[Haskell-cafe] [Haskell] ANNOUNCE: lens-family-th 0.1.0.0

Henning Thielemann lemming at henning-thielemann.de
Sat Jul 7 11:29:48 CEST 2012


On Sat, 7 Jul 2012, roconnor at theorem.ca wrote:

> On Fri, 6 Jul 2012, Dan Burton wrote:
>
>> Following the announcement of lens-family, I'm pleased to announce 
>> lens-family-th 0.1.0.0, a Template Haskell library supplying macros to 
>> generate
>> lens-family lenses for fields of data types declared with record syntax.
>> 
>> Be warned that currently, type signatures are *not* generated alongside the 
>> lens definitions. Type inference should correctly determine the type of the
>> generated lenses, but I have structured the library code so that in the 
>> future, type signatures can also be generated. Patches welcome!
>> 
>> http://hackage.haskell.org/package/lens-family-th
>
> I cannot help but wonder if it is better to *not* generate type signatures 
> (or at least have an option not to).

In data-accessor-template we generate type signatures, also because it 
avoids warnings for missing type signatures. However it needed some 
fine-tuning before it worked in all cases.

> At the moment one can write:
>
>> import Lens.Family2.Stock
>> import Lens.Family2.TH
>> 
>> data Foo a = Foo { _bar :: Int, _baz :: a }
>>            deriving (Show, Read, Eq, Ord)
>> $(mkLenses ''Foo)
>> 
>> -- | My documentation for the 'bar' lens.
>> bar :: Lens (Foo a) Int
>> 
>> -- | My documentation for the 'baz' lens.
>> baz :: LensFamily (Foo a) (Foo a') a a'
>
> I don't know if it is possible to add haddock to functions whose type 
> signatures are generated by template haskell.

Could the documentation be an argument of mkLenses?



More information about the Haskell-Cafe mailing list