[Haskell-cafe] extensible effects and open unions

Suhail Shergill suhailshergill at gmail.com
Mon Dec 1 06:14:40 UTC 2014


adam vogt <vogt.adam at gmail.com> writes:

> You need to write an instance of TCode for every different "effect"
> included in the union for the lookup to work. 
> ...

thanks for the explanation; the Includes instances make more sense now

> I think you're better off depending on a
>
> type family Eq :: Bool where
>  Eq x x = True
>  Eq x y = False
>
> Or the equivalent with overlapping instances if the code is supposed
> to work with ghc-7.6.

yes, i've updated the code on hackage to fall back on the overlapping instances
implementation for ghc-7.6

> Another objection about TList is that it is a linked list, so operations with
> types at the "end" of the union are probably relatively slow at runtime, since
> you end up pattern matching on "n" T constructors in some cases.

that may just be a limitation for the code being written for ghc-7.4 iiuc

> It might be faster to have more of that traversal done at compile time as in:
>
>  http://code.haskell.org/HList/Data/HList/Variant.hs

thanks for the additional reference. i've been meaning to read up on HList;
perhaps this will be my segue

> Or with unions that use Typeable.

actually with Typeable being kind polymorphic in ghc-7.8, the improved deriving
code, -XAutoDeriveTypeable and -XStandaloneDeriving i don't see much of a
drawback with the above approach.

> I'm not sure about your other questions.

yes, they were more directed at oleg (in the cc), but figured others might have
made their way through these waters before me, so it couldn't hurt to ask.

cheers

-- 
Suhail


More information about the Haskell-Cafe mailing list