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

Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Barbie.Bare

Contents

- Bare values
- Covering and stripping

Description

Deprecated: Use Barbies.Bare

Synopsis

- type family Wear t f a where ...
- data Bare
- data Covered
- class FunctorB (b Covered) => BareB b where
  - bstrip :: b Covered Identity -> b Bare Identity
  - bcover :: b Bare Identity -> b Covered Identity
- bstripFrom :: BareB b => (forall a. f a -> a) -> b Covered f -> b Bare Identity
- bcoverWith :: BareB b => (forall a. a -> f a) -> b Bare Identity -> b Covered f

# Bare values

type family Wear t f a where ... Source #

The `Wear` type-function allows one to define a Barbie-type as

    data B t f
      = B { f1 :: Wear t f Int
          , f2 :: Wear t f Bool
          }

This gives rise to two rather different types:

- `B `Covered` f` is a normal Barbie-type, in the sense that `f1 :: B `Covered` f -> f `Int``, etc.
- `B `Bare` f`, on the other hand, is a normal record with no functor around the type:

    B { f1 :: 5, f2 = True } :: B Bare f

Equations

Wear Bare f a = a |
Wear Covered f a = f a |
Wear (Param _ t) f a = Wear t f a |
Wear t _ _ = TypeError (('Text "`Wear` should only be used with " ':<>: 'Text "`Bare` or `Covered`.") ':$$: ((('Text "`" ':<>: 'ShowType t) ':<>: 'Text "`") ':<>: 'Text " is not allowed in this context.")) |

data Bare Source #

data Covered Source #

# Covering and stripping

class FunctorB (b Covered) => BareB b where Source #

Class of Barbie-types defined using `Wear` and can therefore have `Bare` versions. Must satisfy:

    bcover . bstrip = id
    bstrip . bcover = id

Minimal complete definition

Nothing

Methods

bstrip :: b Covered Identity -> b Bare Identity Source #

default bstrip :: CanDeriveBareB b => b Covered Identity -> b Bare Identity Source #

bcover :: b Bare Identity -> b Covered Identity Source #

default bcover :: CanDeriveBareB b => b Bare Identity -> b Covered Identity Source #

bstripFrom :: BareB b => (forall a. f a -> a) -> b Covered f -> b Bare Identity Source #

Generalization of `bstrip` to arbitrary functors

bcoverWith :: BareB b => (forall a. a -> f a) -> b Bare Identity -> b Covered f Source #

Generalization of `bcover` to arbitrary functors