Copyright | (c) Tom Harding 2019 |
---|---|

License | MIT |

Maintainer | tom.harding@habito.com |

Stability | experimental |

Safe Haskell | None |

Language | Haskell2010 |

# 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)`

`>>>`

Last {getLast = Nothing}`construct (mempty @(HKD (Int, Bool) Last))`

We can also *deconstruct* a tuple into a partial structure:

`>>>`

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

These two methods also satisfy the round-tripping property:

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