Closed DanBurton closed 12 years ago
Another possibility is to allow the user to specify field names explicitly.
I've implemented both of these ideas:
mkLensesBy
now requires a (String -> Maybe String)
. Nothings will be skipped over.defaultNameTransform
was adjusted accordingly. It now produces Nothing for any String that does not begin with an underscore.mkLensesFor
, which allows the user to provide an assoc list of fieldName -> lensName. The implementation is merely mkLensesFor fields = mkLensesBy (flip lookup fields)
.
Users may have reason to only want lenses for certain fields of a record. One suggestion was to only create lenses for fields that begin with an underscore. This could be generalized to work with any
String -> Bool
function, in case more flexibility is desired. This shouldn't be too hard to implement, though it does add a little more complexity to the implementation.