1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
--- Types for representing ICurry programs --- @author Marc Andre Wittorf module ICurry.Extended.Types where import ICurry.Types --- An Extended assignment type IEAssign = (IVarIndex, IEExpr) -- Variable = Expression --- An Extended module data IEProg = IEProg String -- module name [String] -- imports [IEDataType] -- declared data types [IEFunction] -- declared functions deriving (Show, Read) type IEQName = (IQName, Int) -- name and a module-unique number to represent -- this name --- An Extended visibility --- @cons Public Visible and usable from other modules --- @cons Private Invisible and not usable from other modules data IEVisibility = Public -- usable from other modules | Private -- usable only in this module deriving (Show, Read) --- An Extended data type type IEDataType = ( IEQName, -- the data type's name IEVisibility, -- if this data type can be used from other modules [ITVarIndex], -- type variables the type is parameterized over [IEConstructor]) -- all possible constructors --- An Extended constructor data IEConstructor = IEConstructor IEQName -- the constructor's name IEVisibility -- if this constructor can be used from other modules [IETExpr] -- one type expression for each argument deriving (Show, Read) --- An Extended type expression --- @cons IETVar a type argument --- @cons IETFunc a functional type --- @cons IETCons a type application data IETExpr = IETVar ITVarIndex -- the type variable | IETFunc IETExpr -- domain type IETExpr -- range type | IETCons IEQName -- the type's name that is applied [IETExpr] -- the arguments deriving (Show, Read) --- An Extended function data IEFunction = IEFunction IEQName -- the function's name IEVisibility -- if this function can be used from other modules IEFuncBody -- what the function does deriving (Show, Read) --- An Extended function's behavior --- @cons IEExternal the function is externally defined --- @cons IEFuncBody the function is defined here data IEFuncBody = IEExternal IArity -- the function's arity String -- the function's external name | IEFuncBody [IVarIndex] -- the function's arguments IEBlock -- the function's actual behavior deriving (Show, Read) --- An Extended block --- @cons IESimpleBlock unconditional evaluation --- @cons IECaseConsBlock conditional evaluation over constructor terms --- @cons IECaseLitBlock conditional evaluation over literals data IEBlock = IESimpleBlock [IEAssign] -- assignments to local variables IEExpr -- the return expression | IECaseConsBlock [IEAssign] -- assignments to local variables IVarIndex -- the variable to differentiate by [IEConsBranch] -- the possible branches | IECaseLitBlock [IEAssign] -- assignments to local variables IVarIndex -- the variable to differentiate by [IELitBranch] -- the possible branches deriving (Show, Read) --- An Extended branch over constructors data IEConsBranch = IEConsBranch IEQName -- the constructor to match this branch [IVarIndex] -- variable bindings IEBlock -- what happens if this branch is taken deriving (Show, Read) --- An Extended branch over literals data IELitBranch = IELitBranch ILiteral -- the literal to match this branch IEBlock -- what happens if this branch is taken deriving (Show, Read) --- An Extended expression --- @cons IEVar a variable --- @cons IELit a literal --- @cons IEFCall a function call --- @cons IECCall a constructor call --- @cons IEOr a non-deterministic choice data IEExpr = IEVar IVarIndex -- the variable | IELit ILiteral -- the literal's value | IEFCall IEQName -- the function's name [IEExpr] -- the arguments | IECCall IEQName -- the constructor's name [IEExpr] -- the arguments | IEOr [IEExpr] -- the possibilities deriving (Show, Read) |