[Haskell-cafe] more thoughts on "Finally tagless"

Martijn van Steenbergen martijn at van.steenbergen.nl
Tue Mar 9 18:24:23 EST 2010

Tom Schrijvers wrote:
> data EvalDict sem = EvalDict { val :: Int -> sem Int, add :: sem Int
> -> sem Int -> sem Int }

An alternative option is to capture the structure in a GADT:

> data Eval a where
>   Val :: Int -> Eval Int
>   Add :: Eval Int -> Eval Int -> Eval Int

And then write what were instances before as functions Eval a -> whatever.

Of course, this makes it harder to combine multiple models.


More information about the Haskell-Cafe mailing list