fused-effects / fused-effects

A fast, flexible, fused effect system for Haskell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add Algebra instance for Ap.

patrickt opened this issue · comments

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 ()

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