Should lens formation be treated as instances

I have a data type defined in another library. I would like to connect to this data type using the lens generated by the Control.Lens library.

Do I need to use newtype my type in my code or is it considered safe for the lens of an already defined data type?

+3
source share
1 answer

You do not need a new type. In fact, there are many hack packages that define lenses for existing types (for example, xml-lensor even lens).

The problem with defining instances is that they cannot be hidden. If you define lenses, you can just hide them when importing, like any other function:

import Module.Lens hiding (someGeneratedLens, ...)

(. fooobar.com/questions/19642/... ). .

+6

All Articles