generic-data-1.1.0.2: Deriving instances with GHC.Generics and related utilities

Safe Haskell | None
Language | Haskell2010

Generic.Data.Internal.Newtype

Description

Pack/unpack newtypes.

### Warning

This is an internal module: it is not subject to any versioning policy, breaking changes can happen at any time.

If something here seems useful, please report it or create a pull request to export it from an external module.

Synopsis

- class (Generic a, Coercible a (Old a), Newtype' a) => Newtype a
- type Old a = GOld (Rep a)
- type family GOld (f :: Type -> Type) where ...
- type Newtype' a = NewtypeErr a (MetaDataNewtype (MetaOf (Rep a)))
- type family NewtypeErr a (b :: Bool) where ...
- unpack :: Newtype a => a -> Old a
- pack :: Newtype a => Old a -> a

# Documentation

class (Generic a, Coercible a (Old a), Newtype' a) => Newtype a Source #

Class of newtypes. There is an instance ``Newtype` a` if and only if `a` is a newtype and an instance of `Generic`.

#### Instances

Instances details

(Generic a, Coercible a (Old a), Newtype' a) => Newtype a Source # |
Instance details Defined in Generic.Data.Internal.Newtype

type Old a = GOld (Rep a) Source #

The type wrapped by a newtype.

    newtype Foo = Foo { bar :: Bar } deriving Generic
    -- Old Foo ~ Bar

type family GOld (f :: Type -> Type) where ... Source #

Equations

GOld (D1 _d (C1 _c (S1 _s (K1 _i b :: Type -> Type)))) = b |

type Newtype' a = NewtypeErr a (MetaDataNewtype (MetaOf (Rep a))) Source #

Use `Newtype` instead.

type family NewtypeErr a (b :: Bool) where ... Source #

Equations

NewtypeErr a 'True = () |
NewtypeErr a 'False = TypeError (('Text "The type " ':<>: 'ShowType a) ':<>: 'Text " is not a newtype.") :: Constraint |

unpack :: Newtype a => a -> Old a Source #

Generic newtype destructor.

pack :: Newtype a => Old a -> a Source #

Generic newtype constructor.