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

MonadFail constraint on Entity _ _ <- pattern match #1393

Closed
parsonsmatt opened this issue Apr 16, 2022 · 2 comments
Closed

MonadFail constraint on Entity _ _ <- pattern match #1393

parsonsmatt opened this issue Apr 16, 2022 · 2 comments

Comments

@parsonsmatt
Copy link
Collaborator

You may be running into a problem where, upon upgrading to persistent-2.14, you're seeing a ton of MonadFail constraints arise due to pattern matching on Enttiy in a bind arrow.

foo = do
    Entity userId user <- getBy $ UserEmail "foo@bar.com"
    ...

This is a bug in GHC, where the COMPLETE pragma for a PatternSynonym is not taken into account in do notation. Here's the GHC issue: https://gitlab.haskell.org/ghc/ghc/-/issues/15681

@parsonsmatt
Copy link
Collaborator Author

To work around:

  1. Add the MonadFail constraint. This kinda sucks, but it's the easiest way for now.
  2. Use the Entity' constructor, which is not a synonym. This does not have record fields, though, which sucks.

These work-arounds are both pretty crappy, so I'm tempted to make this a compile-time opt-in flag that's on by default whenever the GHC bug is fixed.

@parsonsmatt
Copy link
Collaborator Author

closed in #1401

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

No branches or pull requests

1 participant