Safe Haskell | Safe-Inferred |
---|---|

Language | Haskell2010 |

## Synopsis

- type family UnrollAll xs ∷ [Type] where ...
- type family Unroll (p ∷ Type) ∷ [Type] where ...
- type family Break e (rep ∷ Type → Type) ∷ Type → Type where ...
- type family NoGeneric t where ...
- type family GUnroll (t ∷ Type → Type) ∷ [Type] where ...
- type family Insert x xs where ...
- type family Prepend x xs where ...
- type family Concat (as ∷ [k]) (bs ∷ [k]) ∷ [k] where ...
- type family (as ∷ [k]) ++ (bs ∷ [k]) ∷ [k] where ...
- class Unrollable ts where
- unroll ∷ Definitions ts

- deriveDefinitions ∷ ∀ ts. Unrollable (UnrollAll ts) ⇒ Definitions (UnrollAll ts)

# Documentation

type family Unroll (p ∷ Type) ∷ [Type] where ... Source #

Unroll a type into a list of all nested types (including the type itself).

If a type doesn't have a generic representation, then this type family gets "stuck". The good news is that for the purpose of deriving schema definitions, we only need to consider types that are either end-user defined (and therefore have a generic representation) or built-in types that we explicitly list here as terminals in order not to get "stuck".

Unroll Int = '[Int] | |

Unroll Integer = '[Integer] | |

Unroll Text = '[Text] | |

Unroll BuiltinData = '[BuiltinData] | |

Unroll BuiltinUnit = '[BuiltinUnit] | |

Unroll BuiltinString = '[BuiltinString] | |

Unroll (BuiltinList a) = Prepend (BuiltinList a) (GUnroll (Rep a)) | |

Unroll BuiltinByteString = '[BuiltinByteString] | |

Unroll p = Prepend p (GUnroll (Break (NoGeneric p) (Rep p))) |

type family Break e (rep ∷ Type → Type) ∷ Type → Type where ... Source #

Detect stuck type family: https://blog.csongor.co.uk/report-stuck-families/#custom-type-errors

type family GUnroll (t ∷ Type → Type) ∷ [Type] where ... Source #

Unroll a generic representation of a type into a list of all nested types.

type family (as ∷ [k]) ++ (bs ∷ [k]) ∷ [k] where ... infixr 5 Source #

Concatenates two type-level lists removing duplicates.

class Unrollable ts where Source #

This class and its two instances are used internally to derive
`Definitions`

for a given list of types.

unroll ∷ Definitions ts Source #

#### Instances

Unrollable ('[] ∷ [Type]) Source # | |

Defined in PlutusTx.Blueprint.Definition.Unroll unroll ∷ Definitions '[] Source # | |

(Unrollable ts, AsDefinitionId t, HasSchema t ts) ⇒ Unrollable (t ': ts) Source # | |

Defined in PlutusTx.Blueprint.Definition.Unroll unroll ∷ Definitions (t ': ts) Source # |

deriveDefinitions ∷ ∀ ts. Unrollable (UnrollAll ts) ⇒ Definitions (UnrollAll ts) Source #