Re: [Haskell-cafe] Tagless interpreter, expression problem and zipper

2011-03-10 Thread oleg
This is already an improvement to my current code. But I am not entirely satisfied. I can pick and choose which structures to use in my terms but the context type is still an ordinary data type. Each module which extends the expression language with new structures needs to define a

Re: [Haskell-cafe] Tagless interpreter, expression problem and zipper

2011-03-09 Thread oleg
The Tagless final approach can do context-sensitive evaluation, using the well-known trick from the denotational semantics that explicating the context turns context-sensitive semantics to compositional. The trick isn't out of place given how much tagless-final approach is related to denotational

Re: [Haskell-cafe] Tagless interpreter, expression problem and zipper

2011-03-09 Thread Roel van Dijk
Both your replies where very helpful. I combined both approaches to get nearer to what I want. class Lit α where lit ∷ Integer → α class Add α where add ∷ α → α → α instance Lit Integer where lit = fromInteger instance Add Integer where add = (+) This time I require TypeSynonymInstances:

[Haskell-cafe] Tagless interpreter, expression problem and zipper

2011-03-08 Thread Roel van Dijk
Hello everyone, I am stuck rewriting some code in the tagless style. My problem can be thought of as an interpreter for a very simple language: data Exp = Lit Integer | Add Exp Exp | Mul Exp Exp deriving (Show) But some complexity is added by the fact that my

Re: [Haskell-cafe] Tagless interpreter, expression problem and zipper

2011-03-08 Thread Felipe Almeida Lessa
2011/3/8 Roel van Dijk vandijk.r...@gmail.com: Hello everyone, Hello! But I lost the power of the context! How do I get it back? The tagless interpreters splits the interpreter code (in your case, the 'eval' function) into multiple functions on one or more type classes. Now, the key insight