on master help sign in
Proxy-hash for MonadState
3b7d343Index Int
src/Control/Monad/Ether/Implicit/State/Lazy.hs+14−13
@@ -1,5 +1,6 @@
1{-# LANGUAGE ConstraintKinds #-}
1{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE ScopedTypeVariables #-}
2{-# LANGUAGE ScopedTypeVariables #-}
3+{-# LANGUAGE MagicHash #-}
3
4
4-- | See "Control.Monad.Ether.State.Lazy".
5-- | See "Control.Monad.Ether.State.Lazy".
5
6
@@ -25,7 +26,7 @@ module Control.Monad.Ether.Implicit.State.Lazy
25 , execStateT
26 , execStateT
26 ) where
27 ) where
27
28
28−import Data.Proxy
29+import GHC.Prim (Proxy#, proxy#)
29import qualified Control.Monad.Ether.State.Lazy as Explicit
30import qualified Control.Monad.Ether.State.Lazy as Explicit
30
31
31-- | See 'Control.Monad.Ether.State.Lazy.StateT'.
32-- | See 'Control.Monad.Ether.State.Lazy.StateT'.
@@ -36,51 +37,51 @@ type State s = Explicit.State s s
36
37
37-- | See 'Control.Monad.Ether.State.Lazy.stateT'.
38-- | See 'Control.Monad.Ether.State.Lazy.stateT'.
38stateT :: (s -> m (a, s)) -> StateT s m a
39stateT :: (s -> m (a, s)) -> StateT s m a
39−stateT = Explicit.stateT Proxy
40+stateT = Explicit.stateT proxy#
40
41
41-- | See 'Control.Monad.Ether.State.Lazy.runStateT'.
42-- | See 'Control.Monad.Ether.State.Lazy.runStateT'.
42runStateT :: StateT s m a -> s -> m (a, s)
43runStateT :: StateT s m a -> s -> m (a, s)
43−runStateT = Explicit.runStateT Proxy
44+runStateT = Explicit.runStateT proxy#
44
45
45-- | See 'Control.Monad.Ether.State.Lazy.runState'.
46-- | See 'Control.Monad.Ether.State.Lazy.runState'.
46runState :: State s a -> s -> (a, s)
47runState :: State s a -> s -> (a, s)
47−runState = Explicit.runState Proxy
48+runState = Explicit.runState proxy#
48
49
49-- | See 'Control.Monad.Ether.State.Lazy.evalStateT'.
50-- | See 'Control.Monad.Ether.State.Lazy.evalStateT'.
50evalStateT :: Monad m => StateT s m a -> s -> m a
51evalStateT :: Monad m => StateT s m a -> s -> m a
51−evalStateT = Explicit.evalStateT Proxy
52+evalStateT = Explicit.evalStateT proxy#
52
53
53-- | See 'Control.Monad.Ether.State.Lazy.evalState'.
54-- | See 'Control.Monad.Ether.State.Lazy.evalState'.
54evalState :: State s a -> s -> a
55evalState :: State s a -> s -> a
55−evalState = Explicit.evalState Proxy
56+evalState = Explicit.evalState proxy#
56
57
57-- | See 'Control.Monad.Ether.State.Lazy.execStateT'.
58-- | See 'Control.Monad.Ether.State.Lazy.execStateT'.
58execStateT :: Monad m => StateT s m a -> s -> m s
59execStateT :: Monad m => StateT s m a -> s -> m s
59−execStateT = Explicit.execStateT Proxy
60+execStateT = Explicit.execStateT proxy#
60
61
61-- | See 'Control.Monad.Ether.State.Lazy.execState'.
62-- | See 'Control.Monad.Ether.State.Lazy.execState'.
62execState :: State s a -> s -> s
63execState :: State s a -> s -> s
63−execState = Explicit.execState Proxy
64+execState = Explicit.execState proxy#
64
65
65-- | See 'Control.Monad.Ether.State.Lazy.MonadState'.
66-- | See 'Control.Monad.Ether.State.Lazy.MonadState'.
66type MonadState s = Explicit.MonadState s s
67type MonadState s = Explicit.MonadState s s
67
68
68-- | See 'Control.Monad.Ether.State.Lazy.get'.
69-- | See 'Control.Monad.Ether.State.Lazy.get'.
69get :: forall s m . MonadState s m => m s
70get :: forall s m . MonadState s m => m s
70−get = Explicit.get (Proxy :: Proxy s)
71+get = Explicit.get (proxy# :: Proxy# s)
71
72
72-- | See 'Control.Monad.Ether.State.Lazy.gets'.
73-- | See 'Control.Monad.Ether.State.Lazy.gets'.
73gets :: forall s m a . MonadState s m => (s -> a) -> m a
74gets :: forall s m a . MonadState s m => (s -> a) -> m a
74−gets = Explicit.gets (Proxy :: Proxy s)
75+gets = Explicit.gets (proxy# :: Proxy# s)
75
76
76-- | See 'Control.Monad.Ether.State.Lazy.put'.
77-- | See 'Control.Monad.Ether.State.Lazy.put'.
77put :: forall s m . MonadState s m => s -> m ()
78put :: forall s m . MonadState s m => s -> m ()
78−put = Explicit.put (Proxy :: Proxy s)
79+put = Explicit.put (proxy# :: Proxy# s)
79
80
80-- | See 'Control.Monad.Ether.State.Lazy.state'.
81-- | See 'Control.Monad.Ether.State.Lazy.state'.
81state :: forall s m a . MonadState s m => (s -> (a, s)) -> m a
82state :: forall s m a . MonadState s m => (s -> (a, s)) -> m a
82−state = Explicit.state (Proxy :: Proxy s)
83+state = Explicit.state (proxy# :: Proxy# s)
83
84
84-- | See 'Control.Monad.Ether.State.Lazy.modify'.
85-- | See 'Control.Monad.Ether.State.Lazy.modify'.
85modify :: forall s m . MonadState s m => (s -> s) -> m ()
86modify :: forall s m . MonadState s m => (s -> s) -> m ()
86−modify = Explicit.modify (Proxy :: Proxy s)
87+modify = Explicit.modify (proxy# :: Proxy# s)
src/Control/Monad/Ether/Implicit/State/Strict.hs+14−13
@@ -1,5 +1,6 @@
1{-# LANGUAGE ConstraintKinds #-}
1{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE ScopedTypeVariables #-}
2{-# LANGUAGE ScopedTypeVariables #-}
3+{-# LANGUAGE MagicHash #-}
3
4
4-- | See "Control.Monad.Ether.State.Strict".
5-- | See "Control.Monad.Ether.State.Strict".
5
6
@@ -25,7 +26,7 @@ module Control.Monad.Ether.Implicit.State.Strict
25 , execStateT
26 , execStateT
26 ) where
27 ) where
27
28
28−import Data.Proxy
29+import GHC.Prim (Proxy#, proxy#)
29import qualified Control.Monad.Ether.State.Strict as Explicit
30import qualified Control.Monad.Ether.State.Strict as Explicit
30
31
31-- | See 'Control.Monad.Ether.State.Strict.StateT'.
32-- | See 'Control.Monad.Ether.State.Strict.StateT'.
@@ -36,51 +37,51 @@ type State s = Explicit.State s s
36
37
37-- | See 'Control.Monad.Ether.State.Strict.stateT'.
38-- | See 'Control.Monad.Ether.State.Strict.stateT'.
38stateT :: (s -> m (a, s)) -> StateT s m a
39stateT :: (s -> m (a, s)) -> StateT s m a
39−stateT = Explicit.stateT Proxy
40+stateT = Explicit.stateT proxy#
40
41
41-- | See 'Control.Monad.Ether.State.Strict.runStateT'.
42-- | See 'Control.Monad.Ether.State.Strict.runStateT'.
42runStateT :: StateT s m a -> s -> m (a, s)
43runStateT :: StateT s m a -> s -> m (a, s)
43−runStateT = Explicit.runStateT Proxy
44+runStateT = Explicit.runStateT proxy#
44
45
45-- | See 'Control.Monad.Ether.State.Strict.runState'.
46-- | See 'Control.Monad.Ether.State.Strict.runState'.
46runState :: State s a -> s -> (a, s)
47runState :: State s a -> s -> (a, s)
47−runState = Explicit.runState Proxy
48+runState = Explicit.runState proxy#
48
49
49-- | See 'Control.Monad.Ether.State.Strict.evalStateT'.
50-- | See 'Control.Monad.Ether.State.Strict.evalStateT'.
50evalStateT :: Monad m => StateT s m a -> s -> m a
51evalStateT :: Monad m => StateT s m a -> s -> m a
51−evalStateT = Explicit.evalStateT Proxy
52+evalStateT = Explicit.evalStateT proxy#
52
53
53-- | See 'Control.Monad.Ether.State.Strict.evalState'.
54-- | See 'Control.Monad.Ether.State.Strict.evalState'.
54evalState :: State s a -> s -> a
55evalState :: State s a -> s -> a
55−evalState = Explicit.evalState Proxy
56+evalState = Explicit.evalState proxy#
56
57
57-- | See 'Control.Monad.Ether.State.Strict.execStateT'.
58-- | See 'Control.Monad.Ether.State.Strict.execStateT'.
58execStateT :: Monad m => StateT s m a -> s -> m s
59execStateT :: Monad m => StateT s m a -> s -> m s
59−execStateT = Explicit.execStateT Proxy
60+execStateT = Explicit.execStateT proxy#
60
61
61-- | See 'Control.Monad.Ether.State.Strict.execState'.
62-- | See 'Control.Monad.Ether.State.Strict.execState'.
62execState :: State s a -> s -> s
63execState :: State s a -> s -> s
63−execState = Explicit.execState Proxy
64+execState = Explicit.execState proxy#
64
65
65-- | See 'Control.Monad.Ether.State.Strict.MonadState'.
66-- | See 'Control.Monad.Ether.State.Strict.MonadState'.
66type MonadState s = Explicit.MonadState s s
67type MonadState s = Explicit.MonadState s s
67
68
68-- | See 'Control.Monad.Ether.State.Strict.get'.
69-- | See 'Control.Monad.Ether.State.Strict.get'.
69get :: forall s m . MonadState s m => m s
70get :: forall s m . MonadState s m => m s
70−get = Explicit.get (Proxy :: Proxy s)
71+get = Explicit.get (proxy# :: Proxy# s)
71
72
72-- | See 'Control.Monad.Ether.State.Strict.gets'.
73-- | See 'Control.Monad.Ether.State.Strict.gets'.
73gets :: forall s m a . MonadState s m => (s -> a) -> m a
74gets :: forall s m a . MonadState s m => (s -> a) -> m a
74−gets = Explicit.gets (Proxy :: Proxy s)
75+gets = Explicit.gets (proxy# :: Proxy# s)
75
76
76-- | See 'Control.Monad.Ether.State.Strict.put'.
77-- | See 'Control.Monad.Ether.State.Strict.put'.
77put :: forall s m . MonadState s m => s -> m ()
78put :: forall s m . MonadState s m => s -> m ()
78−put = Explicit.put (Proxy :: Proxy s)
79+put = Explicit.put (proxy# :: Proxy# s)
79
80
80-- | See 'Control.Monad.Ether.State.Strict.state'.
81-- | See 'Control.Monad.Ether.State.Strict.state'.
81state :: forall s m a . MonadState s m => (s -> (a, s)) -> m a
82state :: forall s m a . MonadState s m => (s -> (a, s)) -> m a
82−state = Explicit.state (Proxy :: Proxy s)
83+state = Explicit.state (proxy# :: Proxy# s)
83
84
84-- | See 'Control.Monad.Ether.State.Strict.modify'.
85-- | See 'Control.Monad.Ether.State.Strict.modify'.
85modify :: forall s m . MonadState s m => (s -> s) -> m ()
86modify :: forall s m . MonadState s m => (s -> s) -> m ()
86−modify = Explicit.modify (Proxy :: Proxy s)
87+modify = Explicit.modify (proxy# :: Proxy# s)
src/Control/Monad/Ether/State/Class.hs+7−5
@@ -11,6 +11,7 @@
11{-# LANGUAGE FunctionalDependencies #-}
11{-# LANGUAGE FunctionalDependencies #-}
12{-# LANGUAGE TypeFamilies #-}
12{-# LANGUAGE TypeFamilies #-}
13{-# LANGUAGE PolyKinds #-}
13{-# LANGUAGE PolyKinds #-}
14+{-# LANGUAGE MagicHash #-}
14
15
15-- | See "Control.Monad.State.Class".
16-- | See "Control.Monad.State.Class".
16
17
@@ -20,6 +21,7 @@ module Control.Monad.Ether.State.Class
20 , gets
21 , gets
21 ) where
22 ) where
22
23
24+import GHC.Prim (Proxy#)
23import qualified Control.Monad.Trans.Ether.State.Lazy as S.L
25import qualified Control.Monad.Trans.Ether.State.Lazy as S.L
24import qualified Control.Monad.Trans.Ether.State.Strict as S.S
26import qualified Control.Monad.Trans.Ether.State.Strict as S.S
25import qualified Control.Monad.Trans as Lift
27import qualified Control.Monad.Trans as Lift
@@ -31,15 +33,15 @@ class Monad m => MonadState tag s m | m tag -> s where
31 {-# MINIMAL state | get, put #-}
33 {-# MINIMAL state | get, put #-}
32
34
33 -- | Return the state from the internals of the monad.
35 -- | Return the state from the internals of the monad.
34− get :: proxy tag -> m s
36+ get :: Proxy# tag -> m s
35 get t = state t (\s -> (s, s))
37 get t = state t (\s -> (s, s))
36
38
37 -- | Replace the state inside the monad.
39 -- | Replace the state inside the monad.
38− put :: proxy tag -> s -> m ()
40+ put :: Proxy# tag -> s -> m ()
39 put t s = state t (\_ -> ((), s))
41 put t s = state t (\_ -> ((), s))
40
42
41 -- | Embed a simple state action into the monad.
43 -- | Embed a simple state action into the monad.
42− state :: proxy tag -> (s -> (a, s)) -> m a
44+ state :: Proxy# tag -> (s -> (a, s)) -> m a
43 state t f = do
45 state t f = do
44 s <- get t
46 s <- get t
45 let ~(a, s') = f s
47 let ~(a, s') = f s
@@ -47,11 +49,11 @@ class Monad m => MonadState tag s m | m tag -> s where
47 return a
49 return a
48
50
49-- | Modifies the state inside a state monad.
51-- | Modifies the state inside a state monad.
50−modify :: MonadState tag s m => proxy tag -> (s -> s) -> m ()
52+modify :: MonadState tag s m => Proxy# tag -> (s -> s) -> m ()
51modify t f = state t (\s -> ((), f s))
53modify t f = state t (\s -> ((), f s))
52
54
53-- | Gets specific component of the state, using a projection function supplied.
55-- | Gets specific component of the state, using a projection function supplied.
54−gets :: MonadState tag s m => proxy tag -> (s -> a) -> m a
56+gets :: MonadState tag s m => Proxy# tag -> (s -> a) -> m a
55gets t f = Util.fmap f (get t)
57gets t f = Util.fmap f (get t)
56
58
57instance (Monad m, s ~ s') => MonadState tag s (S.L.StateT tag s' m) where
59instance (Monad m, s ~ s') => MonadState tag s (S.L.StateT tag s' m) where
src/Control/Monad/Trans/Ether/Dispatch.hs+4−5
@@ -67,7 +67,6 @@ import Control.Monad.Morph (MFunctor, MMonad)
67import Control.Monad.Catch (MonadThrow, MonadCatch, MonadMask)
67import Control.Monad.Catch (MonadThrow, MonadCatch, MonadMask)
68import GHC.Generics (Generic)
68import GHC.Generics (Generic)
69import Data.Coerce (coerce)
69import Data.Coerce (coerce)
70−import Data.Proxy
71import GHC.Prim (Proxy#, proxy#)
70import GHC.Prim (Proxy#, proxy#)
72
71
73import qualified Control.Monad.Base as MB
72import qualified Control.Monad.Base as MB
@@ -170,8 +169,8 @@ instance MonadReader tag r m
170
169
171instance MonadState tag s m
170instance MonadState tag s m
172 => Class.MonadState s (DispatchTagAttachT tag m) where
171 => Class.MonadState s (DispatchTagAttachT tag m) where
173− get = let t = Proxy :: Proxy tag in Lift.lift (get t)
172+ get = let t = proxy# :: Proxy# tag in Lift.lift (get t)
174− put = let t = Proxy :: Proxy tag in Lift.lift . put t
173+ put = let t = proxy# :: Proxy# tag in Lift.lift . put t
175
174
176instance MonadExcept tag e m
175instance MonadExcept tag e m
177 => Class.MonadError e (DispatchTagAttachT tag m) where
176 => Class.MonadError e (DispatchTagAttachT tag m) where
@@ -195,8 +194,8 @@ instance MonadReader tNew r m
195
194
196instance MonadState tNew s m
195instance MonadState tNew s m
197 => MonadState tOld s (DispatchTagReplaceT tOld tNew m) where
196 => MonadState tOld s (DispatchTagReplaceT tOld tNew m) where
198− get _ = let t = Proxy :: Proxy tNew in Lift.lift (get t)
197+ get _ = let t = proxy# :: Proxy# tNew in Lift.lift (get t)
199− put _ = let t = Proxy :: Proxy tNew in Lift.lift . put t
198+ put _ = let t = proxy# :: Proxy# tNew in Lift.lift . put t
200
199
201instance MonadExcept tNew e m
200instance MonadExcept tNew e m
202 => MonadExcept tOld e (DispatchTagReplaceT tOld tNew m) where
201 => MonadExcept tOld e (DispatchTagReplaceT tOld tNew m) where
src/Control/Monad/Trans/Ether/State/Lazy.hs+12−10
@@ -6,6 +6,7 @@
6{-# LANGUAGE DataKinds #-}
6{-# LANGUAGE DataKinds #-}
7{-# LANGUAGE PolyKinds #-}
7{-# LANGUAGE PolyKinds #-}
8{-# LANGUAGE GeneralizedNewtypeDeriving #-}
8{-# LANGUAGE GeneralizedNewtypeDeriving #-}
9+{-# LANGUAGE MagicHash #-}
9
10
10-- | See "Control.Monad.Trans.State.Lazy".
11-- | See "Control.Monad.Trans.State.Lazy".
11
12
@@ -28,6 +29,7 @@ module Control.Monad.Trans.Ether.State.Lazy
28 , put
29 , put
29 ) where
30 ) where
30
31
32+import GHC.Prim (Proxy#)
31import Data.Functor.Identity (Identity(..))
33import Data.Functor.Identity (Identity(..))
32import qualified Control.Monad.Trans.State.Lazy as Trans
34import qualified Control.Monad.Trans.State.Lazy as Trans
33import Control.Monad.Trans.Ether.Tagged
35import Control.Monad.Trans.Ether.Tagged
@@ -47,48 +49,48 @@ type State tag r = StateT tag r Identity
47type StateT tag s = TaggedTrans tag (Trans.StateT s)
49type StateT tag s = TaggedTrans tag (Trans.StateT s)
48
50
49-- | Constructor for computations in the state monad transformer.
51-- | Constructor for computations in the state monad transformer.
50−stateT :: proxy tag -> (s -> m (a, s)) -> StateT tag s m a
52+stateT :: Proxy# tag -> (s -> m (a, s)) -> StateT tag s m a
51stateT _ = pack . Trans.StateT
53stateT _ = pack . Trans.StateT
52
54
53-- | Constructor for computations in the state monad
55-- | Constructor for computations in the state monad
54-- (the inverse of 'runState').
56-- (the inverse of 'runState').
55−state :: Monad m => proxy tag -> (s -> (a, s)) -> StateT tag s m a
57+state :: Monad m => Proxy# tag -> (s -> (a, s)) -> StateT tag s m a
56state _ = pack . Trans.state
58state _ = pack . Trans.state
57
59
58-- | Runs a 'StateT' with the given initial state
60-- | Runs a 'StateT' with the given initial state
59-- and returns both the final value and the final state.
61-- and returns both the final value and the final state.
60−runStateT :: proxy tag -> StateT tag s m a -> s -> m (a, s)
62+runStateT :: Proxy# tag -> StateT tag s m a -> s -> m (a, s)
61runStateT _ = Trans.runStateT . unpack
63runStateT _ = Trans.runStateT . unpack
62
64
63-- | Runs a 'StateT' with the given initial state
65-- | Runs a 'StateT' with the given initial state
64-- and returns the final value, discarding the final state.
66-- and returns the final value, discarding the final state.
65−evalStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m a
67+evalStateT :: Monad m => Proxy# tag -> StateT tag s m a -> s -> m a
66evalStateT _ = Trans.evalStateT . unpack
68evalStateT _ = Trans.evalStateT . unpack
67
69
68-- | Runs a 'StateT' with the given initial state
70-- | Runs a 'StateT' with the given initial state
69-- and returns the final state, discarding the final value.
71-- and returns the final state, discarding the final value.
70−execStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m s
72+execStateT :: Monad m => Proxy# tag -> StateT tag s m a -> s -> m s
71execStateT _ = Trans.execStateT . unpack
73execStateT _ = Trans.execStateT . unpack
72
74
73-- | Runs a 'State' with the given initial state
75-- | Runs a 'State' with the given initial state
74-- and returns both the final value and the final state.
76-- and returns both the final value and the final state.
75−runState :: proxy tag -> State tag s a -> s -> (a, s)
77+runState :: Proxy# tag -> State tag s a -> s -> (a, s)
76runState _ = Trans.runState . unpack
78runState _ = Trans.runState . unpack
77
79
78-- | Runs a 'State' with the given initial state
80-- | Runs a 'State' with the given initial state
79-- and returns the final value, discarding the final state.
81-- and returns the final value, discarding the final state.
80−evalState :: proxy tag -> State tag s a -> s -> a
82+evalState :: Proxy# tag -> State tag s a -> s -> a
81evalState _ = Trans.evalState . unpack
83evalState _ = Trans.evalState . unpack
82
84
83-- | Runs a 'State' with the given initial state
85-- | Runs a 'State' with the given initial state
84-- and returns the final state, discarding the final value.
86-- and returns the final state, discarding the final value.
85−execState :: proxy tag -> State tag s a -> s -> s
87+execState :: Proxy# tag -> State tag s a -> s -> s
86execState _ = Trans.execState . unpack
88execState _ = Trans.execState . unpack
87
89
88-- | Fetch the current value of the state within the monad.
90-- | Fetch the current value of the state within the monad.
89−get :: Monad m => proxy tag -> StateT tag s m s
91+get :: Monad m => Proxy# tag -> StateT tag s m s
90get _ = pack Trans.get
92get _ = pack Trans.get
91
93
92-- | Set the value of the state within the monad.
94-- | Set the value of the state within the monad.
93−put :: Monad m => proxy tag -> s -> StateT tag s m ()
95+put :: Monad m => Proxy# tag -> s -> StateT tag s m ()
94put _ = pack . Trans.put
96put _ = pack . Trans.put
src/Control/Monad/Trans/Ether/State/Strict.hs+12−10
@@ -6,6 +6,7 @@
6{-# LANGUAGE DataKinds #-}
6{-# LANGUAGE DataKinds #-}
7{-# LANGUAGE PolyKinds #-}
7{-# LANGUAGE PolyKinds #-}
8{-# LANGUAGE GeneralizedNewtypeDeriving #-}
8{-# LANGUAGE GeneralizedNewtypeDeriving #-}
9+{-# LANGUAGE MagicHash #-}
9
10
10-- | See "Control.Monad.Trans.State.Strict".
11-- | See "Control.Monad.Trans.State.Strict".
11
12
@@ -28,6 +29,7 @@ module Control.Monad.Trans.Ether.State.Strict
28 , put
29 , put
29 ) where
30 ) where
30
31
32+import GHC.Prim (Proxy#)
31import Data.Functor.Identity (Identity(..))
33import Data.Functor.Identity (Identity(..))
32import qualified Control.Monad.Trans.State.Strict as Trans
34import qualified Control.Monad.Trans.State.Strict as Trans
33import Control.Monad.Trans.Ether.Tagged
35import Control.Monad.Trans.Ether.Tagged
@@ -47,48 +49,48 @@ type State tag r = StateT tag r Identity
47type StateT tag s = TaggedTrans tag (Trans.StateT s)
49type StateT tag s = TaggedTrans tag (Trans.StateT s)
48
50
49-- | Constructor for computations in the state monad transformer.
51-- | Constructor for computations in the state monad transformer.
50−stateT :: proxy tag -> (s -> m (a, s)) -> StateT tag s m a
52+stateT :: Proxy# tag -> (s -> m (a, s)) -> StateT tag s m a
51stateT _ = pack . Trans.StateT
53stateT _ = pack . Trans.StateT
52
54
53-- | Constructor for computations in the state monad
55-- | Constructor for computations in the state monad
54-- (the inverse of 'runState').
56-- (the inverse of 'runState').
55−state :: Monad m => proxy tag -> (s -> (a, s)) -> StateT tag s m a
57+state :: Monad m => Proxy# tag -> (s -> (a, s)) -> StateT tag s m a
56state _ = pack . Trans.state
58state _ = pack . Trans.state
57
59
58-- | Runs a 'StateT' with the given initial state
60-- | Runs a 'StateT' with the given initial state
59-- and returns both the final value and the final state.
61-- and returns both the final value and the final state.
60−runStateT :: proxy tag -> StateT tag s m a -> s -> m (a, s)
62+runStateT :: Proxy# tag -> StateT tag s m a -> s -> m (a, s)
61runStateT _ = Trans.runStateT . unpack
63runStateT _ = Trans.runStateT . unpack
62
64
63-- | Runs a 'StateT' with the given initial state
65-- | Runs a 'StateT' with the given initial state
64-- and returns the final value, discarding the final state.
66-- and returns the final value, discarding the final state.
65−evalStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m a
67+evalStateT :: Monad m => Proxy# tag -> StateT tag s m a -> s -> m a
66evalStateT _ = Trans.evalStateT . unpack
68evalStateT _ = Trans.evalStateT . unpack
67
69
68-- | Runs a 'StateT' with the given initial state
70-- | Runs a 'StateT' with the given initial state
69-- and returns the final state, discarding the final value.
71-- and returns the final state, discarding the final value.
70−execStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m s
72+execStateT :: Monad m => Proxy# tag -> StateT tag s m a -> s -> m s
71execStateT _ = Trans.execStateT . unpack
73execStateT _ = Trans.execStateT . unpack
72
74
73-- | Runs a 'State' with the given initial state
75-- | Runs a 'State' with the given initial state
74-- and returns both the final value and the final state.
76-- and returns both the final value and the final state.
75−runState :: proxy tag -> State tag s a -> s -> (a, s)
77+runState :: Proxy# tag -> State tag s a -> s -> (a, s)
76runState _ = Trans.runState . unpack
78runState _ = Trans.runState . unpack
77
79
78-- | Runs a 'State' with the given initial state
80-- | Runs a 'State' with the given initial state
79-- and returns the final value, discarding the final state.
81-- and returns the final value, discarding the final state.
80−evalState :: proxy tag -> State tag s a -> s -> a
82+evalState :: Proxy# tag -> State tag s a -> s -> a
81evalState _ = Trans.evalState . unpack
83evalState _ = Trans.evalState . unpack
82
84
83-- | Runs a 'State' with the given initial state
85-- | Runs a 'State' with the given initial state
84-- and returns the final state, discarding the final value.
86-- and returns the final state, discarding the final value.
85−execState :: proxy tag -> State tag s a -> s -> s
87+execState :: Proxy# tag -> State tag s a -> s -> s
86execState _ = Trans.execState . unpack
88execState _ = Trans.execState . unpack
87
89
88-- | Fetch the current value of the state within the monad.
90-- | Fetch the current value of the state within the monad.
89−get :: Monad m => proxy tag -> StateT tag s m s
91+get :: Monad m => Proxy# tag -> StateT tag s m s
90get _ = pack Trans.get
92get _ = pack Trans.get
91
93
92-- | Set the value of the state within the monad.
94-- | Set the value of the state within the monad.
93−put :: Monad m => proxy tag -> s -> StateT tag s m ()
95+put :: Monad m => Proxy# tag -> s -> StateT tag s m ()
94put _ = pack . Trans.put
96put _ = pack . Trans.put