Copyright | (c) Murdoch J. Gabbay 2020 |
---|---|
License | GPL-3 |
Maintainer | murdoch.gabbay@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Based on an example in the Bound package.
What makes this interesting is the binding behaviour of Add
, which adds two numbers and binds the result to a fresh register with scope over subsequent instructions.
Documentation
An operand is an integer literal or a variable
Instances
Eq Operand Source # | |
Show Operand Source # | |
Generic Operand Source # | |
Swappable Operand Source # | |
KSub V Operand Prog Source # | Substitution on |
KSub V Operand Operand Source # | Substitution as standard on |
type Rep Operand Source # | |
Defined in Language.Nominal.Examples.Assembly1 type Rep Operand = D1 (MetaData "Operand" "Language.Nominal.Examples.Assembly1" "nom-0.1.0.1-3UtpNOnqRlSC6EhVIia7SR" False) (C1 (MetaCons "Lit" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)) :+: C1 (MetaCons "Var" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 V))) |
Terms of our assembly language
Ret Operand | Return a value |
Add Operand Operand (KAbs V Prog) | Add two operands and store the value in a fresh variable which is local to subsequent computation (the third argument) |
Instances
Eq Prog Source # | |
Show Prog Source # | |
Generic Prog Source # | |
Swappable Prog Source # | |
KSub V Operand Prog Source # | Substitution on |
type Rep Prog Source # | |
Defined in Language.Nominal.Examples.Assembly1 type Rep Prog = D1 (MetaData "Prog" "Language.Nominal.Examples.Assembly1" "nom-0.1.0.1-3UtpNOnqRlSC6EhVIia7SR" False) (C1 (MetaCons "Ret" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Operand)) :+: C1 (MetaCons "Add" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Operand) :*: (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Operand) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (KAbs V Prog))))) |
evalOperand :: Operand -> Int Source #
Evaluate an operand.
- A literal maps to its corresponding integer.
- If asked to evaluate a free variable, complain.
example1eval :: Int Source #
6