@@ -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.Reader".
11-- | See "Control.Monad.Trans.Reader".
@@ -24,6 +25,7 @@ module Control.Monad.Trans.Ether.Reader
28+import GHC.Prim (Proxy#)
27import Data.Functor.Identity (Identity(..))
29import Data.Functor.Identity (Identity(..))
28import qualified Control.Monad.Trans.Reader as Trans
30import qualified Control.Monad.Trans.Reader as Trans
29import Control.Monad.Trans.Ether.Tagged
31import Control.Monad.Trans.Ether.Tagged
@@ -44,26 +46,26 @@ type Reader tag r = ReaderT tag r Identity
44type ReaderT tag r = TaggedTrans tag (Trans.ReaderT r)
46type ReaderT tag r = TaggedTrans tag (Trans.ReaderT r)
46-- | Constructor for computations in the reader monad transformer.
48-- | Constructor for computations in the reader monad transformer.
47−readerT :: proxy tag -> (r -> m a) -> ReaderT tag r m a
49+readerT :: Proxy# tag -> (r -> m a) -> ReaderT tag r m a
48readerT _ = pack . Trans.ReaderT
50readerT _ = pack . Trans.ReaderT
50-- | Constructor for computations in the reader monad
52-- | Constructor for computations in the reader monad
51-- (the inverse of 'runReader').
53-- (the inverse of 'runReader').
52−reader :: Monad m => proxy tag -> (r -> a) -> ReaderT tag r m a
54+reader :: Monad m => Proxy# tag -> (r -> a) -> ReaderT tag r m a
53reader _ = pack . Trans.reader
55reader _ = pack . Trans.reader
55-- | Runs a 'ReaderT' with the given environment
57-- | Runs a 'ReaderT' with the given environment
56-- and returns the final value.
58-- and returns the final value.
57−runReaderT :: proxy tag -> ReaderT tag r m a -> r -> m a
59+runReaderT :: Proxy# tag -> ReaderT tag r m a -> r -> m a
58runReaderT _ = Trans.runReaderT . unpack
60runReaderT _ = Trans.runReaderT . unpack
60-- | Runs a 'ReaderT' with the given environment
62-- | Runs a 'ReaderT' with the given environment
61-- and returns the final value.
63-- and returns the final value.
62−runReader :: proxy tag -> Reader tag r a -> r -> a
64+runReader :: Proxy# tag -> Reader tag r a -> r -> a
63runReader _ = Trans.runReader . unpack
65runReader _ = Trans.runReader . unpack
65-- | Fetch the value of the environment.
67-- | Fetch the value of the environment.
66−ask :: Monad m => proxy tag -> ReaderT tag r m r
68+ask :: Monad m => Proxy# tag -> ReaderT tag r m r
67ask _ = pack Trans.ask
69ask _ = pack Trans.ask
69-- | Execute a computation in a modified environment
71-- | Execute a computation in a modified environment
@@ -71,7 +73,7 @@ ask _ = pack Trans.ask
72-- * @'runReaderT' tag ('local' tag f m) = 'runReaderT' tag m . f@
74-- * @'runReaderT' tag ('local' tag f m) = 'runReaderT' tag m . f@
74− :: proxy tag
76+ :: Proxy# tag
75 -> (r -> r)
77 -> (r -> r)
76 -- ^ The function to modify the environment.
78 -- ^ The function to modify the environment.
77 -> ReaderT tag r m a
79 -> ReaderT tag r m a