Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Feature request: Lenses generation without type signatures #65

Closed
supki opened this Issue Oct 1, 2012 · 4 comments

Comments

Projects
None yet
3 participants
Collaborator

supki commented Oct 1, 2012

In the following code snippet it would be convenient to generate lenses without explicit type signatures for the purpose of documentation:

data A = A { _a  Int, _b  Int }

makeLensesNoTypeSignatures ''A

So we can have nice haddocks:

-- | Lens 'a'
a  Lens A A Int Int

-- | Lens 'b'
b  Lens A A Int Int
Collaborator

mgsloan commented Oct 1, 2012

I like this idea! We were recently lamenting the fact that TH can't
generate haddocks. We could probably have some sort of half decent
generated docs (maybe even describing why the lens is polymorphic in the
fashion that it is!)

It also ensures that the code generator doesn't unexpectedly change its
behavior and output something with an incompatible type (not something we
anticipate happening, but could happen).

On Mon, Oct 1, 2012 at 1:35 PM, Matvey B. Aksenov <notifications@github.com

wrote:

In the following code snippet it would be convenient to generate lenses
without explicit type signatures for the purpose of documentation:

data A = A { _a ∷ Int, _b ∷ Int }
makeLensesNoTypeSignatures ''A

So we can have nice haddocks:

-- | Lens 'a'a ∷ Lens A A Int Int
-- | Lens 'b'b ∷ Lens A A Int Int


Reply to this email directly or view it on GitHubhttps://github.com/ekmett/lens/issues/65.

Owner

ekmett commented Oct 2, 2012

I recall you (or someone else) asking for this on the Haskell channel, but I forgot to make an issue.

I definitely have no problem with adding this.

It is a clean solution to a messy problem.

Collaborator

supki commented Oct 2, 2012

Yes, it was me on #haskell
Thanks, guys.

Owner

ekmett commented Oct 3, 2012

With 3.0.2, you should now be able to do:

makeLensesWith (lensRules % generateSignatures .~ False) ''A

@ekmett ekmett closed this Oct 3, 2012

@ekmett ekmett was assigned Oct 3, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment