Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upImprove integration with lens #22
Comments
This comment has been minimized.
This comment has been minimized.
|
Erratum: both So for the second option the haskell record doesn't need to match the prefix namespace. |
This comment has been minimized.
This comment has been minimized.
|
I took the option 2 road which is kind of ok. If it is not too much trouble I still believe it would be nice if the Interpreter could optionally ignore 'underscore' from haskell record. |
This comment has been minimized.
This comment has been minimized.
newhoggy
commented
Feb 21, 2017
|
Just bumped into this issue as well. |
This comment has been minimized.
This comment has been minimized.
|
Yeah, I plan to fix this. I would like to support |
Gabriel439
added a commit
that referenced
this issue
Feb 22, 2017
This comment has been minimized.
This comment has been minimized.
|
I have a PR out with support for customizing the field and constructor labels that the derived generic implementation expects: #24 Let me know if that solves your issue. If it does then I'll merge |
This comment has been minimized.
This comment has been minimized.
|
It works nicely with one record but I am experiencing a behaviour that I don't understand when I have two:
This code will fail to compile:
As soon as I stop hiding |
This comment has been minimized.
This comment has been minimized.
|
I have realized that if I inline |
This comment has been minimized.
This comment has been minimized.
|
This probably means that I am supposed to write :
Why not exposing a |
This comment has been minimized.
This comment has been minimized.
|
@PierreR You are being bit by the monomorphism restriction. You can either enable auto :: (GenericInterpret (Rep a), Generic a) => Type a
auto = deriveAuto
(defaultInterpretOptions { fieldModifier = Data.Text.Lazy.dropWhile (== '_') }) |
This comment has been minimized.
This comment has been minimized.
|
@Gabriel439 Thanks ! This monomorphism restriction always comes as a surprise ;-) |
This comment has been minimized.
This comment has been minimized.
|
As an extra note, |
This comment has been minimized.
This comment has been minimized.
|
A part from these minor points, please merge, this is such a nice improvement. Thanks for the PR. |
This comment has been minimized.
This comment has been minimized.
|
The missing |
PierreR commentedFeb 10, 2017
AFAIK in its current form, if I want to re-use records with lenses, I have two options:
_in configuration filesprefixthat will match the Haskell recordAs a note using
makeLensesWith abbreviatedFieldswon't work with records containing Vector field.The first option is the easiest path. It is annoying in the sense that end-users will face
_in all record keys.The second option not only forces the use of a namespace for each fields. For instance for such a record in a file 'box':
It would be converted into:
But it also forces the name of the 'prefix' to match the name of the haskell record exactly. In this example, if I want to use
BoxConfiginstead of justBoxin the haskell code I will be out of luck.Is it possible to imagine that the
Interpreterwould be clever enough to optionally ignore 'underscore' from haskell record ?with