constraints-0.8: Constraint manipulation

Copyright | (C) 2015 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | experimental
Portability | non-portable
Safe Haskell | Safe
Language | Haskell2010

Data.Constraint.Deferrable

Description

The idea for this trick comes from Dimitrios Vytiniotis.

Synopsis

- data UnsatisfiedConstraint = UnsatisfiedConstraint String
- class Deferrable p where
- defer :: forall proxy p r. Deferrable p => proxy p -> (p => r) -> r
- deferred :: forall p. Deferrable p :- p

# Documentation

data UnsatisfiedConstraint #

Constructors

UnsatisfiedConstraint String |

Instances

Show UnsatisfiedConstraint # |
Methods showsPrec :: Int -> UnsatisfiedConstraint -> ShowS # show :: UnsatisfiedConstraint -> String # showList :: [UnsatisfiedConstraint] -> ShowS #
Exception UnsatisfiedConstraint # |
Methods toException :: UnsatisfiedConstraint -> SomeException # fromException :: SomeException -> Maybe UnsatisfiedConstraint # displayException :: UnsatisfiedConstraint -> String #

class Deferrable p where #

Allow an attempt at resolution of a constraint at a later time

Minimal complete definition

deferEither

Methods

deferEither :: proxy p -> (p => r) -> Either String r #

Resolve a `Deferrable` constraint with observable failure.

Instances

(Deferrable a, Deferrable b) => Deferrable (a, b) # |
Methods deferEither :: proxy (a, b) -> ((a, b) -> r) -> Either String r #
(Typeable * a, Typeable * b) => Deferrable ((~) * a b) # |
Methods deferEither :: proxy ((* ~ a) b) -> ((* ~ a) b -> r) -> Either String r #
(Deferrable a, Deferrable b, Deferrable c) => Deferrable (a, b, c) # |
Methods deferEither :: proxy (a, b, c) -> ((a, b, c) -> r) -> Either String r #

defer :: forall proxy p r. Deferrable p => proxy p -> (p => r) -> r #

Defer a constraint for later resolution in a context where we want to upgrade failure into an error

deferred :: forall p. Deferrable p :- p #