Sat Oct 22 09:42:14 EDT 2011

Expression form

So, with the insight that letrec is a possible way of representing
state machines with lexical data context, it's best to adopt this
simpler tree representation.

The only remaining problem is representation of output storage.

I made a fix distinguishing a variable representation from a

type VarName   = String
type LitRep    = String
type OpName    = String
data TypeName  = AFloat | AInt | AVoid deriving (Eq)
type Order     = Int

-- Language syntax terms.
data Var  = Var TypeName VarName Order
          deriving (Eq)
data Term = Ref Var                     -- variable reference
          | Lit TypeName LitRep         -- literal
          | Op  TypeName OpName [Term]  -- primitive operation
          deriving (Eq)

On top of this the flowchart language becomes:

type FunName = String
data Fun     = Fun FunName            -- function reference
data FBind   = FBind Fun [Var] Expr   -- function definition

data Expr = Let     Bind Expr
          | LetRec  [FBind] Expr
          | If      Term Expr Expr
          | Apply   Fun [Var]