on master help sign in
Remove unnecessary proxy passing
17d4165Index Int
src/Control/Monad/Trans/Ether/Except.hs+5−11
@@ -39,7 +39,7 @@ type Except tag e = ExceptT tag e Identity
39
39
40-- | Runs an 'Except' and returns either an exception or a normal value.
40-- | Runs an 'Except' and returns either an exception or a normal value.
41runExcept :: proxy tag -> Except tag e a -> Either e a
41runExcept :: proxy tag -> Except tag e a -> Either e a
42−runExcept t = Trans.runExcept . untagged t
42+runExcept _ = Trans.runExcept . unpack
43
43
44-- | The exception monad transformer.
44-- | The exception monad transformer.
45--
45--
@@ -47,15 +47,9 @@ runExcept t = Trans.runExcept . untagged t
47-- the first exception.
47-- the first exception.
48type ExceptT tag e = TT tag (Trans.ExceptT e)
48type ExceptT tag e = TT tag (Trans.ExceptT e)
49
49
50−tagged :: proxy tag -> Trans.ExceptT e m a -> ExceptT tag e m a
51−tagged _ = pack
52−
53−untagged :: proxy tag -> ExceptT tag e m a -> Trans.ExceptT e m a
54−untagged _ = unpack
55−
56-- | Constructor for computations in the exception monad transformer.
50-- | Constructor for computations in the exception monad transformer.
57exceptT :: proxy tag -> m (Either e a) -> ExceptT tag e m a
51exceptT :: proxy tag -> m (Either e a) -> ExceptT tag e m a
58−exceptT t = tagged t . Trans.ExceptT
52+exceptT _ = pack . Trans.ExceptT
59
53
60-- | Constructor for computations in the exception monad
54-- | Constructor for computations in the exception monad
61-- (the inverse of 'runExcept').
55-- (the inverse of 'runExcept').
@@ -64,12 +58,12 @@ except t = exceptT t . return
64
58
65-- | Runs an 'ExceptT' and returns either an exception or a normal value.
59-- | Runs an 'ExceptT' and returns either an exception or a normal value.
66runExceptT :: proxy tag -> ExceptT tag e m a -> m (Either e a)
60runExceptT :: proxy tag -> ExceptT tag e m a -> m (Either e a)
67−runExceptT t = Trans.runExceptT . untagged t
61+runExceptT _ = Trans.runExceptT . unpack
68
62
69-- | Is used within a monadic computation to begin exception processing.
63-- | Is used within a monadic computation to begin exception processing.
70throw :: Monad m => proxy tag -> e -> ExceptT tag e m a
64throw :: Monad m => proxy tag -> e -> ExceptT tag e m a
71−throw t = tagged t . Trans.throwE
65+throw _ = pack . Trans.throwE
72
66
73-- | A handler function to handle previous exceptions and return to normal execution.
67-- | A handler function to handle previous exceptions and return to normal execution.
74catch :: Monad m => proxy tag -> ExceptT tag e m a -> (e -> ExceptT tag e m a) -> ExceptT tag e m a
68catch :: Monad m => proxy tag -> ExceptT tag e m a -> (e -> ExceptT tag e m a) -> ExceptT tag e m a
75−catch t m h = tagged t $ Trans.catchE (untagged t m) (untagged t . h)
69+catch _ m h = pack $ Trans.catchE (unpack m) (unpack . h)
src/Control/Monad/Trans/Ether/Reader.hs+6−12
@@ -43,34 +43,28 @@ type Reader tag r = ReaderT tag r Identity
43-- the inherited environment to both subcomputations.
43-- the inherited environment to both subcomputations.
44type ReaderT tag r = TT tag (Trans.ReaderT r)
44type ReaderT tag r = TT tag (Trans.ReaderT r)
45
45
46−tagged :: proxy tag -> Trans.ReaderT r m a -> ReaderT tag r m a
47−tagged _ = pack
48−
49−untagged :: proxy tag -> ReaderT tag r m a -> Trans.ReaderT r m a
50−untagged _ = unpack
51−
52-- | Constructor for computations in the reader monad transformer.
46-- | Constructor for computations in the reader monad transformer.
53readerT :: proxy tag -> (r -> m a) -> ReaderT tag r m a
47readerT :: proxy tag -> (r -> m a) -> ReaderT tag r m a
54−readerT t = tagged t . Trans.ReaderT
48+readerT _ = pack . Trans.ReaderT
55
49
56-- | Constructor for computations in the reader monad
50-- | Constructor for computations in the reader monad
57-- (the inverse of 'runReader').
51-- (the inverse of 'runReader').
58reader :: Monad m => proxy tag -> (r -> a) -> ReaderT tag r m a
52reader :: Monad m => proxy tag -> (r -> a) -> ReaderT tag r m a
59−reader t = tagged t . Trans.reader
53+reader _ = pack . Trans.reader
60
54
61-- | Runs a 'ReaderT' with the given environment
55-- | Runs a 'ReaderT' with the given environment
62-- and returns the vinal value.
56-- and returns the vinal value.
63runReaderT :: proxy tag -> ReaderT tag r m a -> r -> m a
57runReaderT :: proxy tag -> ReaderT tag r m a -> r -> m a
64−runReaderT t = Trans.runReaderT . untagged t
58+runReaderT _ = Trans.runReaderT . unpack
65
59
66-- | Runs a 'ReaderT' with the given environment
60-- | Runs a 'ReaderT' with the given environment
67-- and returns the vinal value.
61-- and returns the vinal value.
68runReader :: proxy tag -> Reader tag r a -> r -> a
62runReader :: proxy tag -> Reader tag r a -> r -> a
69−runReader t = Trans.runReader . untagged t
63+runReader _ = Trans.runReader . unpack
70
64
71-- | Fetch the value of the environment.
65-- | Fetch the value of the environment.
72ask :: Monad m => proxy tag -> ReaderT tag r m r
66ask :: Monad m => proxy tag -> ReaderT tag r m r
73−ask t = tagged t Trans.ask
67+ask _ = pack Trans.ask
74
68
75-- | Execute a computation in a modified environment
69-- | Execute a computation in a modified environment
76-- (a specialization of 'withReaderT').
70-- (a specialization of 'withReaderT').
@@ -83,4 +77,4 @@ local
83 -> ReaderT tag r m a
77 -> ReaderT tag r m a
84 -- ^ Computation to run in the modified environment.
78 -- ^ Computation to run in the modified environment.
85 -> ReaderT tag r m a
79 -> ReaderT tag r m a
86−local t f m = tagged t $ Trans.withReaderT f (untagged t m)
80+local _ f = pack . Trans.withReaderT f . unpack
src/Control/Monad/Trans/Ether/State/Lazy.hs+10−16
@@ -46,55 +46,49 @@ type State tag r = StateT tag r Identity
46-- the final state of the first computation as the initial state of the second.
46-- the final state of the first computation as the initial state of the second.
47type StateT tag s = TT tag (Trans.StateT s)
47type StateT tag s = TT tag (Trans.StateT s)
48
48
49−tagged :: proxy tag -> Trans.StateT s m a -> StateT tag s m a
50−tagged _ = pack
51−
52−untagged :: proxy tag -> StateT tag s m a -> Trans.StateT s m a
53−untagged _ = unpack
54−
55-- | Constructor for computations in the state monad transformer.
49-- | Constructor for computations in the state monad transformer.
56stateT :: proxy tag -> (s -> m (a, s)) -> StateT tag s m a
50stateT :: proxy tag -> (s -> m (a, s)) -> StateT tag s m a
57−stateT t = tagged t . Trans.StateT
51+stateT _ = pack . Trans.StateT
58
52
59-- | Constructor for computations in the state monad
53-- | Constructor for computations in the state monad
60-- (the inverse of 'runState').
54-- (the inverse of 'runState').
61state :: Monad m => proxy tag -> (s -> (a, s)) -> StateT tag s m a
55state :: Monad m => proxy tag -> (s -> (a, s)) -> StateT tag s m a
62−state t = tagged t . Trans.state
56+state _ = pack . Trans.state
63
57
64-- | Runs a 'StateT' with the given initial state
58-- | Runs a 'StateT' with the given initial state
65-- and returns both the final value and the final state.
59-- and returns both the final value and the final state.
66runStateT :: proxy tag -> StateT tag s m a -> s -> m (a, s)
60runStateT :: proxy tag -> StateT tag s m a -> s -> m (a, s)
67−runStateT t = Trans.runStateT . untagged t
61+runStateT _ = Trans.runStateT . unpack
68
62
69-- | Runs a 'StateT' with the given initial state
63-- | Runs a 'StateT' with the given initial state
70-- and returns the final value, discarding the final state.
64-- and returns the final value, discarding the final state.
71evalStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m a
65evalStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m a
72−evalStateT t = Trans.evalStateT . untagged t
66+evalStateT _ = Trans.evalStateT . unpack
73
67
74-- | Runs a 'StateT' with the given initial state
68-- | Runs a 'StateT' with the given initial state
75-- and returns the final state, discarding the final value.
69-- and returns the final state, discarding the final value.
76execStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m s
70execStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m s
77−execStateT t = Trans.execStateT . untagged t
71+execStateT _ = Trans.execStateT . unpack
78
72
79-- | Runs a 'State' with the given initial state
73-- | Runs a 'State' with the given initial state
80-- and returns both the final value and the final state.
74-- and returns both the final value and the final state.
81runState :: proxy tag -> State tag s a -> s -> (a, s)
75runState :: proxy tag -> State tag s a -> s -> (a, s)
82−runState t = Trans.runState . untagged t
76+runState _ = Trans.runState . unpack
83
77
84-- | Runs a 'State' with the given initial state
78-- | Runs a 'State' with the given initial state
85-- and returns the final value, discarding the final state.
79-- and returns the final value, discarding the final state.
86evalState :: proxy tag -> State tag s a -> s -> a
80evalState :: proxy tag -> State tag s a -> s -> a
87−evalState t = Trans.evalState . untagged t
81+evalState _ = Trans.evalState . unpack
88
82
89-- | Runs a 'State' with the given initial state
83-- | Runs a 'State' with the given initial state
90-- and returns the final state, discarding the final value.
84-- and returns the final state, discarding the final value.
91execState :: proxy tag -> State tag s a -> s -> s
85execState :: proxy tag -> State tag s a -> s -> s
92−execState t = Trans.execState . untagged t
86+execState _ = Trans.execState . unpack
93
87
94-- | Fetch the current value of the state within the monad.
88-- | Fetch the current value of the state within the monad.
95get :: Monad m => proxy tag -> StateT tag s m s
89get :: Monad m => proxy tag -> StateT tag s m s
96−get t = tagged t Trans.get
90+get _ = pack Trans.get
97
91
98-- | Set the value of the state within the monad.
92-- | Set the value of the state within the monad.
99put :: Monad m => proxy tag -> s -> StateT tag s m ()
93put :: Monad m => proxy tag -> s -> StateT tag s m ()
100−put t = tagged t . Trans.put
94+put _ = pack . Trans.put
src/Control/Monad/Trans/Ether/State/Strict.hs+10−16
@@ -46,55 +46,49 @@ type State tag r = StateT tag r Identity
46-- the final state of the first computation as the initial state of the second.
46-- the final state of the first computation as the initial state of the second.
47type StateT tag s = TT tag (Trans.StateT s)
47type StateT tag s = TT tag (Trans.StateT s)
48
48
49−tagged :: proxy tag -> Trans.StateT s m a -> StateT tag s m a
50−tagged _ = pack
51−
52−untagged :: proxy tag -> StateT tag s m a -> Trans.StateT s m a
53−untagged _ = unpack
54−
55-- | Constructor for computations in the state monad transformer.
49-- | Constructor for computations in the state monad transformer.
56stateT :: proxy tag -> (s -> m (a, s)) -> StateT tag s m a
50stateT :: proxy tag -> (s -> m (a, s)) -> StateT tag s m a
57−stateT t = tagged t . Trans.StateT
51+stateT _ = pack . Trans.StateT
58
52
59-- | Constructor for computations in the state monad
53-- | Constructor for computations in the state monad
60-- (the inverse of 'runState').
54-- (the inverse of 'runState').
61state :: Monad m => proxy tag -> (s -> (a, s)) -> StateT tag s m a
55state :: Monad m => proxy tag -> (s -> (a, s)) -> StateT tag s m a
62−state t = tagged t . Trans.state
56+state _ = pack . Trans.state
63
57
64-- | Runs a 'StateT' with the given initial state
58-- | Runs a 'StateT' with the given initial state
65-- and returns both the final value and the final state.
59-- and returns both the final value and the final state.
66runStateT :: proxy tag -> StateT tag s m a -> s -> m (a, s)
60runStateT :: proxy tag -> StateT tag s m a -> s -> m (a, s)
67−runStateT t = Trans.runStateT . untagged t
61+runStateT _ = Trans.runStateT . unpack
68
62
69-- | Runs a 'StateT' with the given initial state
63-- | Runs a 'StateT' with the given initial state
70-- and returns the final value, discarding the final state.
64-- and returns the final value, discarding the final state.
71evalStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m a
65evalStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m a
72−evalStateT t = Trans.evalStateT . untagged t
66+evalStateT _ = Trans.evalStateT . unpack
73
67
74-- | Runs a 'StateT' with the given initial state
68-- | Runs a 'StateT' with the given initial state
75-- and returns the final state, discarding the final value.
69-- and returns the final state, discarding the final value.
76execStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m s
70execStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m s
77−execStateT t = Trans.execStateT . untagged t
71+execStateT _ = Trans.execStateT . unpack
78
72
79-- | Runs a 'State' with the given initial state
73-- | Runs a 'State' with the given initial state
80-- and returns both the final value and the final state.
74-- and returns both the final value and the final state.
81runState :: proxy tag -> State tag s a -> s -> (a, s)
75runState :: proxy tag -> State tag s a -> s -> (a, s)
82−runState t = Trans.runState . untagged t
76+runState _ = Trans.runState . unpack
83
77
84-- | Runs a 'State' with the given initial state
78-- | Runs a 'State' with the given initial state
85-- and returns the final value, discarding the final state.
79-- and returns the final value, discarding the final state.
86evalState :: proxy tag -> State tag s a -> s -> a
80evalState :: proxy tag -> State tag s a -> s -> a
87−evalState t = Trans.evalState . untagged t
81+evalState _ = Trans.evalState . unpack
88
82
89-- | Runs a 'State' with the given initial state
83-- | Runs a 'State' with the given initial state
90-- and returns the final state, discarding the final value.
84-- and returns the final state, discarding the final value.
91execState :: proxy tag -> State tag s a -> s -> s
85execState :: proxy tag -> State tag s a -> s -> s
92−execState t = Trans.execState . untagged t
86+execState _ = Trans.execState . unpack
93
87
94-- | Fetch the current value of the state within the monad.
88-- | Fetch the current value of the state within the monad.
95get :: Monad m => proxy tag -> StateT tag s m s
89get :: Monad m => proxy tag -> StateT tag s m s
96−get t = tagged t Trans.get
90+get _ = pack Trans.get
97
91
98-- | Set the value of the state within the monad.
92-- | Set the value of the state within the monad.
99put :: Monad m => proxy tag -> s -> StateT tag s m ()
93put :: Monad m => proxy tag -> s -> StateT tag s m ()
100−put t = tagged t . Trans.put
94+put _ = pack . Trans.put
src/Control/Monad/Trans/Ether/Writer.hs+8−14
@@ -50,40 +50,34 @@ type Writer tag w = WriterT tag w Identity
50-- the outputs of the subcomputations using 'mappend'.
50-- the outputs of the subcomputations using 'mappend'.
51type WriterT tag w = TT tag (Trans.WriterT w)
51type WriterT tag w = TT tag (Trans.WriterT w)
52
52
53−tagged :: proxy tag -> Trans.WriterT w m a -> WriterT tag w m a
54−tagged _ = pack
55−
56−untagged :: proxy tag -> WriterT tag w m a -> Trans.WriterT w m a
57−untagged _ = unpack
58−
59-- | Constructor for computations in the writer monad transformer.
53-- | Constructor for computations in the writer monad transformer.
60writerT :: proxy tag -> m (a, w) -> WriterT tag w m a
54writerT :: proxy tag -> m (a, w) -> WriterT tag w m a
61−writerT t = tagged t . Trans.WriterT
55+writerT _ = pack . Trans.WriterT
62
56
63-- | Constructor for computations in the writer monad
57-- | Constructor for computations in the writer monad
64-- (the inverse of 'runWriter').
58-- (the inverse of 'runWriter').
65writer :: Monad m => proxy tag -> (a, w) -> WriterT tag w m a
59writer :: Monad m => proxy tag -> (a, w) -> WriterT tag w m a
66−writer t = tagged t . Trans.writer
60+writer _ = pack . Trans.writer
67
61
68-- | Runs a 'WriterT' and returns both the normal value
62-- | Runs a 'WriterT' and returns both the normal value
69-- and the final accumulator.
63-- and the final accumulator.
70runWriterT :: proxy tag -> WriterT tag w m a -> m (a, w)
64runWriterT :: proxy tag -> WriterT tag w m a -> m (a, w)
71−runWriterT t = Trans.runWriterT . untagged t
65+runWriterT _ = Trans.runWriterT . unpack
72
66
73-- | Runs a 'Writer' and returns both the normal value
67-- | Runs a 'Writer' and returns both the normal value
74-- and the final accumulator.
68-- and the final accumulator.
75runWriter :: proxy tag -> Writer tag w a -> (a, w)
69runWriter :: proxy tag -> Writer tag w a -> (a, w)
76−runWriter t = Trans.runWriter . untagged t
70+runWriter _ = Trans.runWriter . unpack
77
71
78-- | Runs a 'WriterT' and returns the final accumulator,
72-- | Runs a 'WriterT' and returns the final accumulator,
79-- discarding the normal value.
73-- discarding the normal value.
80execWriterT :: Monad m => proxy tag -> WriterT tag w m a -> m w
74execWriterT :: Monad m => proxy tag -> WriterT tag w m a -> m w
81−execWriterT t = Trans.execWriterT . untagged t
75+execWriterT _ = Trans.execWriterT . unpack
82
76
83-- | Runs a 'Writer' and returns the final accumulator,
77-- | Runs a 'Writer' and returns the final accumulator,
84-- discarding the normal value.
78-- discarding the normal value.
85execWriter :: proxy tag -> Writer tag w a -> w
79execWriter :: proxy tag -> Writer tag w a -> w
86−execWriter t = Trans.execWriter . untagged t
80+execWriter _ = Trans.execWriter . unpack
87
81
88-- | Appends a value to the accumulator within the monad.
82-- | Appends a value to the accumulator within the monad.
89tell :: Monad m => proxy tag -> w -> WriterT tag w m ()
83tell :: Monad m => proxy tag -> w -> WriterT tag w m ()
@@ -91,9 +85,9 @@ tell t w = writer t ((), w)
91
85
92-- | Executes an action and adds its accumulator to the value of the computation.
86-- | Executes an action and adds its accumulator to the value of the computation.
93listen :: (Monoid w, Monad m) => proxy tag -> WriterT tag w m a -> WriterT tag w m (a, w)
87listen :: (Monoid w, Monad m) => proxy tag -> WriterT tag w m a -> WriterT tag w m (a, w)
94−listen t m = tagged t $ Trans.listen (untagged t m)
88+listen _ = pack . Trans.listen . unpack
95
89
96-- | Executes an action which returns a value and a function, and returns the
90-- | Executes an action which returns a value and a function, and returns the
97-- value, applying the function to the accumulator.
91-- value, applying the function to the accumulator.
98pass :: (Monoid w, Monad m) => proxy tag -> WriterT tag w m (a, w -> w) -> WriterT tag w m a
92pass :: (Monoid w, Monad m) => proxy tag -> WriterT tag w m (a, w -> w) -> WriterT tag w m a
99−pass t m = tagged t $ Trans.pass (untagged t m)
93+pass _ = pack . Trans.pass . unpack