@@ -57,7 +57,7 @@ data ElabInfo = EInfo { params :: [(Name, PTerm)],
57 liftname :: Name -> Name,
57 liftname :: Name -> Name,
58 namespace :: Maybe [String],
58 namespace :: Maybe [String],
59 elabFC :: Maybe FC,
59 elabFC :: Maybe FC,
60− rec_elabDecl :: ElabWhat -> ElabInfo -> PDecl ->
60+ rec_elabDecl :: ElabWhat -> ElabInfo -> PDecl ->
61 Idris () }
61 Idris () }
63toplevel :: ElabInfo
63toplevel :: ElabInfo
@@ -601,14 +601,18 @@ data PDecl' t
601 [PDecl' t] -- declarations
601 [PDecl' t] -- declarations
602 -- ^ Type class: arguments are documentation, syntax info, source location, constraints,
602 -- ^ Type class: arguments are documentation, syntax info, source location, constraints,
603 -- class name, parameters, method declarations
603 -- class name, parameters, method declarations
605+ (Docstring (Either Err PTerm))
604− | PInstance SyntaxInfo FC [(Name, t)] -- constraints
607+ FC [(Name, t)] -- constraints
605− Name -- class
608+ Name -- class
606− [t] -- parameters
609+ [t] -- parameters
607− t -- full instance type
610+ t -- full instance type
608− (Maybe Name) -- explicit name
611+ (Maybe Name) -- explicit name
609− [PDecl' t]
612+ [PDecl' t]
610− -- ^ Instance declaration: arguments are syntax info, source location, constraints,
613+ -- ^ Instance declaration: documentation, arguments are syntax info, source
614+ -- location, constraints, class name, parameters, full instance
611− -- class name, parameters, full instance type, optional explicit name, and definitions
615+ -- type, optional explicit name, and definitions
612 | PDSL Name (DSL' t) -- ^ DSL declaration
616 | PDSL Name (DSL' t) -- ^ DSL declaration
613 | PSyntax FC Syntax -- ^ Syntax definition
617 | PSyntax FC Syntax -- ^ Syntax definition
614 | PMutual FC [PDecl' t] -- ^ Mutual block
618 | PMutual FC [PDecl' t] -- ^ Mutual block
@@ -688,7 +692,7 @@ declared (PParams _ _ ds) = concatMap declared ds
688declared (PNamespace _ ds) = concatMap declared ds
692declared (PNamespace _ ds) = concatMap declared ds
689declared (PRecord _ _ _ n _ _ _ c _) = [n, c]
693declared (PRecord _ _ _ n _ _ _ c _) = [n, c]
690declared (PClass _ _ _ _ n _ _ ms) = n : concatMap declared ms
694declared (PClass _ _ _ _ n _ _ ms) = n : concatMap declared ms
691−declared (PInstance _ _ _ _ _ _ _ _) = []
695+declared (PInstance _ _ _ _ _ _ _ _ _) = []
692declared (PDSL n _) = [n]
696declared (PDSL n _) = [n]
693declared (PSyntax _ _) = []
697declared (PSyntax _ _) = []
694declared (PMutual _ ds) = concatMap declared ds
698declared (PMutual _ ds) = concatMap declared ds
@@ -707,7 +711,7 @@ tldeclared (PParams _ _ ds) = []
707tldeclared (PMutual _ ds) = concatMap tldeclared ds
711tldeclared (PMutual _ ds) = concatMap tldeclared ds
708tldeclared (PNamespace _ ds) = concatMap tldeclared ds
712tldeclared (PNamespace _ ds) = concatMap tldeclared ds
709tldeclared (PClass _ _ _ _ n _ _ ms) = concatMap tldeclared ms
713tldeclared (PClass _ _ _ _ n _ _ ms) = concatMap tldeclared ms
710−tldeclared (PInstance _ _ _ _ _ _ _ _) = []
714+tldeclared (PInstance _ _ _ _ _ _ _ _ _) = []
711tldeclared _ = []
715tldeclared _ = []
713defined :: PDecl -> [Name]
717defined :: PDecl -> [Name]
@@ -723,7 +727,7 @@ defined (PParams _ _ ds) = concatMap defined ds
723defined (PNamespace _ ds) = concatMap defined ds
727defined (PNamespace _ ds) = concatMap defined ds
724defined (PRecord _ _ _ n _ _ _ c _) = [n, c]
728defined (PRecord _ _ _ n _ _ _ c _) = [n, c]
725defined (PClass _ _ _ _ n _ _ ms) = n : concatMap defined ms
729defined (PClass _ _ _ _ n _ _ ms) = n : concatMap defined ms
726−defined (PInstance _ _ _ _ _ _ _ _) = []
730+defined (PInstance _ _ _ _ _ _ _ _ _) = []
727defined (PDSL n _) = [n]
731defined (PDSL n _) = [n]
728defined (PSyntax _ _) = []
732defined (PSyntax _ _) = []
729defined (PMutual _ ds) = concatMap defined ds
733defined (PMutual _ ds) = concatMap defined ds
@@ -778,7 +782,7 @@ data PTerm = PQuote Raw -- ^ Inclusion of a core term into the high-level langua
778 | PAlternative Bool [PTerm] -- ^ True if only one may work. (| A, B, C|)
782 | PAlternative Bool [PTerm] -- ^ True if only one may work. (| A, B, C|)
779 | PHidden PTerm -- ^ Irrelevant or hidden pattern
783 | PHidden PTerm -- ^ Irrelevant or hidden pattern
780 | PType -- ^ 'Type' type
784 | PType -- ^ 'Type' type
781− | PUniverse Universe -- ^ Some universe
785+ | PUniverse Universe -- ^ Some universe
782 | PGoal FC PTerm Name PTerm -- ^ quoteGoal, used for %reflection functions
786 | PGoal FC PTerm Name PTerm -- ^ quoteGoal, used for %reflection functions
783 | PConstant Const -- ^ Builtin types
787 | PConstant Const -- ^ Builtin types
784 | Placeholder -- ^ Underscore
788 | Placeholder -- ^ Underscore
@@ -1113,7 +1117,7 @@ data SSymbol = Keyword Name
1113 | Expr Name
1117 | Expr Name
1114 | SimpleExpr Name
1118 | SimpleExpr Name
1115 deriving (Show, Eq)
1119 deriving (Show, Eq)
1119deriving instance Binary SSymbol
1123deriving instance Binary SSymbol
@@ -1388,7 +1392,7 @@ pprintPTerm ppo bnd docArgs infixes = prettySe startPrec bnd
1389 startPrec = 0
1393 startPrec = 0
1390 funcAppPrec = 10
1394 funcAppPrec = 10
1392 prettySe :: Int -> [(Name, Bool)] -> PTerm -> Doc OutputAnnotation
1396 prettySe :: Int -> [(Name, Bool)] -> PTerm -> Doc OutputAnnotation
1393 prettySe p bnd (PQuote r) =
1397 prettySe p bnd (PQuote r) =
1394 text "![" <> pretty r <> text "]"
1398 text "![" <> pretty r <> text "]"
@@ -1451,7 +1455,7 @@ pprintPTerm ppo bnd docArgs infixes = prettySe startPrec bnd
1451 [x] -> group (opName True <$> group (prettySe startPrec bnd (getTm x)))
1455 [x] -> group (opName True <$> group (prettySe startPrec bnd (getTm x)))
1452 [l,r] -> let precedence = maybe (startPrec - 1) prec f
1456 [l,r] -> let precedence = maybe (startPrec - 1) prec f
1453 in bracket p precedence $ inFix (getTm l) (getTm r)
1457 in bracket p precedence $ inFix (getTm l) (getTm r)
1454− (l@(PExp _ _ _ _) : r@(PExp _ _ _ _) : rest) ->
1458+ (l@(PExp _ _ _ _) : r@(PExp _ _ _ _) : rest) ->
1455 bracket p funcAppPrec $
1459 bracket p funcAppPrec $
1456 enclose lparen rparen (inFix (getTm l) (getTm r)) <+>
1460 enclose lparen rparen (inFix (getTm l) (getTm r)) <+>
1457 align (group (vsep (map (prettyArgS bnd) rest)))
1461 align (group (vsep (map (prettyArgS bnd) rest)))
@@ -1467,7 +1471,7 @@ pprintPTerm ppo bnd docArgs infixes = prettySe startPrec bnd
1467 Just (Infixr p') -> p'
1471 Just (Infixr p') -> p'
1468 Just f' -> prec f' + 1
1472 Just f' -> prec f' + 1
1469 inFix l r = align . group $
1473 inFix l r = align . group $
1470− (prettySe left bnd l <+> opName False) <$>
1474+ (prettySe left bnd l <+> opName False) <$>
1471 group (prettySe right bnd r)
1475 group (prettySe right bnd r)
1472 prettySe p bnd (PApp _ hd@(PRef fc f) [tm]) -- symbols, like 'foo
1476 prettySe p bnd (PApp _ hd@(PRef fc f) [tm]) -- symbols, like 'foo
1473 | PConstant (Idris.Core.TT.Str str) <- getTm tm,
1477 | PConstant (Idris.Core.TT.Str str) <- getTm tm,
@@ -1486,7 +1490,7 @@ pprintPTerm ppo bnd docArgs infixes = prettySe startPrec bnd
1486 align $ kwd "case" <+> prettySe startPrec bnd scr <+> kwd "of" <$>
1490 align $ kwd "case" <+> prettySe startPrec bnd scr <+> kwd "of" <$>
1487 indent 2 (vsep (map ppcase cases))
1491 indent 2 (vsep (map ppcase cases))
1489− ppcase (l, r) = let prettyCase = prettySe startPrec
1493+ ppcase (l, r) = let prettyCase = prettySe startPrec
1490 ([(n, False) | n <- vars l] ++ bnd)
1494 ([(n, False) | n <- vars l] ++ bnd)
1491 in nest nestingSize $
1495 in nest nestingSize $
1492 prettyCase l <+> text "=>" <+> prettyCase r
1496 prettyCase l <+> text "=>" <+> prettyCase r
@@ -1557,7 +1561,7 @@ pprintPTerm ppo bnd docArgs infixes = prettySe startPrec bnd
1557 prettyAs =
1561 prettyAs =
1558 foldr (\l -> \r -> l <+> text "," <+> r) empty $ map (prettySe startPrec bnd) as
1562 foldr (\l -> \r -> l <+> text "," <+> r) empty $ map (prettySe startPrec bnd) as
1559 prettySe p bnd PType = annotate (AnnType "Type" "The type of types") $ text "Type"
1563 prettySe p bnd PType = annotate (AnnType "Type" "The type of types") $ text "Type"
1560− prettySe p bnd (PUniverse u) = annotate (AnnType (show u) "The type of unique types") $ text (show u)
1564+ prettySe p bnd (PUniverse u) = annotate (AnnType (show u) "The type of unique types") $ text (show u)
1561 prettySe p bnd (PConstant c) = annotate (AnnConst c) (text (show c))
1565 prettySe p bnd (PConstant c) = annotate (AnnConst c) (text (show c))
1562 -- XXX: add pretty for tactics
1566 -- XXX: add pretty for tactics
1563 prettySe p bnd (PProof ts) =
1567 prettySe p bnd (PProof ts) =
@@ -1729,7 +1733,7 @@ showDeclImp o (PNamespace n ps) = text "namespace" <+> text n <> braces (line <>
1729showDeclImp _ (PSyntax _ syn) = text "syntax" <+> text (show syn)
1733showDeclImp _ (PSyntax _ syn) = text "syntax" <+> text (show syn)
1730showDeclImp o (PClass _ _ _ cs n ps _ ds)
1734showDeclImp o (PClass _ _ _ cs n ps _ ds)
1731 = text "class" <+> text (show cs) <+> text (show n) <+> text (show ps) <> line <> showDecls o ds
1735 = text "class" <+> text (show cs) <+> text (show n) <+> text (show ps) <> line <> showDecls o ds
1732−showDeclImp o (PInstance _ _ cs n _ t _ ds)
1736+showDeclImp o (PInstance _ _ _ cs n _ t _ ds)
1733 = text "instance" <+> text (show cs) <+> text (show n) <+> prettyImp o t <> line <> showDecls o ds
1737 = text "instance" <+> text (show cs) <+> text (show n) <+> prettyImp o t <> line <> showDecls o ds
1734showDeclImp _ _ = text "..."
1738showDeclImp _ _ = text "..."
1735-- showDeclImp (PImport o) = "import " ++ o
1739-- showDeclImp (PImport o) = "import " ++ o
@@ -1905,16 +1909,16 @@ implicitNamesIn :: [Name] -> IState -> PTerm -> [Name]
1905implicitNamesIn uvars ist tm = nub $ ni [] tm
1909implicitNamesIn uvars ist tm = nub $ ni [] tm
1907 ni env (PRef _ n)
1911 ni env (PRef _ n)
1908− | not (n `elem` env)
1912+ | not (n `elem` env)
1909 = case lookupTy n (tt_ctxt ist) of
1913 = case lookupTy n (tt_ctxt ist) of
1910 [] -> [n]
1914 [] -> [n]
1911 _ -> if n `elem` uvars then [n] else []
1915 _ -> if n `elem` uvars then [n] else []
1912− ni env (PApp _ f@(PRef _ n) as)
1916+ ni env (PApp _ f@(PRef _ n) as)
1913 | n `elem` uvars = ni env f ++ concatMap (ni env) (map getTm as)
1917 | n `elem` uvars = ni env f ++ concatMap (ni env) (map getTm as)
1914 | otherwise = concatMap (ni env) (map getTm as)
1918 | otherwise = concatMap (ni env) (map getTm as)
1915 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1919 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1916 ni env (PAppBind _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1920 ni env (PAppBind _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1917− ni env (PCase _ c os) = ni env c ++
1921+ ni env (PCase _ c os) = ni env c ++
1918 -- names in 'os', not counting the names bound in the cases
1922 -- names in 'os', not counting the names bound in the cases
1919 (nub (concatMap (ni env) (map snd os))
1923 (nub (concatMap (ni env) (map snd os))
1920 \\ nub (concatMap (ni env) (map fst os)))
1924 \\ nub (concatMap (ni env) (map fst os)))
@@ -1944,7 +1948,7 @@ namesIn uvars ist tm = nub $ ni [] tm
1944 _ -> if n `elem` (map fst uvars) then [n] else []
1948 _ -> if n `elem` (map fst uvars) then [n] else []
1945 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1949 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1946 ni env (PAppBind _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1950 ni env (PAppBind _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1947− ni env (PCase _ c os) = ni env c ++
1951+ ni env (PCase _ c os) = ni env c ++
1948 -- names in 'os', not counting the names bound in the cases
1952 -- names in 'os', not counting the names bound in the cases
1949 (nub (concatMap (ni env) (map snd os))
1953 (nub (concatMap (ni env) (map snd os))
1950 \\ nub (concatMap (ni env) (map fst os)))
1954 \\ nub (concatMap (ni env) (map fst os)))
@@ -2003,4 +2007,3 @@ getErasureInfo ist n =
2003 case lookupCtxtExact n (idris_optimisation ist) of
2007 case lookupCtxtExact n (idris_optimisation ist) of
2004 Just (Optimise inacc detagg) -> map fst inacc
2008 Just (Optimise inacc detagg) -> map fst inacc
2005 Nothing -> []
2009 Nothing -> []