Skip to content

Instantly share code, notes, and snippets.

@as-capabl
Created August 25, 2017 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save as-capabl/450fccdf3b1893ae183bedc80cfaf3ef to your computer and use it in GitHub Desktop.
Save as-capabl/450fccdf3b1893ae183bedc80cfaf3ef to your computer and use it in GitHub Desktop.
extensible-effectsの作用の拡大
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
import Control.Eff
import Control.Monad.Free.Reflection
import Data.OpenUnion
import Data.Typeable
-- http://aiya000.github.io/posts/2017-08-22-my-experience-of-eff-convertion.html
upgrade :: (Functor t, Typeable t) => Eff r a -> Eff (t :> r) a
upgrade = fromView . go . toView
where
go (Impure uni) = Impure $ weaken (upgrade <$> uni)
go (Pure x) = Pure x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment