Re: [Haskell-cafe] Haskell source AST zipper with state
On Thu, May 3, 2012 at 2:22 AM, Niklas Broberg wrote: > On Thu, May 3, 2012 at 2:52 AM, Andrew Seniuk wrote: >> >> Note that the "Annotated" version of the HSE parser/AST will probably >> not provide enough generality for the sorts of attributes you want to >> store... > > I do hope you're wrong on that! The annotations are fully general (and have > been all along), so you can store whatever you like there(*). They are > *used* for source locations by the parser, but that's just one possibility. > > (*) The only requirement is that you need to store values of the same type > throughout the syntax tree - but Either or Maybe should do the trick there. Sorry Niklas! Thanks for the mild correction. (Wish I'd understood that when trying to compute the semilattice joins I needed.) Any recommendations for a zipper (or other traversal) library for use with HSE? Andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell source AST zipper with state
On Thu, May 3, 2012 at 2:52 AM, Andrew Seniuk wrote: > Note that the "Annotated" version of the HSE parser/AST will probably > not provide enough > generality for the sorts of attributes you want to store (it's for > source locations, unless something changed in the most recent > release). > I do hope you're wrong on that! The annotations are fully general (and have been all along), so you can store whatever you like there(*). They are *used* for source locations by the parser, but that's just one possibility. Cheers, /Niklas (*) The only requirement is that you need to store values of the same type throughout the syntax tree - but Either or Maybe should do the trick there. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell source AST zipper with state
On Wed, May 2, 2012 at 7:20 PM, Tony Morris wrote: > Is there a library to traverse a source AST keeping state? Hi Tony, I was able to do this [1] using haskell-src-exts and a state monad. AST traversal is possible due to HSE deriving instances for Data in all its datatype declarations, but the traversals were of a generic variety, rather than zippers. I read Scrap Your Zippers [2] and looked at various other generic zipper libs, but in the end I managed without zippers. Note that most zipper libs require instance declarations for all the syntax datatypes -- Scrap Your Zippers only requires the Data instances that HSE comes with, not sure why I was unable to use it, probably just inexperience. Note that the "Annotated" version of the HSE parser/AST will probably not provide enough generality for the sorts of attributes you want to store (it's for source locations, unless something changed in the most recent release). Best of luck, and I'll be interested to hear other responses! -Andrew [1] http://hackage.haskell.org/freesect (in particular FreeSect*.hs) [2] https://www.cs.indiana.edu/~adamsmd/papers/scrap_your_zippers/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell source AST zipper with state
Is there a library to traverse a source AST keeping state? -- Tony Morris http://tmorris.net/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe