@@ -211,7 +211,7 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
211211 ev ntimes (n:stk) True env tm
212212 [(TyDecl nt ty, _)] -> do vty <- ev ntimes stk True env ty
213213 return $ VP nt n vty
214− [(CaseOp ci _ _ _ cd, acc)]
214+ [(CaseOp ci _ _ _ _ cd, acc)]
215215 | (acc /= Frozen) &&
216216 null (fst (cases_totcheck cd)) -> -- unoptimised version
217217 let (ns, tree) = getCases cd in
@@ -284,7 +284,7 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
284284 reapply ntimes stk top env f@(VP Ref n ty) args
285285 = let val = lookupDefAcc n (spec || atRepl) ctxt in
286286 case val of
287− [(CaseOp ci _ _ _ cd, acc)] ->
287+ [(CaseOp ci _ _ _ _ cd, acc)] ->
288288 let (ns, tree) = getCases cd in
289289 do c <- evCase ntimes n (n:stk) top env ns args tree
290290 case c of
@@ -310,7 +310,7 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
310310 if u then
311311 do let val = lookupDefAcc n (spec || atRepl) ctxt
312312 case val of
313− [(CaseOp ci _ _ _ cd, acc)]
313+ [(CaseOp ci _ _ _ _ cd, acc)]
314314 | acc /= Frozen -> -- unoptimised version
315315 let (ns, tree) = getCases cd in
316316 if blockSimplify ci n stk
@@ -561,8 +561,8 @@ convEq ctxt = ceq [] where
561561 sameDefs ps x y = case (lookupDef x ctxt, lookupDef y ctxt) of
562562 ([Function _ xdef], [Function _ ydef])
563563 -> ceq ((x,y):ps) xdef ydef
564− ([CaseOp _ _ _ _ xd],
565− [CaseOp _ _ _ _ yd])
564+ ([CaseOp _ _ _ _ _ xd],
565+ [CaseOp _ _ _ _ _ yd])
566566 -> let (_, xdef) = cases_compiletime xd
567567 (_, ydef) = cases_compiletime yd in
568568 caseeq ((x,y):ps) xdef ydef
@@ -588,6 +588,7 @@ data Def = Function !Type !Term
588588 | Operator Type Int ([Value] -> Maybe Value)
589589 | CaseOp CaseInfo
590590 !Type
591+ ![Type] -- argument types
591592 ![Either Term (Term, Term)] -- original definition
592593 ![([Name], Term, Term)] -- simplified for totality check definition
593594 !CaseDefs
@@ -620,7 +621,7 @@ instance Show Def where
620621 show (Function ty tm) = "Function: " ++ show (ty, tm)
621622 show (TyDecl nt ty) = "TyDecl: " ++ show nt ++ " " ++ show ty
622623 show (Operator ty _ _) = "Operator: " ++ show ty
623− show (CaseOp (CaseInfo inlc inlr) ty ps_in ps cd)
624+ show (CaseOp (CaseInfo inlc inlr) ty atys ps_in ps cd)
624625 = let (ns, sc) = cases_compiletime cd
625626 (ns_t, sc_t) = cases_totcheck cd
626627 (ns', sc') = cases_runtime cd in
@@ -752,6 +753,7 @@ addDatatype (Data n tag ty cons) uctxt
752753
753754-- FIXME: Too many arguments! Refactor all these Bools.
754755addCasedef :: Name -> CaseInfo -> Bool -> Bool -> Bool -> Bool ->
756+ [Type] -> -- argument types
755757 [Either Term (Term, Term)] ->
756758 [([Name], Term, Term)] -> -- totality
757759 [([Name], Term, Term)] -> -- compile time
@@ -759,16 +761,16 @@ addCasedef :: Name -> CaseInfo -> Bool -> Bool -> Bool -> Bool ->
759761 [([Name], Term, Term)] -> -- run time
760762 Type -> Context -> Context
761763addCasedef n ci@(CaseInfo alwaysInline tcdict)
762− tcase covering reflect asserted ps_in
763− ps_tot ps_inl ps_ct ps_rt ty uctxt
764+ tcase covering reflect asserted argtys
765+ ps_in ps_tot ps_inl ps_ct ps_rt ty uctxt
764766 = let ctxt = definitions uctxt
765767 access = case lookupDefAcc n False uctxt of
766768 [(_, acc)] -> acc
767769 _ -> Public
768− ctxt' = case (simpleCase tcase covering reflect CompileTime emptyFC ps_tot,
769− simpleCase tcase covering reflect CompileTime emptyFC ps_ct,
770− simpleCase tcase covering reflect CompileTime emptyFC ps_inl,
771− simpleCase tcase covering reflect RunTime emptyFC ps_rt) of
770+ ctxt' = case (simpleCase tcase covering reflect CompileTime emptyFC argtys ps_tot,
771+ simpleCase tcase covering reflect CompileTime emptyFC argtys ps_ct,
772+ simpleCase tcase covering reflect CompileTime emptyFC argtys ps_inl,
773+ simpleCase tcase covering reflect RunTime emptyFC argtys ps_rt) of
772774 (OK (CaseDef args_tot sc_tot _),
773775 OK (CaseDef args_ct sc_ct _),
774776 OK (CaseDef args_inl sc_inl _),
@@ -781,7 +783,7 @@ addCasedef n ci@(CaseInfo alwaysInline tcdict)
781783 (args_inl, sc_inl)
782784 (args_rt, sc_rt) in
783785 addDef n (CaseOp (ci { case_inlinable = inlc })
784− ty ps_in ps_tot cdef,
786+ ty argtys ps_in ps_tot cdef,
785787 access, Unchecked, EmptyMI) ctxt in
786788 uctxt { definitions = ctxt' }
787789
@@ -790,15 +792,15 @@ simplifyCasedef :: Name -> Context -> Context
790792simplifyCasedef n uctxt
791793 = let ctxt = definitions uctxt
792794 ctxt' = case lookupCtxt n ctxt of
793− [(CaseOp ci ty [] ps _, acc, tot, metainf)] ->
795+ [(CaseOp ci ty atys [] ps _, acc, tot, metainf)] ->
794796 ctxt -- nothing to simplify (or already done...)
795− [(CaseOp ci ty ps_in ps cd, acc, tot, metainf)] ->
797+ [(CaseOp ci ty atys ps_in ps cd, acc, tot, metainf)] ->
796798 let ps_in' = map simpl ps_in
797799 pdef = map debind ps_in' in
798− case simpleCase False True False CompileTime emptyFC pdef of
800+ case simpleCase False True False CompileTime emptyFC atys pdef of
799801 OK (CaseDef args sc _) ->
800802 addDef n (CaseOp ci
801− ty ps_in' ps (cd { cases_totcheck = (args, sc) }),
803+ ty atys ps_in' ps (cd { cases_totcheck = (args, sc) }),
802804 acc, tot, metainf) ctxt
803805 Error err -> error (show err)
804806 _ -> ctxt in
@@ -836,7 +838,7 @@ lookupTy n ctxt
836838 (Function ty _) -> return ty
837839 (TyDecl _ ty) -> return ty
838840 (Operator ty _ _) -> return ty
839− (CaseOp _ ty _ _ _) -> return ty
841+ (CaseOp _ ty _ _ _ _) -> return ty
840842
841843isConName :: Name -> Context -> Bool
842844isConName n ctxt = isTConName n ctxt || isDConName n ctxt
@@ -861,7 +863,7 @@ isFnName n ctxt
861863 case tfst def of
862864 (Function _ _) -> return True
863865 (Operator _ _ _) -> return True
864− (CaseOp _ _ _ _ _) -> return True
866+ (CaseOp _ _ _ _ _ _) -> return True
865867 _ -> return False
866868
867869lookupP :: Name -> Context -> [Term]
@@ -870,7 +872,7 @@ lookupP n ctxt
870872 p <- case def of
871873 (Function ty tm, a, _, _) -> return (P Ref n ty, a)
872874 (TyDecl nt ty, a, _, _) -> return (P nt n ty, a)
873− (CaseOp _ ty _ _ _, a, _, _) -> return (P Ref n ty, a)
875+ (CaseOp _ ty _ _ _ _, a, _, _) -> return (P Ref n ty, a)
874876 (Operator ty _ _, a, _, _) -> return (P Ref n ty, a)
875877 case snd p of
876878 Hidden -> []