Add Algebra instance for Ap.
patrickt opened this issue · comments
Patrick Thomson commented
As @robrix points out, Ap is the identity monad transformer, so we can define a passthrough instance and allow standard effect invocation inside code like this:
foo :: Has Blah sig m => Ap m ()
Rob Rix commented
Better yet, you wouldn’t even have to mention Ap
in the types to use it:
doThings :: [Thing] -> m ()
doThings = getAp . foldMap action
action :: Has Stuff sig m => Thing -> m ()
action thing = do
stuff thing