@@ -35,8 +35,8 @@ checkDef fc ns = do ctxt <- getContext
35 mapM (\(n, t) -> do (t', _) <- recheckC ctxt fc [] t
35 mapM (\(n, t) -> do (t', _) <- recheckC ctxt fc [] t
36 return (n, t')) ns
36 return (n, t')) ns
38−elabType :: ElabInfo -> SyntaxInfo -> FC -> Name -> PTerm -> Idris ()
38+elabType :: ElabInfo -> SyntaxInfo -> FC -> FnOpts -> Name -> PTerm -> Idris ()
39−elabType info syn fc n ty' = {- let ty' = piBind (params info) ty_in
39+elabType info syn fc opts n ty' = {- let ty' = piBind (params info) ty_in
40 n = liftname info n_in in -}
40 n = liftname info n_in in -}
41 do checkUndefined fc n
41 do checkUndefined fc n
42 ctxt <- getContext
42 ctxt <- getContext
@@ -52,6 +52,8 @@ elabType info syn fc n ty' = {- let ty' = piBind (params info) ty_in
52 ds <- checkDef fc ((n, nty):defer)
52 ds <- checkDef fc ((n, nty):defer)
53 addIBC (IBCDef n)
53 addIBC (IBCDef n)
54 addDeferred ds
54 addDeferred ds
56+ addIBC (IBCFlags n opts)
55 mapM_ (elabCaseBlock info) is
57 mapM_ (elabCaseBlock info) is
57elabData :: ElabInfo -> SyntaxInfo -> FC -> PData -> Idris ()
59elabData :: ElabInfo -> SyntaxInfo -> FC -> PData -> Idris ()
@@ -79,6 +81,7 @@ elabData info syn fc (PDatadecl n t_in dcons)
79 addIBC (IBCData n)
81 addIBC (IBCData n)
80 collapseCons n cons
82 collapseCons n cons
81 updateContext (addDatatype (Data n ttag cty cons))
83 updateContext (addDatatype (Data n ttag cty cons))
84+ mapM_ (checkPositive n) cons
83elabRecord :: ElabInfo -> SyntaxInfo -> FC -> Name ->
86elabRecord :: ElabInfo -> SyntaxInfo -> FC -> Name ->
84 PTerm -> Name -> PTerm -> Idris ()
87 PTerm -> Name -> PTerm -> Idris ()
@@ -142,6 +145,13 @@ elabClauses info fc opts n_in cs = let n = liftname info n_in in
142 return Total
145 return Total
143 else do logLvl 2 $ show n ++ " does not cover all cases"
146 else do logLvl 2 $ show n ++ " does not cover all cases"
144 return $ Partial NotCovering
147 return $ Partial NotCovering
148+ case lookupCtxt (namespace info) n (idris_flags ist) of
149+ [fs] -> if TotalFn `elem` fs
152+ t -> tclift $ tfail (At fc (Msg (show n ++ " is " ++ show t)))
145 case tree of
155 case tree of
146 CaseDef _ _ [] -> return ()
156 CaseDef _ _ [] -> return ()
147 CaseDef _ _ xs -> mapM_ (\x ->
157 CaseDef _ _ xs -> mapM_ (\x ->
@@ -199,8 +209,12 @@ elabClause info fc tcgen (PClause fname lhs_in [] PImpossible [])
199 (erun fc (buildTC i info True tcgen fname (infTerm lhs))) of
209 (erun fc (buildTC i info True tcgen fname (infTerm lhs))) of
200 OK ((lhs', _, _), _) ->
210 OK ((lhs', _, _), _) ->
201 do let lhs_tm = orderPats (getInferTerm lhs')
211 do let lhs_tm = orderPats (getInferTerm lhs')
202− checkInferred fc (delab' i lhs_tm True) lhs
212+-- checkInferred fc (delab' i lhs_tm True) lhs
213+ b <- inferredDiff fc (delab' i lhs_tm True) lhs
203− fail $ show fc ++ ":" ++ showImp True (delab' i lhs_tm True) ++ " is a possible case"
216+ else fail $ show fc ++ ":" ++ showImp True (delab' i lhs_tm True) ++
217+ " is a possible case"
204 ++ "\n" ++ showImp True lhs
218 ++ "\n" ++ showImp True lhs
205 Error _ -> return ()
219 Error _ -> return ()
206 return Nothing
220 return Nothing
@@ -419,10 +433,10 @@ elabClass info syn fc constraints tn ps ds
419 conbind (ty : ns) x = PPi constraint (MN 0 "c") ty (conbind ns x)
433 conbind (ty : ns) x = PPi constraint (MN 0 "c") ty (conbind ns x)
420 conbind [] x = x
434 conbind [] x = x
422− tdecl (PTy syn _ n t) = do t' <- implicit syn n t
436+ tdecl (PTy syn _ _ n t) = do t' <- implicit syn n t
423− return ( (n, (toExp (map fst ps) Exp t')),
437+ return ( (n, (toExp (map fst ps) Exp t')),
424− (n, (toExp (map fst ps) Imp t')),
438+ (n, (toExp (map fst ps) Imp t')),
425− (n, (syn, t) ) )
439+ (n, (syn, t) ) )
426 tdecl _ = fail "Not allowed in a class declaration"
440 tdecl _ = fail "Not allowed in a class declaration"
428 -- Create default definitions
442 -- Create default definitions
@@ -430,7 +444,7 @@ elabClass info syn fc constraints tn ps ds
430 case lookup n mtys of
444 case lookup n mtys of
431 Just (syn, ty) -> do let ty' = insertConstraint c ty
445 Just (syn, ty) -> do let ty' = insertConstraint c ty
432 let ds = map (decorateid defaultdec)
446 let ds = map (decorateid defaultdec)
433− [PTy syn fc n ty',
447+ [PTy syn fc [] n ty',
434 PClauses fc (TCGen:opts) n cs]
448 PClauses fc (TCGen:opts) n cs]
435 iLOG (show ds)
449 iLOG (show ds)
436 return (n, (defaultdec n, ds))
450 return (n, (defaultdec n, ds))
@@ -440,7 +454,7 @@ elabClass info syn fc constraints tn ps ds
440 defaultdec (UN n) = UN ("default#" ++ n)
454 defaultdec (UN n) = UN ("default#" ++ n)
441 defaultdec (NS n ns) = NS (defaultdec n) ns
455 defaultdec (NS n ns) = NS (defaultdec n) ns
443− tydecl (PTy _ _ _ _) = True
457+ tydecl (PTy _ _ _ _ _) = True
444 tydecl _ = False
458 tydecl _ = False
445 clause (PClauses _ _ _ _) = True
459 clause (PClauses _ _ _ _) = True
446 clause _ = False
460 clause _ = False
@@ -454,7 +468,7 @@ elabClass info syn fc constraints tn ps ds
454 let ty = PPi constraint (MN 0 "pc") c con
468 let ty = PPi constraint (MN 0 "pc") c con
455 iLOG (showImp True ty)
469 iLOG (showImp True ty)
456 iLOG (showImp True lhs ++ " = " ++ showImp True rhs)
470 iLOG (showImp True lhs ++ " = " ++ showImp True rhs)
457− return [PTy syn fc cfn ty,
471+ return [PTy syn fc [] cfn ty,
458 PClauses fc [Inlinable,TCGen] cfn [PClause cfn lhs [] rhs []]]
472 PClauses fc [Inlinable,TCGen] cfn [PClause cfn lhs [] rhs []]]
460 tfun cn c syn all (m, ty)
474 tfun cn c syn all (m, ty)
@@ -468,7 +482,7 @@ elabClass info syn fc constraints tn ps ds
468 iLOG (showImp True ty)
482 iLOG (showImp True ty)
469 iLOG (show (m, ty', capp, margs))
483 iLOG (show (m, ty', capp, margs))
470 iLOG (showImp True lhs ++ " = " ++ showImp True rhs)
484 iLOG (showImp True lhs ++ " = " ++ showImp True rhs)
471− return [PTy syn fc m ty',
485+ return [PTy syn fc [] m ty',
472 PClauses fc [Inlinable,TCGen] m [PClause m lhs [] rhs []]]
486 PClauses fc [Inlinable,TCGen] m [PClause m lhs [] rhs []]]
474 getMArgs (PPi (Imp _ _) n ty sc) = IA : getMArgs sc
488 getMArgs (PPi (Imp _ _) n ty sc) = IA : getMArgs sc
@@ -509,7 +523,7 @@ elabInstance info syn fc cs n ps t ds
509 [c] -> return c
523 [c] -> return c
510 _ -> fail $ show n ++ " is not a type class"
524 _ -> fail $ show n ++ " is not a type class"
511 let iname = UN ('@':show n ++ "$" ++ show ps)
525 let iname = UN ('@':show n ++ "$" ++ show ps)
512− elabType info syn fc iname t
526+ elabType info syn fc [] iname t
513 let ips = zip (class_params ci) ps
527 let ips = zip (class_params ci) ps
514 let ns = case n of
528 let ns = case n of
515 NS n ns' -> ns'
529 NS n ns' -> ns'
@@ -549,7 +563,7 @@ elabInstance info syn fc cs n ps t ds
549 decorate ns (UN n) = NS (UN ('!':n)) ns
563 decorate ns (UN n) = NS (UN ('!':n)) ns
550 decorate ns (NS (UN n) s) = NS (UN ('!':n)) ns
564 decorate ns (NS (UN n) s) = NS (UN ('!':n)) ns
552− mkTyDecl (n, t, _) = PTy syn fc n t
566+ mkTyDecl (n, t, _) = PTy syn fc [] n t
554 conbind (ty : ns) x = PPi constraint (MN 0 "c") ty (conbind ns x)
568 conbind (ty : ns) x = PPi constraint (MN 0 "c") ty (conbind ns x)
555 conbind [] x = x
569 conbind [] x = x
@@ -577,7 +591,7 @@ elabInstance info syn fc cs n ps t ds
577 clauseFor m ns (PClauses _ _ m' _) = decorate ns m == decorate ns m'
591 clauseFor m ns (PClauses _ _ m' _) = decorate ns m == decorate ns m'
578 clauseFor m ns _ = False
592 clauseFor m ns _ = False
580−decorateid decorate (PTy s f n t) = PTy s f (decorate n) t
594+decorateid decorate (PTy s f o n t) = PTy s f o (decorate n) t
581decorateid decorate (PClauses f o n cs)
595decorateid decorate (PClauses f o n cs)
582 = PClauses f o (decorate n) (map dc cs)
596 = PClauses f o (decorate n) (map dc cs)
583 where dc (PClause n t as w ds) = PClause (decorate n) (dappname t) as w ds
597 where dc (PClause n t as w ds) = PClause (decorate n) (dappname t) as w ds
@@ -612,8 +626,8 @@ elabDecl info d = idrisCatch (elabDecl' info d)
613elabDecl' info (PFix _ _ _) = return () -- nothing to elaborate
627elabDecl' info (PFix _ _ _) = return () -- nothing to elaborate
614elabDecl' info (PSyntax _ p) = return () -- nothing to elaborate
628elabDecl' info (PSyntax _ p) = return () -- nothing to elaborate
615−elabDecl' info (PTy s f n ty) = do iLOG $ "Elaborating type decl " ++ show n
629+elabDecl' info (PTy s f o n ty) = do iLOG $ "Elaborating type decl " ++ show n
616− elabType info s f n ty
630+ elabType info s f o n ty
617elabDecl' info (PData s f d) = do iLOG $ "Elaborating " ++ show (d_name d)
631elabDecl' info (PData s f d) = do iLOG $ "Elaborating " ++ show (d_name d)
618 elabData info s f d
632 elabData info s f d
619elabDecl' info d@(PClauses f o n ps) = do iLOG $ "Elaborating clause " ++ show n
633elabDecl' info d@(PClauses f o n ps) = do iLOG $ "Elaborating clause " ++ show n
@@ -667,3 +681,14 @@ checkInferred fc inf user =
667 ++ show x ++ " and " ++ show y)
681 ++ show x ++ " and " ++ show y)
668-- ++ "\n" ++ showImp True inf ++ "\n" ++ showImp True user)
682-- ++ "\n" ++ showImp True inf ++ "\n" ++ showImp True user)
684+-- Return whether inferred term is different from given term
685+-- (as above, but return a Bool)
687+inferredDiff :: FC -> PTerm -> PTerm -> Idris Bool
688+inferredDiff fc inf user =
689+ do logLvl 6 $ "Checked to\n" ++ showImp True inf ++ "\n" ++
691+ tclift $ case matchClause' True user inf of
692+ Right vs -> return False
693+ Left (x, y) -> return True