[jhc] The Wonders of generic applicative traversal routines

Roman Cheplyaka roma at ro-che.info
Tue May 13 06:57:39 UTC 2014


Nice!

See also
http://ro-che.info/articles/2013-03-11-generalizing-gfoldl.html
http://ro-che.info/articles/2013-03-29-gtraverse-vs-gfoldl.html
http://hackage.haskell.org/package/traverse-with-class

* John Meacham <john at repetae.net> [2014-05-12 17:36:43-0700]
> Before
> 
> http://repetae.net/drop/TypeSyns_old.hs
> 
> and after
> 
> http://repetae.net/drop/TypeSyns_new.hs
> 
> that's right, the work of a 550 line complicated file done in a few lines.
> 
> The magic is in FrontEnd.Syn.Traverse where I have a class that
> recurses over arbitrary source syntax and takes a
> 
> data HsOps m = HsOps {
>     opHsDecl :: HsDecl -> m HsDecl,
>     opHsExp  :: HsExp  -> m HsExp,
>     opHsPat  :: HsPat  -> m HsPat,
>     opHsType :: HsType -> m HsType,
>     opHsStmt :: HsStmt -> m HsStmt
>     }
> 
> as an argument, by recursively defining your ops by 'tying the knot'
> each of the routines will recurse down the others. quite handy. Now I
> have about 2500 lines of code to excise from FrontEnd/.
> 
> Many improvements to the front end have been put off due to the sheer
> amount of traversal code that has to modified for every new syntax
> construct. good times.
> 
>     John
> 
> 
> -- 
> John Meacham - http://notanumber.net/
> _______________________________________________
> jhc mailing list
> jhc at haskell.org
> http://www.haskell.org/mailman/listinfo/jhc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://www.haskell.org/pipermail/jhc/attachments/20140513/350296fc/attachment.sig>


More information about the jhc mailing list