@@ -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 #-}
10-- | See "Control.Monad.Trans.State.Strict".
11-- | See "Control.Monad.Trans.State.Strict".
@@ -28,6 +29,7 @@ module Control.Monad.Trans.Ether.State.Strict
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)
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
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
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
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
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
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
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
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
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
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