barbies-2.0.4.0: Classes for working with types that can change clothes.

Safe Haskell | Safe-Inferred
Language | Haskell2010

Barbies.Constraints

Contents

- Instance dictionaries
- Getting constraints

Description

Support for operating on Barbie-types with constrained functions.

Synopsis

- data Dict c a where
  - Dict :: c a => Dict c a
- requiringDict :: (c a => r) -> Dict c a -> r
- type AllBF c f b = AllB (ClassF c f) b
- class c (f a) => ClassF c f a
- class c (f a) (g a) => ClassFG c f g a

# Instance dictionaries

data Dict c a where Source #

``Dict` c a` is evidence that there exists an instance of `c a`.

It is essentially equivalent to `Dict (c a)` from the constraints package, but because of its kind, it allows us to define things like ``Dict` `Show``.

Constructors

Dict :: c a => Dict c a |

#### Instances

Instances details

Show1 (Dict c) Source # |
Instance details Defined in Barbies.Internal.Dicts Methods liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Dict c a -> ShowS Source # liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Dict c a] -> ShowS Source #
Show (Dict c a) Source # |
Instance details Defined in Barbies.Internal.Dicts Methods showsPrec :: Int -> Dict c a -> ShowS Source # show :: Dict c a -> String Source # showList :: [Dict c a] -> ShowS Source #
Eq (Dict c a) Source # |
Instance details Defined in Barbies.Internal.Dicts Methods (==) :: Dict c a -> Dict c a -> Bool Source # (/=) :: Dict c a -> Dict c a -> Bool Source #

requiringDict :: (c a => r) -> Dict c a -> r Source #

Turn a constrained-function into an unconstrained one that uses the packed instance dictionary instead.

# Getting constraints

type AllBF c f b = AllB (ClassF c f) b Source #

Similar to `AllB` but will put the functor argument `f` between the constraint `c` and the type `a`. For example:

      AllB  Show   Person ~ (Show    String,  Show    Int)
      AllBF Show f Person ~ (Show (f String), Show (f Int))

class c (f a) => ClassF c f a Source #

`ClassF` has one universal instance that makes ``ClassF` c f a` equivalent to `c (f a)`. However, we have

    'ClassF c f :: k -> Constraint

This is useful since it allows to define constraint-constructors like ``ClassF` `Monoid` `Maybe``

#### Instances

Instances details

c (f a) => ClassF (c :: k1 -> Constraint) (f :: k2 -> k1) (a :: k2) Source # |
Instance details Defined in Barbies.Internal.Dicts

class c (f a) (g a) => ClassFG c f g a Source #

Like `ClassF` but for binary relations.

#### Instances

Instances details

c (f a) (g a) => ClassFG (c :: k1 -> k2 -> Constraint) (f :: k3 -> k1) (g :: k3 -> k2) (a :: k3) Source # |
Instance details Defined in Barbies.Internal.Dicts