[Haskell-cafe] makeFields without lenses

Benjamin Edwards edwards.benj at gmail.com
Sat Oct 4 11:03:05 UTC 2014


The compiler automatically provides accessor functions already. You can't have more than one function with the same name in the same module without a qualified import.

Ben

On Sat, Oct 4, 2014 at 2:57 PM, Nicola Gigante <nicola.gigante at gmail.com>
wrote:

> Good morning to everyone.
> I really love what makeFields from
> Control.Lens.TH does: generating
> a typeclasse HasXXX for each
> field _typeXXX and instances of the class
> for each type that has a record field
> with the same name.
> However, it generates lenses, which 
> at this time I don’t use in my little project.
> I'll learn to use them well sooner or later,
> I promise! In the meantime, is there
> some module out there than provides a
> template haskell function that do the
> same thing but generating simple accessor
> functions instead of lenses? Or can I
> configure the parameters of makeFieldsWith
> to generate simple functions instead of
> lenses?
> Another related question: if I use makeFields
> in more than one module, and different records
> have fields with the same name, the generated
> typeclasses will have the same name but will
> be different, because declared twice in different 
> modules, am I right? Is there a way to use a unique
> typeclass in the whole project for every generated
> field of the same name? 
> Thank you very much,
> Nicola
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20141004/e1342466/attachment.html>


More information about the Haskell-Cafe mailing list