@@ -36,7 +36,7 @@ import Idris.Parser.Ops
3636import Idris.Termination
3737import Idris.Unlit
3838
39−import qualified Util.Pretty as P
39+import qualified Util.Pretty
4040import Util.System (readSource)
4141
4242import Prelude hiding (pi)
@@ -59,9 +59,9 @@ import qualified System.Directory as Dir (makeAbsolute)
5959import System.FilePath
6060import Text.PrettyPrint.ANSI.Leijen (Doc, plain)
6161import qualified Text.PrettyPrint.ANSI.Leijen as ANSI
62−import Text.Trifecta hiding (Err, char, charLiteral, natural, span, string,
63− stringLiteral, symbol, whiteSpace)
64−import Text.Trifecta.Delta
62+import Text.Trifecta ((<?>))
63+import qualified Text.Trifecta as P
64+import qualified Text.Trifecta.Delta as P
6565
6666{-
6767@
@@ -84,17 +84,17 @@ import Text.Trifecta.Delta
8484@
8585-}
8686moduleHeader :: IdrisParser (Maybe (Docstring ()), [String], [(FC, OutputAnnotation)])
87−moduleHeader = try (do docs <- optional docComment
88− noArgs docs
89− reservedHL "module"
90− (i, ifc) <- identifier
91− option ';' (lchar ';')
92− let modName = moduleName i
93− return (fmap fst docs,
94− modName,
95− [(ifc, AnnNamespace (map T.pack modName) Nothing)]))
96− <|> try (do lchar '%'; reserved "unqualified"
97− return (Nothing, [], []))
87+moduleHeader = P.try (do docs <- optional docComment
88+ noArgs docs
89+ reservedHL "module"
90+ (i, ifc) <- identifier
91+ P.option ';' (lchar ';')
92+ let modName = moduleName i
93+ return (fmap fst docs,
94+ modName,
95+ [(ifc, AnnNamespace (map T.pack modName) Nothing)]))
96+ <|> P.try (do lchar '%'; reserved "unqualified"
97+ return (Nothing, [], []))
9898 <|> return (Nothing, moduleName "Main", [])
9999 where moduleName x = case span (/='.') x of
100100 (x, "") -> [x]
@@ -119,12 +119,11 @@ data ImportInfo = ImportInfo { import_reexport :: Bool
119119import_ :: IdrisParser ImportInfo
120120import_ = do fc <- getFC
121121 reservedHL "import"
122− reexport <- option False (do reservedHL "public"
123− return True)
122+ reexport <- P.option False (True <$ reservedHL "public")
124123 (id, idfc) <- identifier
125124 newName <- optional (do reservedHL "as"
126125 identifier)
127− option ';' (lchar ';')
126+ P.option ';' (lchar ';')
128127 return $ ImportInfo reexport (toPath id)
129128 (fmap (\(n, fc) -> (toPath n, fc)) newName)
130129 (map T.pack $ ns id) fc idfc
@@ -143,7 +142,7 @@ prog syn = do whiteSpace
143142 decls <- many (decl syn)
144143 let c = concat decls
145144 case maxline syn of
146− Nothing -> do notOpenBraces; eof
145+ Nothing -> do notOpenBraces; P.eof
147146 _ -> return ()
148147 ist <- get
149148 fc <- getFC
@@ -172,7 +171,7 @@ Decl ::=
172171@
173172-}
174173decl :: SyntaxInfo -> IdrisParser [PDecl]
175−decl syn = try (externalDecl syn)
174+decl syn = P.try (externalDecl syn)
176175 <|> internalDecl syn
177176 <?> "declaration"
178177
@@ -195,13 +194,13 @@ internalDecl syn
195194 if continue then
196195 do notEndBlock
197196 declBody continue
198− else try (do notEndBlock
199− declBody continue)
197+ else P.try (do notEndBlock
198+ declBody continue)
200199 <|> fail "End of readable input"
201200 where declBody :: Bool -> IdrisParser [PDecl]
202201 declBody b =
203− try (implementation True syn)
204− <|> try (openInterface syn)
202+ P.try (implementation True syn)
203+ <|> P.try (openInterface syn)
205204 <|> declBody' b
206205 <|> using_ syn
207206 <|> params syn
@@ -276,9 +275,9 @@ declExtensions syn rules = declExtension syn [] (filter isDeclRule rules)
276275declExtension :: SyntaxInfo -> [Maybe (Name, SynMatch)] -> [Syntax]
277276 -> IdrisParser [PDecl]
278277declExtension syn ns rules =
279− choice $ flip map (groupBy (ruleGroup `on` syntaxSymbols) rules) $ \rs ->
278+ P.choice $ flip map (groupBy (ruleGroup `on` syntaxSymbols) rules) $ \rs ->
280279 case head rs of -- can never be []
281− DeclRule (symb:_) _ -> try $ do
280+ DeclRule (symb:_) _ -> P.try $ do
282281 n <- extSymbol symb
283282 declExtension syn (n : ns) [DeclRule ss t | (DeclRule (_:ss) t) <- rs]
284283 -- If we have more than one Rule in this bucket, our grammar is
@@ -427,28 +426,28 @@ SyntaxSym ::= '[' Name_t ']'
427426-}
428427syntaxRule :: SyntaxInfo -> IdrisParser Syntax
429428syntaxRule syn
430− = do sty <- try (do
429+ = do sty <- P.try (do
431430 pushIndent
432− sty <- option AnySyntax
433− (do reservedHL "term"; return TermSyntax
434− <|> do reservedHL "pattern"; return PatternSyntax)
431+ sty <- P.option AnySyntax
432+ (TermSyntax <$ reservedHL "term"
433+ <|> PatternSyntax <$ reservedHL "pattern")
435434 reservedHL "syntax"
436435 return sty)
437436 syms <- some syntaxSym
438− when (all isExpr syms) $ unexpected "missing keywords in syntax rule"
437+ when (all isExpr syms) $ P.unexpected "missing keywords in syntax rule"
439438 let ns = mapMaybe getName syms
440439 when (length ns /= length (nub ns))
441− $ unexpected "repeated variable in syntax rule"
440+ $ P.unexpected "repeated variable in syntax rule"
442441 lchar '='
443442 tm <- typeExpr (allowImp syn) >>= uniquifyBinders [n | Binding n <- syms]
444443 terminator
445444 return (Rule (mkSimple syms) tm sty)
446445 <|> do reservedHL "decl"; reservedHL "syntax"
447446 syms <- some syntaxSym
448− when (all isExpr syms) $ unexpected "missing keywords in syntax rule"
447+ when (all isExpr syms) $ P.unexpected "missing keywords in syntax rule"
449448 let ns = mapMaybe getName syms
450449 when (length ns /= length (nub ns))
451− $ unexpected "repeated variable in syntax rule"
450+ $ P.unexpected "repeated variable in syntax rule"
452451 lchar '='
453452 openBlock
454453 dec <- some (decl syn)
@@ -544,10 +543,10 @@ SyntaxSym ::= '[' Name_t ']'
544543@
545544 -}
546545syntaxSym :: IdrisParser SSymbol
547−syntaxSym = try (do lchar '['; n <- fst <$> name; lchar ']'
548− return (Expr n))
549− <|> try (do lchar '{'; n <- fst <$> name; lchar '}'
550− return (Binding n))
546+syntaxSym = P.try (do lchar '['; n <- fst <$> name; lchar ']'
547+ return (Expr n))
548+ <|> P.try (do lchar '{'; n <- fst <$> name; lchar '}'
549+ return (Binding n))
551550 <|> do n <- fst <$> iName []
552551 return (Keyword n)
553552 <|> do sym <- fmap fst stringLiteral
@@ -561,11 +560,11 @@ syntaxSym = try (do lchar '['; n <- fst <$> name; lchar ']'
561560@
562561-}
563562fnDecl :: SyntaxInfo -> IdrisParser [PDecl]
564−fnDecl syn = try (do notEndBlock
565− d <- fnDecl' syn
566− i <- get
567− let d' = fmap (desugar syn i) d
568− return [d']) <?> "function declaration"
563+fnDecl syn = P.try (do notEndBlock
564+ d <- fnDecl' syn
565+ i <- get
566+ let d' = fmap (desugar syn i) d
567+ return [d']) <?> "function declaration"
569568
570569{-| Parses a function declaration
571570
@@ -580,7 +579,7 @@ fnDecl syn = try (do notEndBlock
580579-}
581580fnDecl' :: SyntaxInfo -> IdrisParser PDecl
582581fnDecl' syn = checkDeclFixity $
583− do (doc, argDocs, fc, opts', n, nfc, acc) <- try (do
582+ do (doc, argDocs, fc, opts', n, nfc, acc) <- P.try (do
584583 pushIndent
585584 (doc, argDocs) <- docstring syn
586585 (opts, acc) <- fnOpts
@@ -658,41 +657,32 @@ NameTimesList ::=
658657-}
659658fnOpt :: IdrisParser FnOpt
660659fnOpt = do reservedHL "total"; return TotalFn
661− <|> do reservedHL "partial"; return PartialFn
662− <|> do reservedHL "covering"; return CoveringFn
663− <|> do try (lchar '%' *> reserved "export"); c <- fmap fst stringLiteral;
664− return $ CExport c
665− <|> do try (lchar '%' *> reserved "no_implicit");
666− return NoImplicit
667− <|> do try (lchar '%' *> reserved "inline");
668− return Inlinable
669− <|> do try (lchar '%' *> reserved "static");
670− return StaticFn
671− <|> do try (lchar '%' *> reserved "assert_total");
660+ <|> PartialFn <$ reservedHL "partial"
661+ <|> CoveringFn <$ reservedHL "covering"
662+ <|> do P.try (lchar '%' *> reserved "export"); c <- fmap fst stringLiteral;
663+ return $ CExport c
664+ <|> NoImplicit <$ P.try (lchar '%' *> reserved "no_implicit")
665+ <|> Inlinable <$ P.try (lchar '%' *> reserved "inline")
666+ <|> StaticFn <$ P.try (lchar '%' *> reserved "static")
667+ <|> do P.try (lchar '%' *> reserved "assert_total");
672668 fc <- getFC
673669 parserWarning fc Nothing (Msg "%assert_total is deprecated. Use the 'assert_total' function instead.")
674670 return AssertTotal
675− <|> do try (lchar '%' *> reserved "error_handler");
676− return ErrorHandler
677− <|> do try (lchar '%' *> reserved "error_reverse");
678− return ErrorReverse
679− <|> do try (lchar '%' *> reserved "error_reduce");
680− return ErrorReduce
681− <|> do try (lchar '%' *> reserved "reflection");
682− return Reflection
683− <|> do try (lchar '%' *> reserved "hint");
684− return AutoHint
685− <|> do try (lchar '%' *> reserved "overlapping");
686− return OverlappingDictionary
671+ <|> ErrorHandler <$ P.try (lchar '%' *> reserved "error_handler")
672+ <|> ErrorReverse <$ P.try (lchar '%' *> reserved "error_reverse")
673+ <|> ErrorReduce <$ P.try (lchar '%' *> reserved "error_reduce")
674+ <|> Reflection <$ P.try (lchar '%' *> reserved "reflection")
675+ <|> AutoHint <$ P.try (lchar '%' *> reserved "hint")
676+ <|> OverlappingDictionary <$ P.try (lchar '%' *> reserved "overlapping")
687677 <|> do lchar '%'; reserved "specialise";
688− lchar '['; ns <- sepBy nameTimes (lchar ','); lchar ']';
678+ lchar '['; ns <- P.sepBy nameTimes (lchar ','); lchar ']';
689679 return $ Specialise ns
690− <|> do reservedHL "implicit"; return Implicit
680+ <|> Implicit <$ reservedHL "implicit"
691681 <?> "function modifier"
692682 where nameTimes :: IdrisParser (Name, Maybe Int)
693683 nameTimes = do n <- fst <$> fnName
694− t <- option Nothing (do reds <- fmap fst natural
695− return (Just (fromInteger reds)))
684+ t <- P.option Nothing (do reds <- fmap fst natural
685+ return (Just (fromInteger reds)))
696686 return (n, t)
697687
698688{-| Parses a postulate
@@ -705,10 +695,10 @@ Postulate ::=
705695-}
706696postulate :: SyntaxInfo -> IdrisParser PDecl
707697postulate syn = do (doc, ext)
708− <- try $ do (doc, _) <- docstring syn
709− pushIndent
710− ext <- ppostDecl
711− return (doc, ext)
698+ <- P.try $ do (doc, _) <- docstring syn
699+ pushIndent
700+ ext <- ppostDecl
701+ return (doc, ext)
712702 ist <- get
713703 (opts, acc) <- fnOpts
714704 (n_in, nfc) <- fnName
@@ -768,7 +758,7 @@ openInterface syn =
768758 do reservedHL "using"
769759 reservedHL "implementation"
770760 fc <- getFC
771− ns <- sepBy1 fnName (lchar ',')
761+ ns <- P.sepBy1 fnName (lchar ',')
772762
773763 openBlock
774764 ds <- many (decl syn)
@@ -848,14 +838,14 @@ InterfaceBlock ::=
848838interfaceBlock :: SyntaxInfo -> IdrisParser (Maybe (Name, FC), Docstring (Either Err PTerm), [PDecl])
849839interfaceBlock syn = do reservedHL "where"
850840 openBlock
851− (cn, cd) <- option (Nothing, emptyDocstring) $
852− try (do (doc, _) <- option noDocs docComment
853− n <- constructor
854− return (Just n, doc))
841+ (cn, cd) <- P.option (Nothing, emptyDocstring) $
842+ P.try (do (doc, _) <- P.option noDocs docComment
843+ n <- constructor
844+ return (Just n, doc))
855845 ist <- get
856846 let cd' = annotate syn ist cd
857847
858− ds <- many (notEndBlock >> try (implementation True syn)
848+ ds <- many (notEndBlock >> P.try (implementation True syn)
859849 <|> do x <- data_ syn
860850 return [x]
861851 <|> fnDecl syn)
@@ -886,24 +876,24 @@ Interface ::=
886876-}
887877interface_ :: SyntaxInfo -> IdrisParser [PDecl]
888878interface_ syn = do (doc, argDocs, acc)
889− <- try (do (doc, argDocs) <- docstring syn
890− acc <- accessibility
891− interfaceKeyword
892− return (doc, argDocs, acc))
879+ <- P.try (do (doc, argDocs) <- docstring syn
880+ acc <- accessibility
881+ interfaceKeyword
882+ return (doc, argDocs, acc))
893883 fc <- getFC
894884 cons <- constraintList syn
895885 let cons' = [(c, ty) | (_, c, _, ty) <- cons]
896886 (n_in, nfc) <- fnName
897887 let n = expandNS syn n_in
898888 cs <- many carg
899− fds <- option [(cn, NoFC) | (cn, _, _) <- cs] fundeps
900− (cn, cd, ds) <- option (Nothing, fst noDocs, []) (interfaceBlock syn)
889+ fds <- P.option [(cn, NoFC) | (cn, _, _) <- cs] fundeps
890+ (cn, cd, ds) <- P.option (Nothing, fst noDocs, []) (interfaceBlock syn)
901891 accData acc n (concatMap declared ds)
902892 return [PInterface doc syn fc cons' n nfc cs argDocs fds ds cn cd]
903893 <?> "interface declaration"
904894 where
905895 fundeps :: IdrisParser [(Name, FC)]
906− fundeps = do lchar '|'; sepBy name (lchar ',')
896+ fundeps = do lchar '|'; P.sepBy name (lchar ',')
907897
908898 interfaceKeyword :: IdrisParser ()
909899 interfaceKeyword = reservedHL "interface"
@@ -964,7 +954,7 @@ implementation kwopt syn
964954
965955 implementationUsing :: IdrisParser [Name]
966956 implementationUsing = do reservedHL "using"
967− ns <- sepBy1 fnName (lchar ',')
957+ ns <- P.sepBy1 fnName (lchar ',')
968958 return (map fst ns)
969959 <|> return []
970960
@@ -972,7 +962,7 @@ implementation kwopt syn
972962docstring :: SyntaxInfo
973963 -> IdrisParser (Docstring (Either Err PTerm),
974964 [(Name,Docstring (Either Err PTerm))])
975−docstring syn = do (doc, argDocs) <- option noDocs docComment
965+docstring syn = do (doc, argDocs) <- P.option noDocs docComment
976966 ist <- get
977967 let doc' = annotCode (tryFullExpr syn ist) doc
978968 argDocs' = [ (n, annotCode (tryFullExpr syn ist) d)
@@ -1005,8 +995,8 @@ NameList ::=
1005995-}
1006996usingDeclList :: SyntaxInfo -> IdrisParser [Using]
1007997usingDeclList syn
1008− = try (sepBy1 (usingDecl syn) (lchar ','))
1009− <|> do ns <- sepBy1 (fst <$> name) (lchar ',')
998+ = P.try (P.sepBy1 (usingDecl syn) (lchar ','))
999+ <|> do ns <- P.sepBy1 (fst <$> name) (lchar ',')
10101000 lchar ':'
10111001 t <- typeExpr (disallowImp syn)
10121002 return (map (\x -> UImplicit x t) ns)
@@ -1022,10 +1012,10 @@ UsingDecl ::=
10221012@
10231013-}
10241014usingDecl :: SyntaxInfo -> IdrisParser Using
1025−usingDecl syn = try (do x <- fst <$> fnName
1026− lchar ':'
1027− t <- typeExpr (disallowImp syn)
1028− return (UImplicit x t))
1015+usingDecl syn = P.try (do x <- fst <$> fnName
1016+ lchar ':'
1017+ t <- typeExpr (disallowImp syn)
1018+ return (UImplicit x t))
10291019 <|> do c <- fst <$> fnName
10301020 xs <- many (fst <$> fnName)
10311021 return (UConstraint c xs)
@@ -1068,7 +1058,7 @@ ArgExpr ::= HSimpleExpr | {- In Pattern External (User-defined) Expression -};
10681058-}
10691059argExpr :: SyntaxInfo -> IdrisParser PTerm
10701060argExpr syn = let syn' = syn { inPattern = True } in
1071− try (hsimpleExpr syn') <|> simpleExternalExpr syn'
1061+ P.try (hsimpleExpr syn') <|> simpleExternalExpr syn'
10721062 <?> "argument expression"
10731063
10741064{-| Parse a right hand side of a function
@@ -1090,8 +1080,8 @@ rhs syn n = do lchar '='
10901080 expr syn
10911081 <|> do symbol "?=";
10921082 fc <- getFC
1093− name <- option n' (do symbol "{"; n <- fst <$> fnName; symbol "}";
1094− return n)
1083+ name <- P.option n' (do symbol "{"; n <- fst <$> fnName; symbol "}";
1084+ return n)
10951085 r <- expr syn
10961086 return (addLet fc name r)
10971087 <|> impossible
@@ -1135,7 +1125,7 @@ WhereOrTerminator ::= WhereBlock | Terminator;
11351125-}
11361126clause :: SyntaxInfo -> IdrisParser PClause
11371127clause syn
1138− = do wargs <- try (do pushIndent; some (wExpr syn))
1128+ = do wargs <- P.try (do pushIndent; some (wExpr syn))
11391129 fc <- getFC
11401130 ist <- get
11411131 n <- case lastParse ist of
@@ -1143,11 +1133,8 @@ clause syn
11431133 Nothing -> fail "Invalid clause"
11441134 (do r <- rhs syn n
11451135 let wsyn = syn { syn_namespace = [], syn_toplevel = False }
1146− (wheres, nmap) <- choice [do x <- whereBlock n wsyn
1147− popIndent
1148− return x,
1149− do terminator
1150− return ([], [])]
1136+ (wheres, nmap) <- whereBlock n wsyn <* popIndent
1137+ <|> ([], []) <$ terminator
11511138 return $ PClauseR fc wargs r wheres) <|> (do
11521139 popIndent
11531140 reservedHL "with"
@@ -1158,19 +1145,16 @@ clause syn
11581145 let withs = concat ds
11591146 closeBlock
11601147 return $ PWithR fc wargs wval pn withs)
1161− <|> do ty <- try (do pushIndent
1162− ty <- simpleExpr syn
1163− symbol "<=="
1164− return ty)
1148+ <|> do ty <- P.try (do pushIndent
1149+ ty <- simpleExpr syn
1150+ symbol "<=="
1151+ return ty)
11651152 fc <- getFC
11661153 n_in <- fst <$> fnName; let n = expandNS syn n_in
11671154 r <- rhs syn n
11681155 let wsyn = syn { syn_namespace = [] }
1169− (wheres, nmap) <- choice [do x <- whereBlock n wsyn
1170− popIndent
1171− return x,
1172− do terminator
1173− return ([], [])]
1156+ (wheres, nmap) <- whereBlock n wsyn <* popIndent
1157+ <|> ([], []) <$ terminator
11741158 let capp = PLet fc RigW (sMN 0 "match") NoFC
11751159 ty
11761160 (PMatchApp fc n)
@@ -1178,7 +1162,7 @@ clause syn
11781162 ist <- get
11791163 put (ist { lastParse = Just n })
11801164 return $ PClause fc n capp [] r wheres
1181− <|> do (l, op, nfc) <- try (do
1165+ <|> do (l, op, nfc) <- P.try (do
11821166 pushIndent
11831167 l <- argExpr syn
11841168 (op, nfc) <- symbolicOperatorFC
@@ -1191,11 +1175,8 @@ clause syn
11911175 wargs <- many (wExpr syn)
11921176 (do rs <- rhs syn n
11931177 let wsyn = syn { syn_namespace = [] }
1194− (wheres, nmap) <- choice [do x <- whereBlock n wsyn
1195− popIndent
1196− return x,
1197− do terminator
1198− return ([], [])]
1178+ (wheres, nmap) <- whereBlock n wsyn <* popIndent
1179+ <|> ([], []) <$ terminator
11991180 ist <- get
12001181 let capp = PApp fc (PRef nfc [nfc] n) [pexp l, pexp r]
12011182 put (ist { lastParse = Just n })
@@ -1215,18 +1196,15 @@ clause syn
12151196 <|> do pushIndent
12161197 (n_in, nfc) <- fnName; let n = expandNS syn n_in
12171198 fc <- getFC
1218− args <- many (try (implicitArg (syn { inPattern = True } ))
1219− <|> try (constraintArg (syn { inPattern = True }))
1199+ args <- many (P.try (implicitArg (syn { inPattern = True } ))
1200+ <|> P.try (constraintArg (syn { inPattern = True }))
12201201 <|> (fmap pexp (argExpr syn)))
12211202 wargs <- many (wExpr syn)
12221203 let capp = PApp fc (PRef nfc [nfc] n) args
12231204 (do r <- rhs syn n
12241205 let wsyn = syn { syn_namespace = [] }
1225− (wheres, nmap) <- choice [do x <- whereBlock n wsyn
1226− popIndent
1227− return x,
1228− do terminator
1229− return ([], [])]
1206+ (wheres, nmap) <- whereBlock n wsyn <* popIndent
1207+ <|> ([], []) <$ terminator
12301208 ist <- get
12311209 put (ist { lastParse = Just n })
12321210 return $ PClause fc n capp wargs r wheres) <|> (do
@@ -1243,9 +1221,9 @@ clause syn
12431221 return $ PWith fc n capp wargs wval pn withs)
12441222 <?> "function clause"
12451223 where
1246− optProof = option Nothing (do reservedHL "proof"
1247− n <- fnName
1248− return (Just n))
1224+ optProof = P.option Nothing (do reservedHL "proof"
1225+ n <- fnName
1226+ return (Just n))
12491227
12501228 fillLHS :: Name -> PTerm -> [PTerm] -> PClause -> PClause
12511229 fillLHS n capp owargs (PClauseR fc wargs v ws)
@@ -1336,74 +1314,74 @@ Directive' ::= 'lib' CodeGen String_t
13361314@
13371315-}
13381316directive :: SyntaxInfo -> IdrisParser [PDecl]
1339−directive syn = do try (lchar '%' *> reserved "lib")
1317+directive syn = do P.try (lchar '%' *> reserved "lib")
13401318 cgn <- codegen_
13411319 lib <- fmap fst stringLiteral
13421320 return [PDirective (DLib cgn lib)]
1343− <|> do try (lchar '%' *> reserved "link")
1321+ <|> do P.try (lchar '%' *> reserved "link")
13441322 cgn <- codegen_; obj <- fst <$> stringLiteral
13451323 return [PDirective (DLink cgn obj)]
1346− <|> do try (lchar '%' *> reserved "flag")
1324+ <|> do P.try (lchar '%' *> reserved "flag")
13471325 cgn <- codegen_; flag <- fst <$> stringLiteral
13481326 return [PDirective (DFlag cgn flag)]
1349− <|> do try (lchar '%' *> reserved "include")
1327+ <|> do P.try (lchar '%' *> reserved "include")
13501328 cgn <- codegen_
13511329 hdr <- fst <$> stringLiteral
13521330 return [PDirective (DInclude cgn hdr)]
1353− <|> do try (lchar '%' *> reserved "hide"); n <- fst <$> fnName
1331+ <|> do P.try (lchar '%' *> reserved "hide"); n <- fst <$> fnName
13541332 return [PDirective (DHide n)]
1355− <|> do try (lchar '%' *> reserved "freeze"); n <- fst <$> iName []
1333+ <|> do P.try (lchar '%' *> reserved "freeze"); n <- fst <$> iName []
13561334 return [PDirective (DFreeze n)]
1357− <|> do try (lchar '%' *> reserved "thaw"); n <- fst <$> iName []
1335+ <|> do P.try (lchar '%' *> reserved "thaw"); n <- fst <$> iName []
13581336 return [PDirective (DThaw n)]
13591337 -- injectivity assertins are intended for debugging purposes
13601338 -- only, and won't be documented/could be removed at any point
1361− <|> do try (lchar '%' *> reserved "assert_injective"); n <- fst <$> fnName
1339+ <|> do P.try (lchar '%' *> reserved "assert_injective"); n <- fst <$> fnName
13621340 return [PDirective (DInjective n)]
13631341 -- Assert totality of something after definition. This is
13641342 -- here as a debugging aid, so commented out...
1365−-- <|> do try (lchar '%' *> reserved "assert_set_total"); n <- fst <$> fnName
1343+-- <|> do P.try (lchar '%' *> reserved "assert_set_total"); n <- fst <$> fnName
13661344-- return [PDirective (DSetTotal n)]
1367− <|> do try (lchar '%' *> reserved "access")
1345+ <|> do P.try (lchar '%' *> reserved "access")
13681346 acc <- accessibility
13691347 ist <- get
13701348 put ist { default_access = acc }
13711349 return [PDirective (DAccess acc)]
1372− <|> do try (lchar '%' *> reserved "default"); tot <- totality
1350+ <|> do P.try (lchar '%' *> reserved "default"); tot <- totality
13731351 i <- get
13741352 put (i { default_total = tot } )
13751353 return [PDirective (DDefault tot)]
1376− <|> do try (lchar '%' *> reserved "logging")
1354+ <|> do P.try (lchar '%' *> reserved "logging")
13771355 i <- fst <$> natural
13781356 return [PDirective (DLogging i)]
1379− <|> do try (lchar '%' *> reserved "dynamic")
1380− libs <- sepBy1 (fmap fst stringLiteral) (lchar ',')
1357+ <|> do P.try (lchar '%' *> reserved "dynamic")
1358+ libs <- P.sepBy1 (fmap fst stringLiteral) (lchar ',')
13811359 return [PDirective (DDynamicLibs libs)]
1382− <|> do try (lchar '%' *> reserved "name")
1360+ <|> do P.try (lchar '%' *> reserved "name")
13831361 (ty, tyFC) <- fnName
1384− ns <- sepBy1 name (lchar ',')
1362+ ns <- P.sepBy1 name (lchar ',')
13851363 return [PDirective (DNameHint ty tyFC ns)]
1386− <|> do try (lchar '%' *> reserved "error_handlers")
1364+ <|> do P.try (lchar '%' *> reserved "error_handlers")
13871365 (fn, nfc) <- fnName
13881366 (arg, afc) <- fnName
1389− ns <- sepBy1 name (lchar ',')
1367+ ns <- P.sepBy1 name (lchar ',')
13901368 return [PDirective (DErrorHandlers fn nfc arg afc ns) ]
1391− <|> do try (lchar '%' *> reserved "language"); ext <- pLangExt;
1369+ <|> do P.try (lchar '%' *> reserved "language"); ext <- pLangExt;
13921370 return [PDirective (DLanguage ext)]
1393− <|> do try (lchar '%' *> reserved "deprecate")
1371+ <|> do P.try (lchar '%' *> reserved "deprecate")
13941372 n <- fst <$> fnName
1395− alt <- option "" (fst <$> stringLiteral)
1373+ alt <- P.option "" (fst <$> stringLiteral)
13961374 return [PDirective (DDeprecate n alt)]
1397− <|> do try (lchar '%' *> reserved "fragile")
1375+ <|> do P.try (lchar '%' *> reserved "fragile")
13981376 n <- fst <$> fnName
1399− alt <- option "" (fst <$> stringLiteral)
1377+ alt <- P.option "" (fst <$> stringLiteral)
14001378 return [PDirective (DFragile n alt)]
14011379 <|> do fc <- getFC
1402− try (lchar '%' *> reserved "used")
1380+ P.try (lchar '%' *> reserved "used")
14031381 fn <- fst <$> fnName
14041382 arg <- fst <$> iName []
14051383 return [PDirective (DUsed fc fn arg)]
1406− <|> do try (lchar '%' *> reserved "auto_implicits")
1384+ <|> do P.try (lchar '%' *> reserved "auto_implicits")
14071385 b <- on_off
14081386 return [PDirective (DAutoImplicits b)]
14091387 <?> "directive"
@@ -1440,12 +1418,12 @@ ProviderWhat ::= 'proof' | 'term' | 'type' | 'postulate'
14401418@
14411419 -}
14421420provider :: SyntaxInfo -> IdrisParser [PDecl]
1443−provider syn = do doc <- try (do (doc, _) <- docstring syn
1444− fc1 <- getFC
1445− lchar '%'
1446− fc2 <- reservedFC "provide"
1447− highlightP (spanFC fc1 fc2) AnnKeyword
1448− return doc)
1421+provider syn = do doc <- P.try (do (doc, _) <- docstring syn
1422+ fc1 <- getFC
1423+ lchar '%'
1424+ fc2 <- reservedFC "provide"
1425+ highlightP (spanFC fc1 fc2) AnnKeyword
1426+ return doc)
14491427 provideTerm doc <|> providePostulate doc
14501428 <?> "type provider"
14511429 where provideTerm doc =
@@ -1469,7 +1447,7 @@ Transform ::= '%' 'transform' Expr '==>' Expr
14691447@
14701448-}
14711449transform :: SyntaxInfo -> IdrisParser [PDecl]
1472−transform syn = do try (lchar '%' *> reserved "transform")
1450+transform syn = do P.try (lchar '%' *> reserved "transform")
14731451 -- leave it unchecked, until we work out what this should
14741452 -- actually mean...
14751453-- safety <- option True (do reserved "unsafe"
@@ -1489,10 +1467,10 @@ RunElabDecl ::= '%' 'runElab' Expr
14891467-}
14901468runElabDecl :: SyntaxInfo -> IdrisParser PDecl
14911469runElabDecl syn =
1492− do kwFC <- try (do fc <- getFC
1493− lchar '%'
1494− fc' <- reservedFC "runElab"
1495− return (spanFC fc fc'))
1470+ do kwFC <- P.try (do fc <- getFC
1471+ lchar '%'
1472+ fc' <- reservedFC "runElab"
1473+ return (spanFC fc fc'))
14961474 script <- expr syn <?> "elaborator script"
14971475 highlightP kwFC AnnKeyword
14981476 return $ PRunElabDecl kwFC script (syn_namespace syn)
@@ -1500,19 +1478,19 @@ runElabDecl syn =
15001478
15011479{- * Loading and parsing -}
15021480{-| Parses an expression from input -}
1503−parseExpr :: IState -> String -> Result PTerm
1481+parseExpr :: IState -> String -> P.Result PTerm
15041482parseExpr st = runparser (fullExpr defaultSyntax) st "(input)"
15051483
15061484{-| Parses a constant form input -}
1507−parseConst :: IState -> String -> Result Const
1485+parseConst :: IState -> String -> P.Result Const
15081486parseConst st = runparser (fmap fst constant) st "(input)"
15091487
15101488{-| Parses a tactic from input -}
1511−parseTactic :: IState -> String -> Result PTactic
1489+parseTactic :: IState -> String -> P.Result PTactic
15121490parseTactic st = runparser (fullTactic defaultSyntax) st "(input)"
15131491
15141492{-| Parses a do-step from input (used in the elab shell) -}
1515−parseElabShellStep :: IState -> String -> Result (Either ElabShellCmd PDo)
1493+parseElabShellStep :: IState -> String -> P.Result (Either ElabShellCmd PDo)
15161494parseElabShellStep ist = runparser (fmap Right (do_ defaultSyntax) <|> fmap Left elabShellCmd) ist "(input)"
15171495 where elabShellCmd = char ':' >>
15181496 (reserved "qed" >> pure EQED ) <|>
@@ -1525,7 +1503,7 @@ parseElabShellStep ist = runparser (fmap Right (do_ defaultSyntax) <|> fmap Left
15251503 (expressionTactic ["search"] ESearch ) <|>
15261504 (do reserved "doc"
15271505 doc <- (Right . fst <$> constant) <|> (Left . fst <$> fnName)
1528− eof
1506+ P.eof
15291507 return (EDocStr doc))
15301508 <?> "elab command"
15311509 expressionTactic cmds tactic =
@@ -1536,26 +1514,26 @@ parseElabShellStep ist = runparser (fmap Right (do_ defaultSyntax) <|> fmap Left
15361514 spaced parser = indentGt *> parser
15371515
15381516-- | Parse module header and imports
1539−parseImports :: FilePath -> String -> Idris (Maybe (Docstring ()), [String], [ImportInfo], Maybe Delta)
1517+parseImports :: FilePath -> String -> Idris (Maybe (Docstring ()), [String], [ImportInfo], Maybe P.Delta)
15401518parseImports fname input
15411519 = do i <- getIState
1542− case parseString (runInnerParser (evalStateT imports i)) (Directed (UTF8.fromString fname) 0 0 0 0) input of
1543− Failure (ErrInfo err _) -> ifail $ show err
1544− Success (x, annots, i) ->
1520+ case P.parseString (runInnerParser (evalStateT imports i)) (P.Directed (UTF8.fromString fname) 0 0 0 0) input of
1521+ P.Failure (P.ErrInfo err _) -> ifail $ show err
1522+ P.Success (x, annots, i) ->
15451523 do putIState i
15461524 fname' <- runIO $ Dir.makeAbsolute fname
15471525 sendHighlighting $ addPath annots fname'
15481526 return x
15491527 where imports :: IdrisParser ((Maybe (Docstring ()), [String],
15501528 [ImportInfo],
1551− Maybe Delta),
1529+ Maybe P.Delta),
15521530 [(FC, OutputAnnotation)], IState)
15531531 imports = do optional shebang
15541532 whiteSpace
15551533 (mdoc, mname, annots) <- moduleHeader
15561534 ps_exp <- many import_
1557− mrk <- mark
1558− isEof <- lookAheadMatches eof
1535+ mrk <- P.mark
1536+ isEof <- lookAheadMatches P.eof
15591537 let mrk' = if isEof
15601538 then Nothing
15611539 else Just mrk
@@ -1572,7 +1550,7 @@ parseImports fname input
15721550 addPath (annot:annots) path = annot : addPath annots path
15731551
15741552 shebang :: IdrisParser ()
1575− shebang = string "#!" *> many (satisfy $ not . isEol) *> eol *> pure ()
1553+ shebang = string "#!" *> many (P.satisfy $ not . isEol) *> eol *> pure ()
15761554
15771555-- | There should be a better way of doing this...
15781556findFC :: Doc -> (FC, String)
@@ -1596,12 +1574,12 @@ fixColour True doc = doc
15961574
15971575-- | A program is a list of declarations, possibly with associated
15981576-- documentation strings.
1599−parseProg :: SyntaxInfo -> FilePath -> String -> Maybe Delta ->
1577+parseProg :: SyntaxInfo -> FilePath -> String -> Maybe P.Delta ->
16001578 Idris [PDecl]
16011579parseProg syn fname input mrk
16021580 = do i <- getIState
16031581 case runparser mainProg i fname input of
1604− Failure (ErrInfo doc _) -> do -- FIXME: Get error location from trifecta
1582+ P.Failure (P.ErrInfo doc _) -> do -- FIXME: Get error location from trifecta
16051583 -- this can't be the solution!
16061584 -- Issue #1575 on the issue tracker.
16071585 -- https://github.com/idris-lang/Idris-dev/issues/1575
@@ -1609,17 +1587,17 @@ parseProg syn fname input mrk
16091587 i <- getIState
16101588 case idris_outputmode i of
16111589 RawOutput h -> iputStrLn (show $ fixColour (idris_colourRepl i) doc)
1612− IdeMode n h -> iWarn fc (P.text msg)
1590+ IdeMode n h -> iWarn fc (Util.Pretty.text msg)
16131591 putIState (i { errSpan = Just fc })
16141592 return []
1615− Success (x, i) -> do putIState i
1616− reportParserWarnings
1617− return $ collect x
1593+ P.Success (x, i) -> do putIState i
1594+ reportParserWarnings
1595+ return $ collect x
16181596 where mainProg :: IdrisParser ([PDecl], IState)
16191597 mainProg = case mrk of
16201598 Nothing -> do i <- get; return ([], i)
16211599 Just mrk -> do
1622− release mrk
1600+ P.release mrk
16231601 ds <- prog syn
16241602 i' <- get
16251603 return (ds, i')