[Haskell-cafe] Re: Writing an extensible interpreter
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 , designed by ihope (whose name some of
> you may recognise from IRC). The current effort is online , but
> it's at a rather early stage and there's a few modifications I'd like
> to make to it.
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
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe