lexi-lambda / freer-simple

A friendly effect system for Haskell
https://hackage.haskell.org/package/freer-simple
BSD 3-Clause "New" or "Revised" License
227 stars 19 forks source link

Eff computations are coercible to each other #41

Open UlfNorell opened 1 year ago

UlfNorell commented 1 year ago
{-# 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)