explicit lambdas for mapXYZ functions

This commit is contained in:
stefan-hoeck 2021-01-20 05:27:08 +01:00
parent a42a34e9f0
commit 313f52a88a
3 changed files with 3 additions and 3 deletions

View File

@ -90,7 +90,7 @@ execRWS m r s = let (_,s1,w) = runRWS m r s
public export %inline
mapRWS : (Monoid w, Semigroup w')
=> ((a, s, w) -> (b, s, w')) -> RWS r w s a -> RWS r w' s b
mapRWS f = mapRWST (Id . f . runIdentity)
mapRWS f = mapRWST \(Id p) => Id (f p)
||| `withRWS f m` executes action `m` with an initial environment
||| and state modified by applying `f`.

View File

@ -59,7 +59,7 @@ execState s = fst . runState s
||| the given function.
public export %inline
mapState : ((s, a) -> (s, b)) -> State s a -> State s b
mapState f = mapStateT (Id . f . runIdentity)
mapState f = mapStateT \(Id p) => Id (f p)
--------------------------------------------------------------------------------
-- Implementations

View File

@ -70,7 +70,7 @@ execWriter = runIdentity . execWriterT
public export %inline
mapWriter : (Monoid w, Semigroup w')
=> ((a, w) -> (b, w')) -> Writer w a -> Writer w' b
mapWriter f = mapWriterT (Id . f . runIdentity)
mapWriter f = mapWriterT \(Id p) => Id (f p)
--------------------------------------------------------------------------------
-- Implementations