@@ -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
@@ -225,7 +225,8 @@ data IState = IState {
225 idris_callswho :: Maybe (M.Map Name [Name]),
225 idris_callswho :: Maybe (M.Map Name [Name]),
226 idris_repl_defs :: [Name], -- ^ List of names that were defined in the repl, and can be re-/un-defined
226 idris_repl_defs :: [Name], -- ^ List of names that were defined in the repl, and can be re-/un-defined
227 elab_stack :: [Name], -- ^ Stack of names currently being elaborated
227 elab_stack :: [Name], -- ^ Stack of names currently being elaborated
228− idris_symbols :: M.Map Name Name -- ^ Symbol table (preserves sharing of names)
228+ idris_symbols :: M.Map Name Name, -- ^ Symbol table (preserves sharing of names)
229+ idris_exports :: [Name] -- ^ Functions with ExportList
231-- Required for parsers library, and therefore trifecta
232-- Required for parsers library, and therefore trifecta
@@ -297,6 +298,7 @@ data IBCWrite = IBCFix FixDecl
297 | IBCParsedRegion FC
298 | IBCParsedRegion FC
298 | IBCModDocs Name -- ^ The name is the special name used to track module docs
299 | IBCModDocs Name -- ^ The name is the special name used to track module docs
299 | IBCUsage (Name, Int)
300 | IBCUsage (Name, Int)
300 deriving Show
302 deriving Show
302-- | The initial state for the compiler
304-- | The initial state for the compiler
@@ -309,7 +311,7 @@ idrisInit = IState initContext [] []
309 [] [] [] defaultOpts 6 [] [] [] [] emptySyntaxRules [] [] [] [] [] [] []
311 [] [] [] defaultOpts 6 [] [] [] [] emptySyntaxRules [] [] [] [] [] [] []
310 [] [] Nothing [] Nothing [] [] Nothing Nothing [] Hidden False [] Nothing [] []
312 [] [] Nothing [] Nothing [] [] Nothing Nothing [] Hidden False [] Nothing [] []
311 (RawOutput stdout) True defaultTheme [] (0, emptyContext) emptyContext M.empty
313 (RawOutput stdout) True defaultTheme [] (0, emptyContext) emptyContext M.empty
312− AutomaticWidth S.empty [] Nothing Nothing [] [] M.empty
314+ AutomaticWidth S.empty [] Nothing Nothing [] [] M.empty []
314-- | The monad for the main REPL - reading and processing files and updating
316-- | The monad for the main REPL - reading and processing files and updating
315-- global state (hence the IO inner monad).
317-- global state (hence the IO inner monad).
@@ -336,6 +338,8 @@ data Codegen = Via String
336deriving instance NFData Codegen
338deriving instance NFData Codegen
341+data HowMuchDocs = FullDocs | OverviewDocs
339-- | REPL commands
343-- | REPL commands
340data Command = Quit
344data Command = Quit
@@ -343,7 +347,7 @@ data Command = Quit
343 | NewDefn [PDecl] -- ^ Each 'PDecl' should be either a type declaration (at most one) or a clause defining the same name.
347 | NewDefn [PDecl] -- ^ Each 'PDecl' should be either a type declaration (at most one) or a clause defining the same name.
344 | Undefine [Name]
348 | Undefine [Name]
345 | Check PTerm
349 | Check PTerm
346− | DocStr (Either Name Const)
350+ | DocStr (Either Name Const) HowMuchDocs
347 | TotCheck Name
351 | TotCheck Name
349 | Load FilePath (Maybe Int) -- up to maximum line number
353 | Load FilePath (Maybe Int) -- up to maximum line number
@@ -417,6 +421,7 @@ data Opt = Filename String
418 | OLogging Int
422 | OLogging Int
419 | Output String
423 | Output String
420 | TypeCase
425 | TypeCase
421 | TypeInType
426 | TypeInType
422 | DefaultTotal
427 | DefaultTotal
@@ -596,19 +601,24 @@ data PDecl' t
596 [PDecl' t] -- declarations
601 [PDecl' t] -- declarations
597 -- ^ Type class: arguments are documentation, syntax info, source location, constraints,
602 -- ^ Type class: arguments are documentation, syntax info, source location, constraints,
598 -- class name, parameters, method declarations
603 -- class name, parameters, method declarations
605+ (Docstring (Either Err PTerm)) -- Instance docs
606+ [(Name, Docstring (Either Err PTerm))] -- Parameter docs
599− | PInstance SyntaxInfo FC [(Name, t)] -- constraints
608+ FC [(Name, t)] -- constraints
600− Name -- class
609+ Name -- class
601− [t] -- parameters
610+ [t] -- parameters
602− t -- full instance type
611+ t -- full instance type
603− (Maybe Name) -- explicit name
612+ (Maybe Name) -- explicit name
604− [PDecl' t]
613+ [PDecl' t]
605− -- ^ Instance declaration: arguments are syntax info, source location, constraints,
614+ -- ^ Instance declaration: arguments are documentation, syntax info, source
615+ -- location, constraints, class name, parameters, full instance
606− -- class name, parameters, full instance type, optional explicit name, and definitions
616+ -- type, optional explicit name, and definitions
607 | PDSL Name (DSL' t) -- ^ DSL declaration
617 | PDSL Name (DSL' t) -- ^ DSL declaration
608 | PSyntax FC Syntax -- ^ Syntax definition
618 | PSyntax FC Syntax -- ^ Syntax definition
609 | PMutual FC [PDecl' t] -- ^ Mutual block
619 | PMutual FC [PDecl' t] -- ^ Mutual block
610 | PDirective (Idris ()) -- ^ Compiler directive. The parser inserts the corresponding action in the Idris monad.
620 | PDirective (Idris ()) -- ^ Compiler directive. The parser inserts the corresponding action in the Idris monad.
611− | PProvider SyntaxInfo FC (ProvideWhat' t) Name -- ^ Type provider. The first t is the type, the second is the term
621+ | PProvider (Docstring (Either Err PTerm)) SyntaxInfo FC (ProvideWhat' t) Name -- ^ Type provider. The first t is the type, the second is the term
612 | PTransform FC Bool t t -- ^ Source-to-source transformation rule. If
622 | PTransform FC Bool t t -- ^ Source-to-source transformation rule. If
613 -- bool is True, lhs and rhs must be convertible
623 -- bool is True, lhs and rhs must be convertible
614 deriving Functor
624 deriving Functor
@@ -683,7 +693,7 @@ declared (PParams _ _ ds) = concatMap declared ds
683declared (PNamespace _ ds) = concatMap declared ds
693declared (PNamespace _ ds) = concatMap declared ds
684declared (PRecord _ _ _ n _ _ _ (Just c) _ _) = [n, c]
694declared (PRecord _ _ _ n _ _ _ (Just c) _ _) = [n, c]
685declared (PClass _ _ _ _ n _ _ ms) = n : concatMap declared ms
695declared (PClass _ _ _ _ n _ _ ms) = n : concatMap declared ms
686−declared (PInstance _ _ _ _ _ _ _ _) = []
696+declared (PInstance _ _ _ _ _ _ _ _ _ _) = []
687declared (PDSL n _) = [n]
697declared (PDSL n _) = [n]
688declared (PSyntax _ _) = []
698declared (PSyntax _ _) = []
689declared (PMutual _ ds) = concatMap declared ds
699declared (PMutual _ ds) = concatMap declared ds
@@ -703,7 +713,7 @@ tldeclared (PParams _ _ ds) = []
703tldeclared (PMutual _ ds) = concatMap tldeclared ds
713tldeclared (PMutual _ ds) = concatMap tldeclared ds
704tldeclared (PNamespace _ ds) = concatMap tldeclared ds
714tldeclared (PNamespace _ ds) = concatMap tldeclared ds
705tldeclared (PClass _ _ _ _ n _ _ ms) = concatMap tldeclared ms
715tldeclared (PClass _ _ _ _ n _ _ ms) = concatMap tldeclared ms
706−tldeclared (PInstance _ _ _ _ _ _ _ _) = []
716+tldeclared (PInstance _ _ _ _ _ _ _ _ _ _) = []
707tldeclared _ = []
717tldeclared _ = []
709defined :: PDecl -> [Name]
719defined :: PDecl -> [Name]
@@ -719,7 +729,7 @@ defined (PParams _ _ ds) = concatMap defined ds
719defined (PNamespace _ ds) = concatMap defined ds
729defined (PNamespace _ ds) = concatMap defined ds
720defined (PRecord _ _ _ n _ _ _ (Just c) _ _) = [n, c]
730defined (PRecord _ _ _ n _ _ _ (Just c) _ _) = [n, c]
721defined (PClass _ _ _ _ n _ _ ms) = n : concatMap defined ms
731defined (PClass _ _ _ _ n _ _ ms) = n : concatMap defined ms
722−defined (PInstance _ _ _ _ _ _ _ _) = []
732+defined (PInstance _ _ _ _ _ _ _ _ _ _) = []
723defined (PDSL n _) = [n]
733defined (PDSL n _) = [n]
724defined (PSyntax _ _) = []
734defined (PSyntax _ _) = []
725defined (PMutual _ ds) = concatMap defined ds
735defined (PMutual _ ds) = concatMap defined ds
@@ -774,7 +784,7 @@ data PTerm = PQuote Raw -- ^ Inclusion of a core term into the high-level langua
774 | PAlternative Bool [PTerm] -- ^ True if only one may work. (| A, B, C|)
784 | PAlternative Bool [PTerm] -- ^ True if only one may work. (| A, B, C|)
775 | PHidden PTerm -- ^ Irrelevant or hidden pattern
785 | PHidden PTerm -- ^ Irrelevant or hidden pattern
776 | PType -- ^ 'Type' type
786 | PType -- ^ 'Type' type
777− | PUniverse Universe -- ^ Some universe
787+ | PUniverse Universe -- ^ Some universe
778 | PGoal FC PTerm Name PTerm -- ^ quoteGoal, used for %reflection functions
788 | PGoal FC PTerm Name PTerm -- ^ quoteGoal, used for %reflection functions
779 | PConstant Const -- ^ Builtin types
789 | PConstant Const -- ^ Builtin types
780 | Placeholder -- ^ Underscore
790 | Placeholder -- ^ Underscore
@@ -1109,7 +1119,7 @@ data SSymbol = Keyword Name
1109 | Expr Name
1119 | Expr Name
1110 | SimpleExpr Name
1120 | SimpleExpr Name
1111 deriving (Show, Eq)
1121 deriving (Show, Eq)
1115deriving instance Binary SSymbol
1125deriving instance Binary SSymbol
@@ -1158,7 +1168,7 @@ updateSyntaxRules rules (SyntaxRules sr) = SyntaxRules newRules
1159initDSL = DSL (PRef f (sUN ">>="))
1169initDSL = DSL (PRef f (sUN ">>="))
1160 (PRef f (sUN "return"))
1170 (PRef f (sUN "return"))
1161− (PRef f (sUN "<$>"))
1171+ (PRef f (sUN "<*>"))
1162 (PRef f (sUN "pure"))
1172 (PRef f (sUN "pure"))
@@ -1384,7 +1394,7 @@ pprintPTerm ppo bnd docArgs infixes = prettySe startPrec bnd
1385 startPrec = 0
1395 startPrec = 0
1386 funcAppPrec = 10
1396 funcAppPrec = 10
1388 prettySe :: Int -> [(Name, Bool)] -> PTerm -> Doc OutputAnnotation
1398 prettySe :: Int -> [(Name, Bool)] -> PTerm -> Doc OutputAnnotation
1389 prettySe p bnd (PQuote r) =
1399 prettySe p bnd (PQuote r) =
1390 text "![" <> pretty r <> text "]"
1400 text "![" <> pretty r <> text "]"
@@ -1447,7 +1457,7 @@ pprintPTerm ppo bnd docArgs infixes = prettySe startPrec bnd
1447 [x] -> group (opName True <$> group (prettySe startPrec bnd (getTm x)))
1457 [x] -> group (opName True <$> group (prettySe startPrec bnd (getTm x)))
1448 [l,r] -> let precedence = maybe (startPrec - 1) prec f
1458 [l,r] -> let precedence = maybe (startPrec - 1) prec f
1449 in bracket p precedence $ inFix (getTm l) (getTm r)
1459 in bracket p precedence $ inFix (getTm l) (getTm r)
1450− (l@(PExp _ _ _ _) : r@(PExp _ _ _ _) : rest) ->
1460+ (l@(PExp _ _ _ _) : r@(PExp _ _ _ _) : rest) ->
1451 bracket p funcAppPrec $
1461 bracket p funcAppPrec $
1452 enclose lparen rparen (inFix (getTm l) (getTm r)) <+>
1462 enclose lparen rparen (inFix (getTm l) (getTm r)) <+>
1453 align (group (vsep (map (prettyArgS bnd) rest)))
1463 align (group (vsep (map (prettyArgS bnd) rest)))
@@ -1463,7 +1473,7 @@ pprintPTerm ppo bnd docArgs infixes = prettySe startPrec bnd
1463 Just (Infixr p') -> p'
1473 Just (Infixr p') -> p'
1464 Just f' -> prec f' + 1
1474 Just f' -> prec f' + 1
1465 inFix l r = align . group $
1475 inFix l r = align . group $
1466− (prettySe left bnd l <+> opName False) <$>
1476+ (prettySe left bnd l <+> opName False) <$>
1467 group (prettySe right bnd r)
1477 group (prettySe right bnd r)
1468 prettySe p bnd (PApp _ hd@(PRef fc f) [tm]) -- symbols, like 'foo
1478 prettySe p bnd (PApp _ hd@(PRef fc f) [tm]) -- symbols, like 'foo
1469 | PConstant (Idris.Core.TT.Str str) <- getTm tm,
1479 | PConstant (Idris.Core.TT.Str str) <- getTm tm,
@@ -1482,7 +1492,7 @@ pprintPTerm ppo bnd docArgs infixes = prettySe startPrec bnd
1482 align $ kwd "case" <+> prettySe startPrec bnd scr <+> kwd "of" <$>
1492 align $ kwd "case" <+> prettySe startPrec bnd scr <+> kwd "of" <$>
1483 indent 2 (vsep (map ppcase cases))
1493 indent 2 (vsep (map ppcase cases))
1485− ppcase (l, r) = let prettyCase = prettySe startPrec
1495+ ppcase (l, r) = let prettyCase = prettySe startPrec
1486 ([(n, False) | n <- vars l] ++ bnd)
1496 ([(n, False) | n <- vars l] ++ bnd)
1487 in nest nestingSize $
1497 in nest nestingSize $
1488 prettyCase l <+> text "=>" <+> prettyCase r
1498 prettyCase l <+> text "=>" <+> prettyCase r
@@ -1553,7 +1563,7 @@ pprintPTerm ppo bnd docArgs infixes = prettySe startPrec bnd
1553 prettyAs =
1563 prettyAs =
1554 foldr (\l -> \r -> l <+> text "," <+> r) empty $ map (prettySe startPrec bnd) as
1564 foldr (\l -> \r -> l <+> text "," <+> r) empty $ map (prettySe startPrec bnd) as
1555 prettySe p bnd PType = annotate (AnnType "Type" "The type of types") $ text "Type"
1565 prettySe p bnd PType = annotate (AnnType "Type" "The type of types") $ text "Type"
1556− prettySe p bnd (PUniverse u) = annotate (AnnType (show u) "The type of unique types") $ text (show u)
1566+ prettySe p bnd (PUniverse u) = annotate (AnnType (show u) "The type of unique types") $ text (show u)
1557 prettySe p bnd (PConstant c) = annotate (AnnConst c) (text (show c))
1567 prettySe p bnd (PConstant c) = annotate (AnnConst c) (text (show c))
1558 -- XXX: add pretty for tactics
1568 -- XXX: add pretty for tactics
1559 prettySe p bnd (PProof ts) =
1569 prettySe p bnd (PProof ts) =
@@ -1725,7 +1735,7 @@ showDeclImp o (PNamespace n ps) = text "namespace" <+> text n <> braces (line <>
1725showDeclImp _ (PSyntax _ syn) = text "syntax" <+> text (show syn)
1735showDeclImp _ (PSyntax _ syn) = text "syntax" <+> text (show syn)
1726showDeclImp o (PClass _ _ _ cs n ps _ ds)
1736showDeclImp o (PClass _ _ _ cs n ps _ ds)
1727 = text "class" <+> text (show cs) <+> text (show n) <+> text (show ps) <> line <> showDecls o ds
1737 = text "class" <+> text (show cs) <+> text (show n) <+> text (show ps) <> line <> showDecls o ds
1728−showDeclImp o (PInstance _ _ cs n _ t _ ds)
1738+showDeclImp o (PInstance _ _ _ _ cs n _ t _ ds)
1729 = text "instance" <+> text (show cs) <+> text (show n) <+> prettyImp o t <> line <> showDecls o ds
1739 = text "instance" <+> text (show cs) <+> text (show n) <+> prettyImp o t <> line <> showDecls o ds
1730showDeclImp _ _ = text "..."
1740showDeclImp _ _ = text "..."
1731-- showDeclImp (PImport o) = "import " ++ o
1741-- showDeclImp (PImport o) = "import " ++ o
@@ -1901,16 +1911,16 @@ implicitNamesIn :: [Name] -> IState -> PTerm -> [Name]
1901implicitNamesIn uvars ist tm = nub $ ni [] tm
1911implicitNamesIn uvars ist tm = nub $ ni [] tm
1903 ni env (PRef _ n)
1913 ni env (PRef _ n)
1904− | not (n `elem` env)
1914+ | not (n `elem` env)
1905 = case lookupTy n (tt_ctxt ist) of
1915 = case lookupTy n (tt_ctxt ist) of
1906 [] -> [n]
1916 [] -> [n]
1907 _ -> if n `elem` uvars then [n] else []
1917 _ -> if n `elem` uvars then [n] else []
1908− ni env (PApp _ f@(PRef _ n) as)
1918+ ni env (PApp _ f@(PRef _ n) as)
1909 | n `elem` uvars = ni env f ++ concatMap (ni env) (map getTm as)
1919 | n `elem` uvars = ni env f ++ concatMap (ni env) (map getTm as)
1910 | otherwise = concatMap (ni env) (map getTm as)
1920 | otherwise = concatMap (ni env) (map getTm as)
1911 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1921 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1912 ni env (PAppBind _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1922 ni env (PAppBind _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1913− ni env (PCase _ c os) = ni env c ++
1923+ ni env (PCase _ c os) = ni env c ++
1914 -- names in 'os', not counting the names bound in the cases
1924 -- names in 'os', not counting the names bound in the cases
1915 (nub (concatMap (ni env) (map snd os))
1925 (nub (concatMap (ni env) (map snd os))
1916 \\ nub (concatMap (ni env) (map fst os)))
1926 \\ nub (concatMap (ni env) (map fst os)))
@@ -1940,7 +1950,7 @@ namesIn uvars ist tm = nub $ ni [] tm
1940 _ -> if n `elem` (map fst uvars) then [n] else []
1950 _ -> if n `elem` (map fst uvars) then [n] else []
1941 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1951 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1942 ni env (PAppBind _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1952 ni env (PAppBind _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1943− ni env (PCase _ c os) = ni env c ++
1953+ ni env (PCase _ c os) = ni env c ++
1944 -- names in 'os', not counting the names bound in the cases
1954 -- names in 'os', not counting the names bound in the cases
1945 (nub (concatMap (ni env) (map snd os))
1955 (nub (concatMap (ni env) (map snd os))
1946 \\ nub (concatMap (ni env) (map fst os)))
1956 \\ nub (concatMap (ni env) (map fst os)))
@@ -1999,4 +2009,3 @@ getErasureInfo ist n =
1999 case lookupCtxtExact n (idris_optimisation ist) of
2009 case lookupCtxtExact n (idris_optimisation ist) of
2000 Just (Optimise inacc detagg) -> map fst inacc
2010 Just (Optimise inacc detagg) -> map fst inacc
2001 Nothing -> []
2011 Nothing -> []