Created
August 25, 2017 08:58
-
-
Save as-capabl/450fccdf3b1893ae183bedc80cfaf3ef to your computer and use it in GitHub Desktop.
extensible-effectsの作用の拡大
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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