[jhc] The Wonders of generic applicative traversal routines

Roman Cheplyaka roma at ro-che.info
Tue May 13 16:12:55 UTC 2014


Sjoerd Visscher says:

«You might want to point him to multiplate too, that's an exact match with what
he's doing. (I'm not on the jhc mailing list)»
(https://twitter.com/sjoerd_visscher/status/466247707699736576)

* 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/d02a58bc/attachment.sig>


More information about the jhc mailing list