[Haskell-cafe] Syntax programming with lexemes rather than trees?

Neil Mitchell ndmitchell at gmail.com
Tue Mar 23 16:43:11 EDT 2010


Hi Stephen,

It actually sounds like your representation has structure, but you
dislike structure because it's hard to work with. The solution is a
generics library, and I recommend Uniplate:
http://community.haskell.org/~ndm/uniplate

Imagine you have a ridiculously complex AST, with beam groups under
tuplets etc, and you want to delete the first item from every beam
group:

transform f
  where f (Beam (x:xs)) = Beam xs
           f x = x

Uniplate moves through tuplets and any other hierarchical syntax, so
you just specify the transformation. My guess is if you throw away the
structure then you'll need it back for some operations.

Thanks, Neil

2010/3/22 Stephen Tetley <stephen.tetley at gmail.com>:
> Hi Malcolm
>
> Thanks - particularly I don't want to go to an AST because its I'm
> finding it too convoluted 'shape wise' - processing beam groups inside
> tuplets etc. is a nightmare - music representations have had at least
> eight centuries of ad hoc extension.
>
> I know Norman Ramsey and colleagues papers on low-level
> representations - I'll give them a re-reading.
>
> Thanks again
>
> Stephen
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list