higgledy-0.1.0.0: Partial types as a type constructor.

Copyright(c) Tom Harding 2019
LicenseMIT
Maintainertom.harding@habito.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Data.Generic.HKD.Construction

Description

 
Synopsis

Documentation

class Construct (f :: Type -> Type) (structure :: Type) where Source #

When working with the HKD representation, it is useful to have a way to convert to and from our original type. To do this, we can:

  • construct the original type from our HKD representation, and
  • deconstruct the original type into our HKD representation.

As an example, we can try (unsuccessfully) to construct an (Int, Bool) tuple from an unpopulated partial structure.

>>> :set -XTypeApplications
>>> import Data.Monoid (Last)
>>> construct (mempty @(HKD (Int, Bool) Last))
Last {getLast = Nothing}

We can also deconstruct a tuple into a partial structure:

>>> deconstruct @[] ("Hello", True)
(,) ["Hello"] [True]

These two methods also satisfy the round-tripping property:

construct (deconstruct x) == [ x :: (Int, Bool, String) ]

Methods

construct :: HKD structure f -> f structure Source #

deconstruct :: structure -> HKD structure f Source #

Instances
(Functor f, Generic structure, GConstruct f (Rep structure)) => Construct f structure Source # 
Instance details

Defined in Data.Generic.HKD.Construction

Methods

construct :: HKD structure f -> f structure Source #

deconstruct :: structure -> HKD structure f Source #

class GConstruct (f :: Type -> Type) (rep :: Type -> Type) where Source #

Methods

gconstruct :: GHKD_ f rep p -> f (rep p) Source #

gdeconstruct :: rep p -> GHKD_ f rep p Source #

Instances
Applicative f => GConstruct f (K1 index inner :: Type -> Type) Source # 
Instance details

Defined in Data.Generic.HKD.Construction

Methods

gconstruct :: GHKD_ f (K1 index inner) p -> f (K1 index inner p) Source #

gdeconstruct :: K1 index inner p -> GHKD_ f (K1 index inner) p Source #

(Applicative f, GConstruct f left, GConstruct f right) => GConstruct f (left :*: right) Source # 
Instance details

Defined in Data.Generic.HKD.Construction

Methods

gconstruct :: GHKD_ f (left :*: right) p -> f ((left :*: right) p) Source #

gdeconstruct :: (left :*: right) p -> GHKD_ f (left :*: right) p Source #

(Functor f, GConstruct f inner) => GConstruct f (M1 index meta inner) Source # 
Instance details

Defined in Data.Generic.HKD.Construction

Methods

gconstruct :: GHKD_ f (M1 index meta inner) p -> f (M1 index meta inner p) Source #

gdeconstruct :: M1 index meta inner p -> GHKD_ f (M1 index meta inner) p Source #