We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7bd5f66 commit d8ccd51Copy full SHA for d8ccd51
StateT.hs
@@ -1,10 +1,18 @@
1
{-# LANGUAGE MultiParamTypeClasses #-}
2
{-# LANGUAGE FlexibleInstances #-}
3
+module StateT where
4
+
5
import Control.Monad
-import Control.Monad.Trans
6
7
newtype MyStateT s m a = MyStateT { runMyStateT :: s -> m (a,s) }
8
9
+class MonadTrans t where
10
+ lift :: Monad m => m a -> t m a
11
12
+class (MonadState s m) where
13
+ get :: m s
14
+ put :: s -> m ()
15
16
instance Monad m => Functor (MyStateT s m) where
17
fmap = liftM
18
@@ -24,6 +32,7 @@ instance MonadTrans (MyStateT s) where
24
32
x' <- x
25
33
return (x',s)
26
34
27
-get = MyStateT $ \ s -> return (s,s)
28
-put s = MyStateT $ \ _ -> return ((),s)
35
+instance Monad m => MonadState s (MyStateT s m) where
36
+ get = MyStateT $ \ s -> return (s,s)
37
+ put s = MyStateT $ \ _ -> return ((),s)
29
38
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments