[Haskell-cafe] design problem, "varying intermediate types"

Robert Vollmert rvollmert-lists at gmx.net
Fri Apr 4 20:49:24 UTC 2014


On Apr 4, 2014, at 19:42 , Alexander Solla <alex.solla at gmail.com> wrote:
> It seems to me that you might benefit from a "compiler" approach.  In such a design, you parse the input text, turn it into an abstract syntax tree, and then interpret the tree (typically in terms of some monad, but not necessarily).

Thanks, the program does seem obviously compiler-like now that it’s been suggested! This will at least help thinking about it.

> The "intermediate" data type is definitely tricky to get down.  If you are having trouble expressing it in a way that fits your other design constraints, you might want to look into stuff like "data types a la carte" or the "syntactic" package.  But really, standard Haskell data types are pretty good at this kind of thing.  
> 
> You shouldn't need data types a la carte unless you're trying to make a "pluggable" F-algebra.  (That is, a data type that you can "extend" by importing a library)

Fun, I never had a reason to look at the data types a la carte and friends before. Though I’m not sure to what extent these approaches are a good fit given that my input doesn’t have any recursive structure? I do sort of want to keep the intermediate type “open”, though that may well be a mistake…

I’ll keep thinking about it, thanks for the input!

Cheers
Rob



More information about the Haskell-Cafe mailing list