Haddock version during build
David Waern
david.waern at gmail.com
Fri Jun 13 16:14:34 EDT 2008
2008/6/13 Neil Mitchell <ndmitchell at gmail.com>:
> Hi
>
> A few points of clarification:
>
> * If you want to use Derive generated instances, you don't need to
> depend on Derive, since it can be used quite happily as a
> preprocessor.
To further clarify this: no, you don't need to depend on the derive
package. But you'd want to regenerate the instances each build (or
atleast when the relevant types are modified). Otherwise, you lose one
the main advantages of using generics on the GHC datatypes, which is
that your code becomes resistant to AST changes. So you'd still get a
dependency on the derive *program*. Perhaps this is obvious.
> * I don't think the GHC syntax tree types derive Data/Typeable, but I
> could be wrong. I would suggest that they should, if technically
> possible.
>
> * Uniplate works perfectly well on all data types that SYB can deal
> with. It requires no extensions in the single type case, and very
> gentle and simple MPTC's for multitype operations. Since this is
> GHC-land, simple MPTC hardly even counts as an extension! In general,
> Uniplate is at least as powerful as SYB, in terms of what types it can
> operate over.
>
> My suggestion would be:
>
> 1) Add deriving Data/Typeable to all the types inside GHC,
> particularly the abstract syntax tree ones.
>
> 2) Use either SYB or Uniplate to operate over them. Uniplate will
> probably lead to simpler and shorter code, but more complex
> dependencies - unless you just want to grab a copy of Uniplate and
> shove it in bundled. SYB will be a bit longer and more complex, but
> probably not by a substantial amount - you'll still get all the
> goodness that operating generically brings. I would suspect that using
> Traversable is not as neat as either SYB or Uniplate.
Hmm, I guess it depends on what you want to do. Take the example of
replacing the renamer in Haddock with a monadic map over all the names
in the AST (the AST is parameterized by the type of names). In this
case Traversable is much more simple than SYB. In fact, I couldn't
even figure out how to do it with SYB when I tried. With uniplate I
don't know how it would look, if it is possible.
David
More information about the Cvs-libraries
mailing list