[Haskell-cafe] Re: Writing an extensible interpreter
Jonathan Tang
nostrademons at gmail.com
Sun May 21 21:24:34 EDT 2006
> Message: 2
> From: "David House" <dmhouse at gmail.com>
> Subject: [Haskell-cafe] Writing an extensible interpreter
> I'm in the process of writing an interpreter for the self-modifying
> automaton languages SMATINY [1], designed by ihope (whose name some of
> you may recognise from IRC). The current effort is online [2], but
> it's at a rather early stage and there's a few modifications I'd like
> to make to it.
[snip]
However, the remaining issue is step 1): how would the metacode handle
> additional constructors to the Step ADT? Type classes won't work here:
> the intepreter has a type of [Step] -> String. With type classes this
> would have a type of something like Step a => [a] -> String, but by
> the homogeneity of lists you'd only be able to have one type of step
> in your program.
>
> You can get around the homogeneity of lists problem with existential
types:
http://www.haskell.org/hawiki/ExistentialTypes
http://halogen.note.amherst.edu/~jdtang/scheme_in_48/tutorial/evaluator2.html#equal
Another solution might be to eliminate the algebraic data type entirely and
have the Parsec actions return a Smatiny action. Instead of dispatching on
the constructor of Step, package up any information you need as a closure
and make Step a type synonym for 'Smatiny ()' or 'Smatiny a' or whatever
type you need. Then the interpreter main loop just executes the action
returned by the parser.
- Jonathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org//pipermail/haskell-cafe/attachments/20060521/fe51711b/attachment.htm
More information about the Haskell-Cafe
mailing list