I just started to learn Haskell three days ago, aiming for a interpreter for some custom-ed semantics in Haskell. I have the Racket implementation of the interpreter, the match
matching on the S-Expression in Racket is pretty handy. When it comes to Haskell, I am not quite sure whether there is something similar exists?
or I have to write some data types and parse the S-Expressions to the data types defined and then use some matching mechanism in Haskell?
The thing I want to match (in racket), for example, if there is an input (from a file or stand input) like: (lambda (v1 v2) (+ v1 v2))
, then in Racket, I can write the pattern like:
(lambda (,v ...) ,body)
. and then do what I want later on.
In Haskell, can I do something similar?