Skip to content

Instantly share code, notes, and snippets.

@as-capabl as-capabl/upgrade.hs
Created Aug 25, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.