haskeline icon indicating copy to clipboard operation
haskeline copied to clipboard

Add `mapInputT_`

Open janmasrovira opened this issue 1 year ago • 0 comments

This PR adds a variation of mapInputT that only works on the unit type.

mapInputT_ :: (m () -> m ()) -> InputT m () -> InputT m ()
mapInputT_ f = InputT . mapReaderT (mapReaderT (mapReaderT
                                  (mapReaderT (mapReaderT f))))
                    . unInputT

Note that mapInputT_ cannot be implemented in terms of mapInputT because of the forall b quantifier inside the first argument of mapInputT. Thus, it makes sense to also export mapInputT_, since there are cases in which it can be useful.

janmasrovira avatar May 25 '23 21:05 janmasrovira