[Haskell-cafe] Lenses: Should I declare Getters?

Oliver Charles ollie at ocharles.org.uk
Tue Sep 10 17:06:44 CEST 2013


On 09/10/2013 06:31 AM, Charlie Paul wrote:
> I've been looking through Edward Kmett's lens library, and I'm a bit
> befuddled about Getters. In my own code, why would I want to have
> something be a Getter instead of a plain function? As far as I can see,
> a plain function is simpler to use, and can be converted to a Getter
> with "to" if we want to use it as a Fold. Is there a situation where
> writing a Getter is superior than writing a function, then lifting it as
> needed?

Generally, you don't provide 'Getter's because people can always lift a
function with "to" - as you said. This is mentioned in the lens FAQ at:

https://github.com/ekmett/lens/wiki/FAQ#wiki-using-getters

- ocharles


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130910/33b68c56/attachment.pgp>


More information about the Haskell-Cafe mailing list