[Haskell-cafe] Poor man's generic programming
ndmitchell at gmail.com
Tue Jan 19 14:09:41 EST 2010
>> Uniplate is simple (only multi parameter type classes, and even then
>> only in a very simple usage), fast (one of the fastest generics
>> libraries) and concise (probably the most concise generics library).
>> It's also not as powerful as most of the other generics libraries, but
>> I find it does about 98% of the generics tasks I need. Uniplate is
>> used extensively in virtually all my tools, for example HLint.
> Must a package import Uniplate, if it uses Uniplate generics, or is it a
> preprocessor like I sketched?
Uniplate is a library, not a preprocessor. To depend on uniplate
simply add it to your cabal file, and import the correct module. There
is no preprocessor, and there are no wacky extensions. If you restrict
yourself to some part of the library it's even totally Haskell 98, but
none of it's not Haskell 2011.
>> As an example, I guess your function returns all the Int's embedded
>> within a data type, at any level?
> I abstracted the Bin example from GHC's generic extension introduction:
That's one thing Uniplate can't do. But if you want a preprocessor to
generate Binary instances can I recommend Derive
More information about the Haskell-Cafe