freer-simple icon indicating copy to clipboard operation
freer-simple copied to clipboard

Eff computations are coercible to each other

Open UlfNorell opened this issue 3 years ago • 0 comments

{-# LANGUAGE DataKinds #-}

import Control.Monad.Freer
import Control.Monad.Freer.Reader
import Control.Monad.Freer.State
import Data.Coerce

badness :: Eff '[Reader (Int, Int)] a -> Eff '[State Int] a
badness = coerce

boom :: (Int, Int)
boom = run $ evalState 17 (badness ask)

I believe the fix is to add a role annotation

type role Union nominal nominal

here: https://github.com/lexi-lambda/freer-simple/blob/5304190c1deae1fa8905144ed79774e90d9c7247/src/Data/OpenUnion/Internal.hs#L39-L41

(I can make a PR if welcome)

UlfNorell avatar Nov 15 '22 12:11 UlfNorell