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

Tillmann Rendel rendel at Mathematik.Uni-Marburg.de
Wed Mar 10 05:01:38 EST 2010


Martijn van Steenbergen wrote:
> 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.

But these interpreter functions Eval a -> whatever would have to use 
pattern matching at runtime to discover the structure of the term, so 
this approach is no longer tagless.

   Tillmann


More information about the Haskell-Cafe mailing list