Skip to content

Instantly share code, notes, and snippets.

@hanshoglund
Created August 28, 2017 10:46
Show Gist options
  • Save hanshoglund/f708c834a5c7ee70d72aa20e1316e665 to your computer and use it in GitHub Desktop.
Save hanshoglund/f708c834a5c7ee70d72aa20e1316e665 to your computer and use it in GitHub Desktop.

Handlers

-- Problem: Fill in _ to 'handle' the B effect
-- Try using a separate algebra + freer monad
-- See if one technique subsumes the other

foo :: Write_ A m => m a
foo = _ bar

bar :: Write_ B m => m a
bar = ...

-- Most general way
-- Make B an algebra over effects used in bar (e.g. using Freer)
-- Make the outer monad (return type of foo an instance of (Has BAlg)), so ... = liftTo
data BAlg a = ...

instance Write_ a m => Has BAlg m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment