[Haskell-beginners] evaluation of expressions [was Re: eval command?]

Tillmann Rendel rendel at daimi.au.dk
Wed Oct 29 04:27:32 EDT 2008


Andrew Sackville-West schrieb:
> this raises a question for me, being a bit of a schemer. Is there any
> parallel in haskell to the data is code model of the lisp family? 

No.

> My initial impression is no, that you'd have to parse it as an
> expression and evaluate it as you would in regular imperative
> languages. I'd love to hear otherwise.

I don't see how "code is data" is connected to imperative vs. purely 
functional. After all, lisp & co. are not purely functional, but feature 
"code is data". Another well-known symbolic language, which allows to 
treat code as data and vice versa, is prolog.

Since Haskell features algebraic data types, and a reasonable flexible 
syntax, you do not need to do any parsing. Instead, you can write down 
the AST of the embedded language directly as part of your Haskell 
program. But you have to write an evaluator. With pattern matching, that 
is often very easy, though.

   Tillmann


More information about the Beginners mailing list