
10 Mar
2010
10 Mar
'10
5:01 a.m.
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