@@ -35,8 +35,8 @@ checkDef fc ns = do ctxt <- getContext
3535 mapM (\(n, t) -> do (t', _) <- recheckC ctxt fc [] t
3636 return (n, t')) ns
3737
38−elabType :: ElabInfo -> SyntaxInfo -> FC -> Name -> PTerm -> Idris ()
39−elabType info syn fc n ty' = {- let ty' = piBind (params info) ty_in
38+elabType :: ElabInfo -> SyntaxInfo -> FC -> FnOpts -> Name -> PTerm -> Idris ()
39+elabType info syn fc opts n ty' = {- let ty' = piBind (params info) ty_in
4040 n = liftname info n_in in -}
4141 do checkUndefined fc n
4242 ctxt <- getContext
@@ -52,6 +52,8 @@ elabType info syn fc n ty' = {- let ty' = piBind (params info) ty_in
5252 ds <- checkDef fc ((n, nty):defer)
5353 addIBC (IBCDef n)
5454 addDeferred ds
55+ setFlags n opts
56+ addIBC (IBCFlags n opts)
5557 mapM_ (elabCaseBlock info) is
5658
5759elabData :: ElabInfo -> SyntaxInfo -> FC -> PData -> Idris ()
@@ -79,6 +81,7 @@ elabData info syn fc (PDatadecl n t_in dcons)
7981 addIBC (IBCData n)
8082 collapseCons n cons
8183 updateContext (addDatatype (Data n ttag cty cons))
84+ mapM_ (checkPositive n) cons
8285
8386elabRecord :: ElabInfo -> SyntaxInfo -> FC -> Name ->
8487 PTerm -> Name -> PTerm -> Idris ()
@@ -142,6 +145,13 @@ elabClauses info fc opts n_in cs = let n = liftname info n_in in
142145 return Total
143146 else do logLvl 2 $ show n ++ " does not cover all cases"
144147 return $ Partial NotCovering
148+ case lookupCtxt (namespace info) n (idris_flags ist) of
149+ [fs] -> if TotalFn `elem` fs
150+ then case tot of
151+ Total -> return ()
152+ t -> tclift $ tfail (At fc (Msg (show n ++ " is " ++ show t)))
153+ else return ()
154+ _ -> return ()
145155 case tree of
146156 CaseDef _ _ [] -> return ()
147157 CaseDef _ _ xs -> mapM_ (\x ->
@@ -199,8 +209,12 @@ elabClause info fc tcgen (PClause fname lhs_in [] PImpossible [])
199209 (erun fc (buildTC i info True tcgen fname (infTerm lhs))) of
200210 OK ((lhs', _, _), _) ->
201211 do let lhs_tm = orderPats (getInferTerm lhs')
202− checkInferred fc (delab' i lhs_tm True) lhs
203− fail $ show fc ++ ":" ++ showImp True (delab' i lhs_tm True) ++ " is a possible case"
212+-- checkInferred fc (delab' i lhs_tm True) lhs
213+ b <- inferredDiff fc (delab' i lhs_tm True) lhs
214+ if b
215+ then return ()
216+ else fail $ show fc ++ ":" ++ showImp True (delab' i lhs_tm True) ++
217+ " is a possible case"
204218 ++ "\n" ++ showImp True lhs
205219 Error _ -> return ()
206220 return Nothing
@@ -419,10 +433,10 @@ elabClass info syn fc constraints tn ps ds
419433 conbind (ty : ns) x = PPi constraint (MN 0 "c") ty (conbind ns x)
420434 conbind [] x = x
421435
422− tdecl (PTy syn _ n t) = do t' <- implicit syn n t
423− return ( (n, (toExp (map fst ps) Exp t')),
424− (n, (toExp (map fst ps) Imp t')),
425− (n, (syn, t) ) )
436+ tdecl (PTy syn _ _ n t) = do t' <- implicit syn n t
437+ return ( (n, (toExp (map fst ps) Exp t')),
438+ (n, (toExp (map fst ps) Imp t')),
439+ (n, (syn, t) ) )
426440 tdecl _ = fail "Not allowed in a class declaration"
427441
428442 -- Create default definitions
@@ -430,7 +444,7 @@ elabClass info syn fc constraints tn ps ds
430444 case lookup n mtys of
431445 Just (syn, ty) -> do let ty' = insertConstraint c ty
432446 let ds = map (decorateid defaultdec)
433− [PTy syn fc n ty',
447+ [PTy syn fc [] n ty',
434448 PClauses fc (TCGen:opts) n cs]
435449 iLOG (show ds)
436450 return (n, (defaultdec n, ds))
@@ -440,7 +454,7 @@ elabClass info syn fc constraints tn ps ds
440454 defaultdec (UN n) = UN ("default#" ++ n)
441455 defaultdec (NS n ns) = NS (defaultdec n) ns
442456
443− tydecl (PTy _ _ _ _) = True
457+ tydecl (PTy _ _ _ _ _) = True
444458 tydecl _ = False
445459 clause (PClauses _ _ _ _) = True
446460 clause _ = False
@@ -454,7 +468,7 @@ elabClass info syn fc constraints tn ps ds
454468 let ty = PPi constraint (MN 0 "pc") c con
455469 iLOG (showImp True ty)
456470 iLOG (showImp True lhs ++ " = " ++ showImp True rhs)
457− return [PTy syn fc cfn ty,
471+ return [PTy syn fc [] cfn ty,
458472 PClauses fc [Inlinable,TCGen] cfn [PClause cfn lhs [] rhs []]]
459473
460474 tfun cn c syn all (m, ty)
@@ -468,7 +482,7 @@ elabClass info syn fc constraints tn ps ds
468482 iLOG (showImp True ty)
469483 iLOG (show (m, ty', capp, margs))
470484 iLOG (showImp True lhs ++ " = " ++ showImp True rhs)
471− return [PTy syn fc m ty',
485+ return [PTy syn fc [] m ty',
472486 PClauses fc [Inlinable,TCGen] m [PClause m lhs [] rhs []]]
473487
474488 getMArgs (PPi (Imp _ _) n ty sc) = IA : getMArgs sc
@@ -509,7 +523,7 @@ elabInstance info syn fc cs n ps t ds
509523 [c] -> return c
510524 _ -> fail $ show n ++ " is not a type class"
511525 let iname = UN ('@':show n ++ "$" ++ show ps)
512− elabType info syn fc iname t
526+ elabType info syn fc [] iname t
513527 let ips = zip (class_params ci) ps
514528 let ns = case n of
515529 NS n ns' -> ns'
@@ -549,7 +563,7 @@ elabInstance info syn fc cs n ps t ds
549563 decorate ns (UN n) = NS (UN ('!':n)) ns
550564 decorate ns (NS (UN n) s) = NS (UN ('!':n)) ns
551565
552− mkTyDecl (n, t, _) = PTy syn fc n t
566+ mkTyDecl (n, t, _) = PTy syn fc [] n t
553567
554568 conbind (ty : ns) x = PPi constraint (MN 0 "c") ty (conbind ns x)
555569 conbind [] x = x
@@ -577,7 +591,7 @@ elabInstance info syn fc cs n ps t ds
577591 clauseFor m ns (PClauses _ _ m' _) = decorate ns m == decorate ns m'
578592 clauseFor m ns _ = False
579593
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
581595decorateid decorate (PClauses f o n cs)
582596 = PClauses f o (decorate n) (map dc cs)
583597 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)
612626
613627elabDecl' info (PFix _ _ _) = return () -- nothing to elaborate
614628elabDecl' info (PSyntax _ p) = return () -- nothing to elaborate
615−elabDecl' info (PTy s f n ty) = do iLOG $ "Elaborating type decl " ++ show n
616− elabType info s f n ty
629+elabDecl' info (PTy s f o n ty) = do iLOG $ "Elaborating type decl " ++ show n
630+ elabType info s f o n ty
617631elabDecl' info (PData s f d) = do iLOG $ "Elaborating " ++ show (d_name d)
618632 elabData info s f d
619633elabDecl' info d@(PClauses f o n ps) = do iLOG $ "Elaborating clause " ++ show n
@@ -667,3 +681,14 @@ checkInferred fc inf user =
667681 ++ show x ++ " and " ++ show y)
668682-- ++ "\n" ++ showImp True inf ++ "\n" ++ showImp True user)
669683
684+-- Return whether inferred term is different from given term
685+-- (as above, but return a Bool)
686+
687+inferredDiff :: FC -> PTerm -> PTerm -> Idris Bool
688+inferredDiff fc inf user =
689+ do logLvl 6 $ "Checked to\n" ++ showImp True inf ++ "\n" ++
690+ showImp True user
691+ tclift $ case matchClause' True user inf of
692+ Right vs -> return False
693+ Left (x, y) -> return True
694+