@@ -122,6 +122,9 @@ eval ctxt genv tm = ev [] tm where
122122 chooseAlt _ (VP (DCon i a) _ _, args) alts amap
123123 | Just (ns, sc) <- findTag i alts = Just (updateAmap (zip ns args) amap, sc)
124124 | 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)
125128 chooseAlt _ (VConstant c, []) alts amap
126129 | Just v <- findConst c alts = Just (amap, v)
127130 | Just v <- findDefault alts = Just (amap, v)
@@ -142,6 +145,11 @@ eval ctxt genv tm = ev [] tm where
142145
143146 findConst c [] = Nothing
144147 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
145153 findConst c (_ : xs) = findConst c xs
146154
147155 getValArgs tm = getValArgs' tm []
@@ -199,10 +207,10 @@ addTyDecl :: Name -> Type -> Context -> Context
199207addTyDecl n ty ctxt = addDef n (TyDecl Ref ty (eval ctxt [] ty)) ctxt
200208
201209addDatatype :: Datatype Name -> Context -> Context
202−addDatatype (Data n ty cons) ctxt
210+addDatatype (Data n tag ty cons) ctxt
203211 = let ty' = normalise ctxt [] ty in
204212 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)
206214 where
207215 addCons tag [] ctxt = ctxt
208216 addCons tag ((n, ty) : cons) ctxt
@@ -210,9 +218,9 @@ addDatatype (Data n ty cons) ctxt
210218 addCons (tag+1) cons (addDef n
211219 (TyDecl (DCon tag (arity ty')) ty (eval ctxt [] ty)) ctxt)
212220
213−addCasedef :: Name -> [(Term, Term)] -> Type -> Context -> Context
214−addCasedef n ps ty ctxt
215− = case simpleCase ps of
221+addCasedef :: Name -> Bool -> [(Term, Term)] -> Type -> Context -> Context
222+addCasedef n tcase ps ty ctxt
223+ = case simpleCase tcase ps of
216224 CaseDef args sc -> addDef n (CaseOp ty ps args sc) ctxt
217225
218226addOperator :: Name -> Type -> Int -> ([Value] -> Maybe Value) -> Context -> Context