Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

makePrisms example in the README doesn't compile #914

Closed
RyanGlScott opened this issue Feb 19, 2020 · 0 comments · Fixed by #946
Closed

makePrisms example in the README doesn't compile #914

RyanGlScott opened this issue Feb 19, 2020 · 0 comments · Fixed by #946
Labels

Comments

@RyanGlScott
Copy link
Collaborator

The README currently provides this example of how to use makePrisms:

You can automatically derive isomorphisms for your own newtypes with makePrisms. e.g.

newtype Neither a b = Neither { _nor :: Either a b } deriving (Show)
makePrisms ''Neither

will automatically derive

neither :: Iso (Neither a b) (Neither c d) (Either a b) (Either c d)
nor :: Iso (Either a b) (Either c d) (Neither a b) (Neither c d)

such that

from neither = nor
from nor = neither
neither.nor = id
nor.neither = id

Unfortunately, this example appears to have bitrotted severely, as it no longer compiles with modern lens. Declaring makePrisms ''Neither won't generate Isos named neither or nor, despite what it claims, but rather it will generate:

_Neither :: Iso (Neither a b) (Neither c d) (Either a b) (Either c d)

As far as I can tell, there is no TH functionality to generate the nor Iso above. (You can use makeLenses ''Prisms, but that will generate nor :: Iso (Neither a b) (Neither c d) (Either a b) (Either c d), which is a different type than the one claimed above.)

My guess is that generating neither/nor was the behavior of the old makeIso function, which was removed nearly six years ago in favor of makePrisms. However, this example in the README was never updated accordingly.

RyanGlScott added a commit that referenced this issue Oct 9, 2020
The section in the `README` about TH-generated prisms for newtypes has
severely bitrotted to the point where it doesn't compile anymore. I have
attempted to modernize this section and document what the current behavior is.

Resolves #914.

[ci skip]
RyanGlScott added a commit that referenced this issue Oct 10, 2020
The section in the `README` about TH-generated prisms for newtypes has
severely bitrotted to the point where it doesn't compile anymore. I have
attempted to modernize this section and document what the current behavior is.

Resolves #914.

[ci skip]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant