on master help sign in
Merge branch 'master' of github.com:idris-lang/Idris-dev
commit0a1b72cb5414c4b32768c68baf3c26e89bdc2bbe authorEdwin Brady <ecb10@st-andrews.ac.uk> dateSun 4 Jan 2015, 14:45 (12 years ago) parentcad3b0225c117a
19 files changed+199−34
CHANGELOG+1−1 idris.cabal+7−2 libs/prelude/Prelude/Uninhabited.idr+3 src/Idris/AbsSyntaxTree.hs+12−1 src/Idris/Chaser.hs+1−1 src/Idris/Core/Binary.hs+1−1 src/Idris/Core/Unify.hs+4−4 src/Idris/Docs.hs+14 src/Idris/IBC.hs+17−5 src/Idris/IdeSlave.hs+3−3 src/Idris/ParseHelpers.hs+8−1 src/Idris/Parser.hs+35−13 src/Idris/Primitives.hs+1−1 src/Idris/REPL.hs+6−1 src/Pkg/PParser.hs+7 test/idrisdoc009/Test.idr+45 test/idrisdoc009/expected+29 test/idrisdoc009/input+2 test/idrisdoc009/run+3
CHANGELOG+1−1
@@ -15,9 +15,9 @@ New in 0.9.16:
1515 to search.
1616* Vect, Fin and So moved out of prelude into base, in modules Data.Vect,
1717 Data.Fin and Data.So respectively.
18−
1918* Several long-standing issues resolved, particularly with pattern matching
2019 and coverage checking.
20+* Modules can now have API documentation strings.
2121
2222New in 0.9.15:
2323--------------
idris.cabal+7−2
@@ -422,6 +422,11 @@ Extra-source-files:
422422 test/idrisdoc008/expected
423423 test/idrisdoc008/*.idr
424424 test/idrisdoc008/*.ipkg
425+ test/idrisdoc009/run
426+ test/idrisdoc009/expected
427+ test/idrisdoc009/input
428+ test/idrisdoc009/*.idr
429+
425430
426431 test/interactive001/run
427432 test/interactive001/input
@@ -725,12 +730,12 @@ Library
725730 , bytestring < 0.11
726731 , cheapskate < 0.2
727732 , containers >= 0.5 && < 0.6
728− , deepseq < 1.4
733+ , deepseq < 1.5
729734 , directory >= 1.2 && < 1.3
730735 , filepath < 1.4
731736 , fingertree >= 0.1 && < 0.2
732737 , haskeline >= 0.7 && < 0.8
733− , lens >= 4.1.1 && < 4.7
738+ , lens >= 4.1.1 && < 4.8
734739 , mtl >= 2.2.1 && < 2.3
735740 , network < 2.7
736741 , optparse-applicative >= 0.11 && < 0.12
libs/prelude/Prelude/Uninhabited.idr+3
@@ -1,3 +1,6 @@
1+||| Utilities for working with uninhabited types, to record explicit
2+||| locations for canonical proofs of emptiness. Typically, one should
3+||| use the `absurd` function.
14module Prelude.Uninhabited
25
36import Builtins
src/Idris/AbsSyntaxTree.hs+12−1
@@ -165,6 +165,9 @@ data IState = IState {
165165 idris_callgraph :: Ctxt CGInfo, -- name, args used in each pos
166166 idris_calledgraph :: Ctxt [Name],
167167 idris_docstrings :: Ctxt (Docstring DocTerm, [(Name, Docstring DocTerm)]),
168+ idris_moduledocs :: Ctxt (Docstring DocTerm),
169+ -- ^ module documentation is saved in a special MN so the context
170+ -- mechanism can be used for disambiguation
168171 idris_tyinfodata :: Ctxt TIData,
169172 idris_fninfo :: Ctxt FnInfo,
170173 idris_transforms :: Ctxt [(Term, Term)],
@@ -285,11 +288,13 @@ data IBCWrite = IBCFix FixDecl
285288 | IBCPostulate Name
286289 | IBCTotCheckErr FC String
287290 | IBCParsedRegion FC
291+ | IBCModDocs Name -- ^ The name is the special name used to track module docs
288292 deriving Show
289293
290294-- | The initial state for the compiler
291295idrisInit :: IState
292−idrisInit = IState initContext [] [] emptyContext emptyContext emptyContext
296+idrisInit = IState initContext [] []
297+ emptyContext emptyContext emptyContext emptyContext
293298 emptyContext emptyContext emptyContext emptyContext
294299 emptyContext emptyContext emptyContext emptyContext
295300 emptyContext emptyContext emptyContext emptyContext
@@ -1197,6 +1202,12 @@ eqParamDoc = [(n "A", annotCode (const (Left $ Msg "")) . parseDocstring . T.pac
11971202
11981203eqOpts = []
11991204
1205+-- | The special name to be used in the module documentation context -
1206+-- not for use in the main definition context. The namespace around it
1207+-- will determine the module to which the docs adhere.
1208+modDocName :: Name
1209+modDocName = sMN 0 "ModuleDocs"
1210+
12001211-- Defined in builtins.idr
12011212sigmaTy = sNS (sUN "Sigma") ["Builtins"]
12021213existsCon = sNS (sUN "MkSigma") ["Builtins"]
src/Idris/Chaser.hs+1−1
@@ -135,7 +135,7 @@ buildTree built fp = btree [] fp
135135 if exist then do
136136 file_in <- runIO $ readFile f
137137 file <- if lit then tclift $ unlit f file_in else return file_in
138− (_, modules, _) <- parseImports f file
138+ (_, _, modules, _) <- parseImports f file
139139 -- The chaser should never report warnings from sub-modules
140140 clearParserWarnings
141141 ms <- mapM (btree done) [realName | (_, realName, alias, fc) <- modules]
src/Idris/Core/Binary.hs+1−1
@@ -1,4 +1,4 @@
1−{-# OPTIONS_GHC -fwarn-incomplete-patterns -Werror #-}
1+{-# OPTIONS_GHC -fwarn-incomplete-patterns #-}
22
33{-| Binary instances for the core datatypes -}
44module Idris.Core.Binary where
src/Idris/Core/Unify.hs+4−4
@@ -73,14 +73,14 @@ match_unify ctxt env topx topy inj holes from =
7373 let topxn = renameBindersTm env (normalise ctxt env topx)
7474 topyn = renameBindersTm env (normalise ctxt env topy) in
7575 case runStateT (un [] topxn topyn)
76− (UI 0 []) of
76+ (UI 0 []) of
7777 OK (v, UI _ fails) ->
7878 do v' <- trimSolutions topx topy from env v
7979 return (map (renameBinders env) v')
8080 Error e ->
8181 -- just normalise the term we're matching against
8282 case runStateT (un [] topxn topy)
83− (UI 0 []) of
83+ (UI 0 []) of
8484 OK (v, UI _ fails) ->
8585 do v' <- trimSolutions topx topy from env v
8686 return (map (renameBinders env) v')
@@ -286,12 +286,12 @@ unify ctxt env topx topy inj holes usersupp from =
286286 topyn = renameBindersTm env (normalise ctxt env topy) in
287287-- trace ("Unifying " ++ show (topx, topy) ++ "\n\n==>\n" ++ show (topxn, topyn) ++ "\n\n" ++ show res ++ "\n\n") $
288288 case runStateT (un False [] topxn topyn)
289− (UI 0 []) of
289+ (UI 0 []) of
290290 OK (v, UI _ fails) ->
291291 do v' <- trimSolutions topx topy from env v
292292 return (map (renameBinders env) v', reverse fails)
293293-- Error e@(CantUnify False _ _ _ _ _) -> tfail e
294− Error e -> tfail e
294+ Error e -> tfail e
295295 where
296296 headDiff (P (DCon _ _ _) x _) (P (DCon _ _ _) y _) = x /= y
297297 headDiff (P (TCon _ _) x _) (P (TCon _ _) y _) = x /= y
src/Idris/Docs.hs+14
@@ -31,6 +31,8 @@ data Docs = FunDoc FunDoc
3131 [(Name, Maybe (Docstring DocTerm))] -- parameters and their docstrings
3232 [PTerm] -- instances
3333 [PTerm] -- superclasses
34+ | ModDoc [String] -- Module name
35+ (Docstring DocTerm)
3436
3537showDoc ist d
3638 | nullDocstring d = empty
@@ -138,7 +140,19 @@ pprintDocs ist (ClassDoc n doc meths params instances superclasses)
138140 then vsep (map (\(nm,md) -> prettyName True False params' nm <+> maybe empty (showDoc ist) md) params)
139141 else hsep (punctuate comma (map (prettyName True False params' . fst) params))
140142
143+pprintDocs ist (ModDoc mod docs)
144+ = nest 4 $ text "Module" <+> text (concat (intersperse "." mod)) <> colon <$>
145+ renderDocstring (renderDocTerm (pprintDelab ist) (normaliseAll (tt_ctxt ist) [])) docs
146+
147+-- | Given a fully-qualified, disambiguated name, construct the
148+-- documentation object for it
141149getDocs :: Name -> Idris Docs
150+getDocs n@(NS n' ns) | n' == modDocName
151+ = do i <- getIState
152+ case lookupCtxtExact n (idris_moduledocs i) of
153+ Just doc -> return $ ModDoc (reverse (map T.unpack ns)) doc
154+ Nothing -> fail $ "Module docs for " ++ show (reverse (map T.unpack ns)) ++
155+ " do not exist! This shouldn't have happened and is a bug."
142156getDocs n
143157 = do i <- getIState
144158 case lookupCtxt n (idris_classes i) of
src/Idris/IBC.hs+17−5
@@ -35,7 +35,7 @@ import Codec.Compression.Zlib (compress)
3535import Util.Zlib (decompressEither)
3636
3737ibcVersion :: Word8
38−ibcVersion = 90
38+ibcVersion = 92
3939
4040data IBCFile = IBCFile { ver :: Word8,
4141 sourcefile :: FilePath,
@@ -65,6 +65,7 @@ data IBCFile = IBCFile { ver :: Word8,
6565 ibc_cg :: ![(Name, CGInfo)],
6666 ibc_defs :: ![(Name, Def)],
6767 ibc_docstrings :: ![(Name, (Docstring D.DocTerm, [(Name, Docstring D.DocTerm)]))],
68+ ibc_moduledocs :: ![(Name, Docstring D.DocTerm)],
6869 ibc_transforms :: ![(Name, (Term, Term))],
6970 ibc_errRev :: ![(Term, Term)],
7071 ibc_coercions :: ![Name],
@@ -84,7 +85,7 @@ deriving instance Binary IBCFile
8485!-}
8586
8687initIBC :: IBCFile
87−initIBC = IBCFile ibcVersion "" [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Nothing
88+initIBC = IBCFile ibcVersion "" [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Nothing
8889
8990loadIBC :: Bool -- ^ True = reexport, False = make everything private
9091 -> FilePath -> Idris ()
@@ -225,6 +226,9 @@ ibc i (IBCMetavar n) f =
225226ibc i (IBCPostulate n) f = return f { ibc_postulates = n : ibc_postulates f }
226227ibc i (IBCTotCheckErr fc err) f = return f { ibc_totcheckfail = (fc, err) : ibc_totcheckfail f }
227228ibc i (IBCParsedRegion fc) f = return f { ibc_parsedSpan = Just fc }
229+ibc i (IBCModDocs n) f = case lookupCtxtExact n (idris_moduledocs i) of
230+ Just v -> return f { ibc_moduledocs = (n,v) : ibc_moduledocs f }
231+ _ -> ifail "IBC write failed"
228232
229233process :: Bool -- ^ Reexporting
230234 -> IBCFile -> FilePath -> Idris ()
@@ -269,6 +273,7 @@ process reexp i fn
269273 pTotCheckErr $ force (ibc_totcheckfail i)
270274 pCG $ force (ibc_cg i)
271275 pDocs $ force (ibc_docstrings i)
276+ pMDocs $ force (ibc_moduledocs i)
272277 pCoercions $ force (ibc_coercions i)
273278 pTrans $ force (ibc_transforms i)
274279 pErrRev $ force (ibc_errRev i)
@@ -479,7 +484,12 @@ pDefs reexp syms ds
479484 update t = return t
480485
481486pDocs :: [(Name, (Docstring D.DocTerm, [(Name, Docstring D.DocTerm)]))] -> Idris ()
482−pDocs ds = mapM_ (\ (n, a) -> addDocStr n (fst a) (snd a)) ds
487+pDocs ds = mapM_ (\(n, a) -> addDocStr n (fst a) (snd a)) ds
488+
489+pMDocs :: [(Name, Docstring D.DocTerm)] -> Idris ()
490+pMDocs ds = mapM_ addMDocStr ds
491+ where addMDocStr (n, d) = do ist <- getIState
492+ putIState ist { idris_moduledocs = addDef n d (idris_moduledocs ist) }
483493
484494pAccess :: Bool -- ^ Reexporting?
485495 -> [(Name, Accessibility)] -> Idris ()
@@ -895,7 +905,7 @@ instance Binary MetaInformation where
895905 return (DataMI x1)
896906
897907instance Binary IBCFile where
898− put x@(IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33 x34 x35 x36 x37 x38 x39 x40)
908+ put x@(IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33 x34 x35 x36 x37 x38 x39 x40 x41)
899909 = {-# SCC "putIBCFile" #-}
900910 do put x1
901911 put x2
@@ -937,6 +947,7 @@ instance Binary IBCFile where
937947 put x38
938948 put x39
939949 put x40
950+ put x41
940951
941952 get
942953 = do x1 <- get
@@ -980,7 +991,8 @@ instance Binary IBCFile where
980991 x38 <- get
981992 x39 <- get
982993 x40 <- get
983− return (IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33 x34 x35 x36 x37 x38 x39 x40)
994+ x41 <- get
995+ return (IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33 x34 x35 x36 x37 x38 x39 x40 x41)
984996 else return (initIBC { ver = x1 })
985997
986998instance Binary DataOpt where
src/Idris/IdeSlave.hs+3−3
@@ -150,9 +150,9 @@ instance SExpable OutputAnnotation where
150150 toSExp (AnnSearchResult ordr) = toSExp [(SymbolAtom "doc-overview",
151151 StringAtom ("Result type is " ++ descr))]
152152 where descr = case ordr of
153− EQ -> "isomorphic"
154− LT -> "more general than searched type"
155− GT -> "more specific than searched type"
153+ EQ -> "isomorphic"
154+ LT -> "more general than searched type"
155+ GT -> "more specific than searched type"
156156 toSExp (AnnErr e) = toSExp [(SymbolAtom "error", StringAtom (encodeErr e))]
157157
158158encodeTerm :: [(Name, Bool)] -> Term -> String
src/Idris/ParseHelpers.hs+8−1
@@ -1,4 +1,7 @@
1−{-# LANGUAGE GeneralizedNewtypeDeriving, ConstraintKinds, PatternGuards, OverlappingInstances, StandaloneDeriving #-}
1+{-# LANGUAGE CPP, GeneralizedNewtypeDeriving, ConstraintKinds, PatternGuards, StandaloneDeriving #-}
2+#if !(MIN_VERSION_base(4,8,0))
3+{-# LANGUAGE OverlappingInstances #-}
4+#endif
25module Idris.ParseHelpers where
36
47import Prelude hiding (pi)
@@ -47,7 +50,11 @@ newtype IdrisInnerParser a = IdrisInnerParser { runInnerParser :: Parser a }
4750
4851deriving instance Parsing IdrisInnerParser
4952
53+#if MIN_VERSION_base(4,8,0)
54+instance {-# OVERLAPPING #-} TokenParsing IdrisParser where
55+#else
5056instance TokenParsing IdrisParser where
57+#endif
5158 someSpace = many (simpleWhiteSpace <|> singleLineComment <|> multiLineComment) *> pure ()
5259 token p = do s <- get
5360 (FC fn (sl, sc) _) <- getFC --TODO: Update after fixing getFC
src/Idris/Parser.hs+35−13
@@ -24,6 +24,7 @@ import Idris.DSL
2424import Idris.Imports
2525import Idris.Delaborate
2626import Idris.Error
27+import Idris.Elab.Value
2728import Idris.ElabDecls
2829import Idris.ElabTerm
2930import Idris.Coverage
@@ -90,18 +91,21 @@ import System.IO
9091 ModuleHeader ::= 'module' Identifier_t ';'?;
9192@
9293-}
93−moduleHeader :: IdrisParser [String]
94−moduleHeader = try (do noDocCommentHere "Modules cannot have documentation comments"
94+moduleHeader :: IdrisParser (Maybe (Docstring ()), [String])
95+moduleHeader = try (do docs <- optional docComment
96+ noArgs docs
9597 reserved "module"
9698 i <- identifier
9799 option ';' (lchar ';')
98− return (moduleName i))
100+ return (fmap fst docs, moduleName i))
99101 <|> try (do lchar '%'; reserved "unqualified"
100− return [])
101− <|> return (moduleName "Main")
102+ return (Nothing, []))
103+ <|> return (Nothing, moduleName "Main")
102104 where moduleName x = case span (/='.') x of
103105 (x, "") -> [x]
104106 (x, '.':y) -> x : moduleName y
107+ noArgs (Just (_, args)) | not (null args) = fail "Modules do not take arguments"
108+ noArgs _ = return ()
105109
106110{- | Parses an import statement
107111
@@ -1133,24 +1137,24 @@ parseTactic :: IState -> String -> Result PTactic
11331137parseTactic st = runparser (fullTactic defaultSyntax) st "(input)"
11341138
11351139-- | Parse module header and imports
1136−parseImports :: FilePath -> String -> Idris ([String], [(Bool, String, Maybe String, FC)], Maybe Delta)
1140+parseImports :: FilePath -> String -> Idris (Maybe (Docstring ()), [String], [(Bool, String, Maybe String, FC)], Maybe Delta)
11371141parseImports fname input
11381142 = do i <- getIState
11391143 case parseString (runInnerParser (evalStateT imports i)) (Directed (UTF8.fromString fname) 0 0 0 0) input of
11401144 Failure err -> fail (show err)
11411145 Success (x, i) -> do putIState i
11421146 return x
1143− where imports :: IdrisParser (([String], [(Bool, String, Maybe String, FC)], Maybe Delta), IState)
1147+ where imports :: IdrisParser ((Maybe (Docstring ()), [String], [(Bool, String, Maybe String, FC)], Maybe Delta), IState)
11441148 imports = do whiteSpace
1145− mname <- moduleHeader
1146− ps <- many import_
1147− mrk <- mark
1148− isEof <- lookAheadMatches eof
1149+ (mdoc, mname) <- moduleHeader
1150+ ps <- many import_
1151+ mrk <- mark
1152+ isEof <- lookAheadMatches eof
11491153 let mrk' = if isEof
11501154 then Nothing
11511155 else Just mrk
11521156 i <- get
1153− return ((mname, ps, mrk'), i)
1157+ return ((mdoc, mname, ps, mrk'), i)
11541158
11551159-- | There should be a better way of doing this...
11561160findFC :: Doc -> (FC, String)
@@ -1261,7 +1265,7 @@ loadSource lidr f toline
12611265 let def_total = default_total i
12621266 file_in <- runIO $ readFile f
12631267 file <- if lidr then tclift $ unlit f file_in else return file_in
1264− (mname, imports_in, pos) <- parseImports f file
1268+ (mdocs, mname, imports_in, pos) <- parseImports f file
12651269 ai <- getAutoImports
12661270 let imports = map (\n -> (True, n, Just n, emptyFC)) ai ++ imports_in
12671271 ids <- allImportDirs
@@ -1340,6 +1344,13 @@ loadSource lidr f toline
13401344 i <- getIState
13411345 addHides (hide_list i)
13421346
1347+ -- Save module documentation if applicable
1348+ i <- getIState
1349+ case mdocs of
1350+ Nothing -> return ()
1351+ Just docs -> addModDoc syntax mname docs
1352+
1353+
13431354 -- Finally, write an ibc if checking was successful
13441355 ok <- noErrors
13451356 when ok $
@@ -1364,6 +1375,17 @@ loadSource lidr f toline
13641375 PInstance _ _ _ _ _ _ _ _ -> r
13651376 _ -> x
13661377
1378+ addModDoc :: SyntaxInfo -> [String] -> Docstring () -> Idris ()
1379+ addModDoc syn mname docs =
1380+ do ist <- getIState
1381+ docs' <- elabDocTerms recinfo (parsedDocs ist)
1382+ let modDocs' = addDef docName docs' (idris_moduledocs ist)
1383+ putIState ist { idris_moduledocs = modDocs' }
1384+ addIBC (IBCModDocs docName)
1385+ where
1386+ docName = NS modDocName (map T.pack (reverse mname))
1387+ parsedDocs ist = annotCode (tryFullExpr syn ist) docs
1388+
13671389{- | Adds names to hide list -}
13681390addHides :: [(Name, Maybe Accessibility)] -> Idris ()
13691391addHides xs = do i <- getIState
src/Idris/Primitives.hs+1−1
@@ -20,7 +20,7 @@ data Prim = Prim { p_name :: Name,
2020 p_type :: Type,
2121 p_arity :: Int,
2222 p_def :: [Const] -> Maybe Const,
23− p_lexp :: (Int, PrimFn),
23+ p_lexp :: (Int, PrimFn),
2424 p_total :: Totality
2525 }
2626
src/Idris/REPL.hs+6−1
@@ -887,12 +887,17 @@ process fn (Check t)
887887
888888process fn (DocStr (Left n))
889889 = do ist <- getIState
890− case lookupCtxtName n (idris_docstrings ist) of
890+ let docs = lookupCtxtName n (idris_docstrings ist) ++
891+ map (\(n,d)-> (n, (d,[]))) (lookupCtxtName (modDocN n) (idris_moduledocs ist))
892+ case docs of
891893 [] -> iPrintError $ "No documentation for " ++ show n
892894 ns -> do toShow <- mapM (showDoc ist) ns
893895 iRenderResult (vsep toShow)
894896 where showDoc ist (n, d) = do doc <- getDocs n
895897 return $ pprintDocs ist doc
898+ modDocN (NS (UN n) ns) = NS modDocName (n:ns)
899+ modDocN (UN n) = NS modDocName [n]
900+ modDocN _ = sMN 1 "NotFoundForSure"
896901
897902process fn (DocStr (Right c))
898903 = do ist <- getIState
src/Pkg/PParser.hs+7
@@ -1,4 +1,7 @@
1+{-# LANGUAGE CPP #-}
2+#if !(MIN_VERSION_base(4,8,0))
13{-# LANGUAGE OverlappingInstances #-}
4+#endif
25
36module Pkg.PParser where
47
@@ -31,7 +34,11 @@ data PkgDesc = PkgDesc { pkgname :: String,
3134 }
3235 deriving Show
3336
37+#if MIN_VERSION_base(4,8,0)
38+instance {-# OVERLAPPING #-} TokenParsing PParser where
39+#else
3440instance TokenParsing PParser where
41+#endif
3542 someSpace = many (simpleWhiteSpace <|> singleLineComment <|> multiLineComment) *> pure ()
3643
3744
test/idrisdoc009/Test.idrnew file+45
@@ -0,0 +1,45 @@
1+||| Docs for module Test.
2+|||
3+||| It is a great module.
4+||| Prelude thingy:
5+||| ```idris example
6+||| "foo" ++ "bar"
7+||| ```
8+|||
9+||| Imported thingy:
10+||| ```idris example
11+||| 0.0 :+ 0.2
12+||| ```
13+|||
14+||| Type error:
15+||| ```idris
16+||| "foo" + 2
17+||| ```
18+|||
19+||| From this module:
20+||| ```idris example
21+||| MkTest
22+||| ```
23+module Test
24+import Data.Complex
25+
26+myplus : Nat -> Nat -> Nat
27+myplus Z j = j
28+myplus (S k) j = S (myplus k j)
29+
30+||| Docs for datatype Test.
31+data Test = MkTest
32+
33+data Thing : Type -> Type where
34+ MkThing : Thing Nat
35+
36+-- fnord ++ xyz do done let module argh
37+
38+namespace Main
39+ ||| Main is handy to do things in. ++.
40+ main : IO ()
41+ main = do putStrLn "Hi!"
42+ l <- getLine
43+ case l of
44+ "" => putStrLn "No!"
45+ str => putStrLn str
test/idrisdoc009/expectednew file+29
@@ -0,0 +1,29 @@
1+Type checking ./Test.idr
2+Data type Test : Type
3+ Docs for datatype Test.
4+
5+Constructors:
6+ MkTest : Test
7+
8+
9+Module Test:
10+ Docs for module Test.
11+
12+ It is a great module. Prelude thingy:
13+
14+ > "foo" ++ "bar"
15+ "foobar"
16+
17+ Imported thingy:
18+
19+ > 0.0 :+ 0.2
20+ 0.0 :+ 0.2
21+
22+ Type error:
23+
24+ "foo" + 2
25+
26+ From this module:
27+
28+ > MkTest
29+ MkTest
test/idrisdoc009/inputnew file+2
@@ -0,0 +1,2 @@
1+:consolewidth infinite
2+:doc Test
test/idrisdoc009/runnew file+3
@@ -0,0 +1,3 @@
1+#!/usr/bin/env bash
2+idris $@ --nocolour --quiet Test.idr < input
3+rm -f *.ibc