freer-simple icon indicating copy to clipboard operation
freer-simple copied to clipboard

Add a function to map the effect list

Open sjoerdvisscher opened this issue 3 years ago • 0 comments

After a bit of refactoring some freer-simple related code I ended up with this function:

mapEffs :: (Union effs ~> Union effs') -> Eff effs ~> Eff effs'
mapEffs f = loop where
    loop = \case
        Val a -> pure a
        E u q -> E (f u) (tsingleton $ qComp q loop)

It seems this might a useful thing to add to the library. Note that I have no idea if this implementation is a good one (or even if it makes sense really.)

sjoerdvisscher avatar Dec 06 '21 15:12 sjoerdvisscher