| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
PlutusTx.Blueprint.Definition.Unroll
Synopsis
- class HasBlueprintDefinition t where
- type Unroll t :: [Type]
- definitionId :: DefinitionId
- type family UnrollIsStuckError (x :: t) :: k where ...
- type family RepIsStuckError (x :: t) :: k where ...
- type Unrolled t = Reverse (IfStuckUnroll (UnrollIsStuckError t :: [Type]) (Unroll t))
- type family UnrollAll (xs :: [Type]) :: [Type] where ...
- type family GUnroll (t :: Type -> Type) :: [Type] where ...
Documentation
class HasBlueprintDefinition t where Source #
Designates a class of types that could be used as a Blueprint Definition.
Each such type:
- could be unrolled to a list of all nested types (including the type itself).
- has a unique DefinitionId.
Minimal complete definition
Nothing
Associated Types
type Unroll t :: [Type] Source #
type Unroll t = Insert t (GUnroll (IfStuckRep (RepIsStuckError t :: Type -> Type) (Rep t)))
Methods
definitionId :: DefinitionId Source #
default definitionId :: Typeable t => DefinitionId Source #
Derive a DefinitionId for a type.
Instances
type family UnrollIsStuckError (x :: t) :: k where ... Source #
Compile-time error that happens when a type couldn't be unrolled
(Unroll TF is "stuck").
Note: This error commonly occurs when using 'DefinitionsFor (UnrollAll '[a])'
with an abstract type variable a. Type families like UnrollAll must be fully
evaluated at compile time, which is not possible when the type is not yet known.
Equations
| UnrollIsStuckError (x :: t) = TypeError ((((((((((('Text "Cannot unroll type '" ':<>: 'ShowType x) ':<>: 'Text "'.") ':$$: 'Text "The 'Unroll' type family is stuck because:") ':$$: 'Text " - The type may be abstract (a type variable), or") ':$$: 'Text " - It lacks a 'HasBlueprintDefinition' instance, or") ':$$: 'Text " - It lacks a 'Generic' instance for default unrolling.") ':$$: 'Text "") ':$$: 'Text "Tip: 'DefinitionsFor (UnrollAll ts)' requires all types in 'ts'") ':$$: 'Text "to be concrete at compile time. Polymorphic constraints like") ':$$: 'Text "'DefinitionsFor (UnrollAll '[a])' cannot be used as superclass") ':$$: 'Text "constraints because 'a' is not known when the class is defined.") :: k |
type family RepIsStuckError (x :: t) :: k where ... Source #
Compile-time error that happens when type's generic representation is not defined
(Rep TF is "stuck")
Equations
| RepIsStuckError (x :: t) = TypeError ((((('Text "Cannot derive generic representation for type '" ':<>: 'ShowType x) ':<>: 'Text "'.") ':$$: 'Text "Add 'deriving Generic' to enable automatic blueprint unrolling,") ':$$: 'Text "or provide a manual 'HasBlueprintDefinition' instance with") ':$$: 'Text "an explicit 'Unroll' type instance.") :: k |
type Unrolled t = Reverse (IfStuckUnroll (UnrollIsStuckError t :: [Type]) (Unroll t)) Source #
Same as Unroll but with a nicer error message