| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Morley.Michelson.Typed.ClassifiedInstr.Internal.WithClassifiedInstr
Description
A more ergonomic way of matching on classified instructions.
Documentation
class WithClassifiedInstr instr where Source #
Associated Types
type WCIConstraint instr (cls' :: InstrClass) :: Constraint Source #
Methods
withClassifiedInstr :: forall t inp out r. ClassifyInstr t => (forall cls. (SingI cls, WCIConstraint instr cls) => Sing (GetClassified cls :: t) -> ClassifiedInstr cls inp out -> r) -> instr inp out -> r Source #
Perform a computation with a classified instruction.
Intended to be used with LambdaCase, e.g.
isRealInstr :: T.Instr a b -> Bool isRealInstr = withClassifiedInstr \caseSFromMichelson-> TrueSStructural-> FalseSAdditional-> \caseC_Nop-> FalseC_Ext{} -> TrueSPhantom-> False
You can use withClassifiedInstr again to obtain a different classification:
go =withClassifiedInstr\caseSFailingNormal->withClassifiedInstr\caseSNoChildren-> _
If you need to reference the original instruction, consider using & for
convenient pointful syntax:
go i = i &withClassifiedInstr\caseSFailingNormal->withClassifiedInstr\caseSNoChildren-> doStuffWith i
Instances
| WithClassifiedInstr Instr Source # | |
Defined in Morley.Michelson.Typed.ClassifiedInstr.Internal.WithClassifiedInstr Associated Types type WCIConstraint Instr cls' Source # Methods withClassifiedInstr :: forall t (inp :: [T]) (out :: [T]) r. ClassifyInstr t => (forall (cls :: InstrClass). (SingI cls, WCIConstraint Instr cls) => Sing (GetClassified cls) -> ClassifiedInstr cls inp out -> r) -> Instr inp out -> r Source # | |
| SingI cls => WithClassifiedInstr (ClassifiedInstr cls) Source # | |
Defined in Morley.Michelson.Typed.ClassifiedInstr.Internal.WithClassifiedInstr Associated Types type WCIConstraint (ClassifiedInstr cls) cls' Source # Methods withClassifiedInstr :: forall t (inp :: [T]) (out :: [T]) r. ClassifyInstr t => (forall (cls0 :: InstrClass). (SingI cls0, WCIConstraint (ClassifiedInstr cls) cls0) => Sing (GetClassified cls0) -> ClassifiedInstr cls0 inp out -> r) -> ClassifiedInstr cls inp out -> r Source # | |