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

Deferrable with default values #57

Open
Icelandjack opened this issue May 20, 2017 · 1 comment
Open

Deferrable with default values #57

Icelandjack opened this issue May 20, 2017 · 1 comment

Comments

@Icelandjack
Copy link
Contributor

Icelandjack commented May 20, 2017

These might be useful for Data.Constraint.Deferrable

deferWithDefault_ :: forall c. Deferrable c => forall r. r -> (c => r) -> r
deferWithDefault_ def r =
  case deferEither_ @c r of
    Left  err -> def
    Right a   -> a

deferWithDefault :: Deferrable c => proxy c -> r -> (c => r) -> r
deferWithDefault proxy def r =
  case deferEither proxy r of
    Left  err -> def
    Right a   -> a
@ekmett
Copy link
Owner

ekmett commented Jun 1, 2017

I have no particular objection to adding these.

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

2 participants