@@ -122,6 +122,9 @@ eval ctxt genv tm = ev [] tm where
122 chooseAlt _ (VP (DCon i a) _ _, args) alts amap
122 chooseAlt _ (VP (DCon i a) _ _, args) alts amap
123 | Just (ns, sc) <- findTag i alts = Just (updateAmap (zip ns args) amap, sc)
123 | Just (ns, sc) <- findTag i alts = Just (updateAmap (zip ns args) amap, sc)
124 | Just v <- findDefault alts = Just (amap, v)
124 | Just v <- findDefault alts = Just (amap, v)
125+ chooseAlt _ (VP (TCon i a) _ _, args) alts amap
126+ | Just (ns, sc) <- findTag i alts = Just (updateAmap (zip ns args) amap, sc)
127+ | Just v <- findDefault alts = Just (amap, v)
125 chooseAlt _ (VConstant c, []) alts amap
128 chooseAlt _ (VConstant c, []) alts amap
126 | Just v <- findConst c alts = Just (amap, v)
129 | Just v <- findConst c alts = Just (amap, v)
127 | Just v <- findDefault alts = Just (amap, v)
130 | Just v <- findDefault alts = Just (amap, v)
@@ -142,6 +145,11 @@ eval ctxt genv tm = ev [] tm where
143 findConst c [] = Nothing
146 findConst c [] = Nothing
144 findConst c (ConstCase c' v : xs) | c == c' = Just v
147 findConst c (ConstCase c' v : xs) | c == c' = Just v
148+ findConst IType (ConCase n 1 [] v : xs) = Just v
149+ findConst FlType (ConCase n 2 [] v : xs) = Just v
150+ findConst ChType (ConCase n 3 [] v : xs) = Just v
151+ findConst StrType (ConCase n 4 [] v : xs) = Just v
152+ findConst PtrType (ConCase n 5 [] v : xs) = Just v
145 findConst c (_ : xs) = findConst c xs
153 findConst c (_ : xs) = findConst c xs
147 getValArgs tm = getValArgs' tm []
155 getValArgs tm = getValArgs' tm []
@@ -199,10 +207,10 @@ addTyDecl :: Name -> Type -> Context -> Context
199addTyDecl n ty ctxt = addDef n (TyDecl Ref ty (eval ctxt [] ty)) ctxt
207addTyDecl n ty ctxt = addDef n (TyDecl Ref ty (eval ctxt [] ty)) ctxt
201addDatatype :: Datatype Name -> Context -> Context
209addDatatype :: Datatype Name -> Context -> Context
202−addDatatype (Data n ty cons) ctxt
210+addDatatype (Data n tag ty cons) ctxt
203 = let ty' = normalise ctxt [] ty in
211 = let ty' = normalise ctxt [] ty in
204 addCons 0 cons (addDef n
212 addCons 0 cons (addDef n
205− (TyDecl (TCon (arity ty')) ty (eval ctxt [] ty)) ctxt)
213+ (TyDecl (TCon tag (arity ty')) ty (eval ctxt [] ty)) ctxt)
207 addCons tag [] ctxt = ctxt
215 addCons tag [] ctxt = ctxt
208 addCons tag ((n, ty) : cons) ctxt
216 addCons tag ((n, ty) : cons) ctxt
@@ -210,9 +218,9 @@ addDatatype (Data n ty cons) ctxt
210 addCons (tag+1) cons (addDef n
218 addCons (tag+1) cons (addDef n
211 (TyDecl (DCon tag (arity ty')) ty (eval ctxt [] ty)) ctxt)
219 (TyDecl (DCon tag (arity ty')) ty (eval ctxt [] ty)) ctxt)
213−addCasedef :: Name -> [(Term, Term)] -> Type -> Context -> Context
221+addCasedef :: Name -> Bool -> [(Term, Term)] -> Type -> Context -> Context
214−addCasedef n ps ty ctxt
222+addCasedef n tcase ps ty ctxt
215− = case simpleCase ps of
223+ = case simpleCase tcase ps of
216 CaseDef args sc -> addDef n (CaseOp ty ps args sc) ctxt
224 CaseDef args sc -> addDef n (CaseOp ty ps args sc) ctxt
218addOperator :: Name -> Type -> Int -> ([Value] -> Maybe Value) -> Context -> Context
226addOperator :: Name -> Type -> Int -> ([Value] -> Maybe Value) -> Context -> Context