on master help sign in
Merge pull request #4170 from eraserhd/megaparsec

Megaparsec

commit774d1b609611bdb43c429f42923e60130c5a1817 authorNiklas Larsson <metaniklas@gmail.com> dateFri 3 Nov 2017, 08:54 (9 years ago) parent59d5c55edfc5e3
17 files changed+380−431
CHANGELOG.md+5 appveyor.yml+2−2 idris.cabal+4−2 src/Idris/AbsSyntaxTree.hs+1−2 src/Idris/IdeMode.hs+12−11 src/Idris/Package/Parser.hs+16−32 src/Idris/Parser.hs+18−19 src/Idris/Parser/Data.hs+4−4 src/Idris/Parser/Expr.hs+15−16 src/Idris/Parser/Helpers.hs+95−140 src/Idris/Parser/Ops.hs+26−24 src/Idris/REPL/Parser.hs+70−69 test/interactive010/expected+14−10 test/layout001/expected+67−70 test/pkg004/expected+6−5 test/pkg004/test.ipkg+1−1 test/regression002/expected+24−24
CHANGELOG.md+5
@@ -45,6 +45,7 @@
4545 * Generalised many combinators to use an unknown `commit` flag where possible.
4646
4747## Tool Updates
48+
4849+ Private functions are no longer visible in the REPL except for modules
4950 that are explicitly loaded.
5051+ The --interface option now creates CommonJS modules on the node backend.
@@ -52,8 +53,12 @@
5253 as they were given in the source files.
5354+ Backslash, braces and percent symbols are now correctly pretty printed
5455 in LaTeX.
56++ Parse errors have a new format, similar to GHC 8.2's default, due to a
57+ switch from Trifecta to Megaparsec for parsing. This could possibly cause
58+ some subtle deviations in parsing from previous versions of Idris.
5559
5660## Packaging Updates
61+
5762+ Package names now only accept a restrictive charset of letters, numbers and the `-_` characters.
5863 Package names are also case insensitive
5964
appveyor.yml+2−2
@@ -5,13 +5,13 @@ init:
55
66 mkdir C:\ghc
77
8− Invoke-WebRequest "http://downloads.haskell.org/~ghc/7.10.3/ghc-7.10.3-x86_64-unknown-mingw32.tar.xz" -OutFile C:\ghc\ghc.tar.xz -UserAgent "Curl"
8+ Invoke-WebRequest "http://downloads.haskell.org/~ghc/8.2.1/ghc-8.2.1-x86_64-unknown-mingw32.tar.xz" -OutFile C:\ghc\ghc.tar.xz -UserAgent "Curl"
99
1010 7z x C:\ghc\ghc.tar.xz -oC:\ghc
1111
1212 7z x C:\ghc\ghc.tar -oC:\ghc
1313
14− $env:PATH="$env:PATH;c:\ghc\ghc-7.10.3\bin;$HOME\AppData\Roaming\cabal\bin"
14+ $env:PATH="$env:PATH;c:\ghc\ghc-8.2.1\bin;$HOME\AppData\Roaming\cabal\bin"
1515
1616 cabal update
1717
idris.cabal+4−2
@@ -286,10 +286,10 @@ Library
286286 , fingertree >= 0.1 && < 0.2
287287 , haskeline >= 0.7 && < 0.8
288288 , ieee754 >= 0.7 && < 0.9
289+ , megaparsec >= 6.2 && <6.3
289290 , mtl >= 2.1 && < 2.3
290291 , network < 2.7
291292 , optparse-applicative >= 0.13 && < 0.15
292− , parsers >= 0.9 && < 0.13
293293 , pretty < 1.2
294294 , process < 1.7
295295 , regex-tdfa >= 1.2
@@ -300,7 +300,6 @@ Library
300300 , time >= 1.4 && < 1.9
301301 , transformers < 0.6
302302 , transformers-compat >= 0.3
303− , trifecta >= 1.6 && < 1.8
304303 , uniplate >=1.6 && < 1.7
305304 , unordered-containers < 0.3
306305 , utf8-string < 1.1
@@ -310,6 +309,9 @@ Library
310309 , fsnotify >= 0.2 && < 2.2
311310 , async < 2.2
312311
312+ if !impl(ghc >= 8.0)
313+ Build-Depends: semigroups == 0.18.*
314+
313315 Default-Language: Haskell2010
314316 ghc-prof-options: -auto-all -caf-all
315317
src/Idris/AbsSyntaxTree.hs+1−2
@@ -269,7 +269,6 @@ data IState = IState {
269269 , lastParse :: Maybe Name
270270 , indent_stack :: [Int]
271271 , brace_stack :: [Maybe Int]
272− , lastTokenSpan :: Maybe FC -- ^ What was the span of the latest token parsed?
273272 , idris_parsedSpan :: Maybe FC
274273 , hide_list :: Ctxt Accessibility
275274 , default_access :: Accessibility
@@ -407,7 +406,7 @@ idrisInit = IState initContext S.empty []
407406 emptyContext emptyContext emptyContext emptyContext
408407 emptyContext
409408 [] [] [] defaultOpts 6 [] [] [] [] [] emptySyntaxRules [] [] [] [] [] [] []
410− [] [] Nothing [] Nothing [] [] Nothing Nothing emptyContext Private DefaultCheckingPartial [] Nothing [] []
409+ [] [] Nothing [] Nothing [] [] Nothing emptyContext Private DefaultCheckingPartial [] Nothing [] []
411410 (RawOutput stdout) True defaultTheme [] (0, emptyContext) emptyContext M.empty
412411 AutomaticWidth S.empty S.empty [] [] [] M.empty [] [] []
413412 emptyContext S.empty M.empty emptyContext initialInteractiveOpts
src/Idris/IdeMode.hs+12−11
@@ -15,6 +15,7 @@ import Idris.Core.Binary ()
1515import Idris.Core.TT
1616
1717import Control.Applicative hiding (Const)
18+import Control.Arrow (left)
1819import qualified Data.Binary as Binary
1920import qualified Data.ByteString.Base64 as Base64
2021import qualified Data.ByteString.Lazy as Lazy
@@ -24,9 +25,9 @@ import Data.Maybe (isJust)
2425import qualified Data.Text as T
2526import Numeric
2627import System.IO
28+import qualified Text.Megaparsec as P
29+import qualified Text.Megaparsec.Char as P
2730import Text.Printf
28−import qualified Text.Trifecta as P
29−import qualified Text.Trifecta.Delta as P
3031
3132getNChar :: Handle -> Int -> String -> IO (String)
3233getNChar _ 0 s = return (reverse s)
@@ -205,28 +206,31 @@ escape = concatMap escapeChar
205206 escapeChar '"' = "\\\""
206207 escapeChar c = [c]
207208
208−pSExp = SexpList <$> P.between (P.char '(') (P.char ')') (pSExp `P.sepBy` (P.char ' '))
209+type Parser a = P.Parsec () String a
210+
211+sexp :: Parser SExp
212+sexp = SexpList <$> P.between (P.char '(') (P.char ')') (sexp `P.sepBy` (P.char ' '))
209213 <|> atom
210214
215+atom :: Parser SExp
211216atom = SexpList [] <$ P.string "nil"
212217 <|> P.char ':' *> atomC
213218 <|> StringAtom <$> P.between (P.char '"') (P.char '"') (P.many quotedChar)
214− <|> do ints <- some P.digit
219+ <|> do ints <- some P.digitChar
215220 case readDec ints of
216221 ((num, ""):_) -> return (IntegerAtom (toInteger num))
217222 _ -> return (StringAtom ints)
218223
224+atomC :: Parser SExp
219225atomC = BoolAtom True <$ P.string "True"
220226 <|> BoolAtom False <$ P.string "False"
221227 <|> SymbolAtom <$> many (P.noneOf " \n\t\r\"()")
222228
229+quotedChar :: Parser Char
223230quotedChar = P.try ('\\' <$ P.string "\\\\")
224231 <|> P.try ('"' <$ P.string "\\\"")
225232 <|> P.noneOf "\""
226233
227−parseSExp :: String -> P.Result SExp
228−parseSExp = P.parseString pSExp (P.Directed (UTF8.fromString "(unknown)") 0 0 0 0)
229−
230234data Opt = ShowImpl | ErrContext deriving Show
231235
232236data WhatDocs = Overview | Full
@@ -321,10 +325,7 @@ parseMessage x = case receiveString x of
321325 Left err -> Left err
322326
323327receiveString :: String -> Either Err SExp
324−receiveString x =
325− case parseSExp x of
326− P.Failure _ -> Left . Msg $ "parse failure"
327− P.Success r -> Right r
328+receiveString = left (const $ Msg "parse failure") . P.parse sexp "(unknown)"
328329
329330convSExp :: SExpable a => String -> a -> Integer -> String
330331convSExp pre s id =
src/Idris/Package/Parser.hs+16−32
@@ -5,15 +5,16 @@ Copyright :
55License : BSD3
66Maintainer : The Idris Community.
77-}
8−{-# LANGUAGE CPP, ConstraintKinds, FlexibleInstances, TypeSynonymInstances #-}
8+{-# LANGUAGE FlexibleContexts #-}
99module Idris.Package.Parser where
1010
1111import Idris.CmdOptions
1212import Idris.Imports
1313import Idris.Package.Common
14−import Idris.Parser.Helpers (MonadicParsing, eol, iName, identifier, isEol,
15− lchar, packageName, parseErrorDoc, reserved,
16− runparser, someSpace')
14+import Idris.Parser.Helpers (IdrisInnerParser, MonadicParsing, eol, iName,
15+ identifier, isEol, lchar, packageName,
16+ parseErrorDoc, reserved, runparser, someSpace,
17+ stringLiteral)
1718
1819import Control.Applicative
1920import Control.Monad.State.Strict
@@ -21,29 +22,12 @@ import Data.List (union)
2122import System.Directory (doesFileExist)
2223import System.Exit
2324import System.FilePath (isValid, takeExtension, takeFileName)
25+import Text.Megaparsec ((<?>))
26+import qualified Text.Megaparsec as P
27+import qualified Text.Megaparsec.Char as P
2428import qualified Text.PrettyPrint.ANSI.Leijen as PP
25−import Text.Trifecta ((<?>))
26−import qualified Text.Trifecta as P
27−
28−type PParser = StateT PkgDesc P.Parser
29−
30−#if MIN_VERSION_base(4,9,0)
31−instance {-# OVERLAPPING #-} P.DeltaParsing PParser where
32− line = lift P.line
33− {-# INLINE line #-}
34− position = lift P.position
35− {-# INLINE position #-}
36− slicedWith f (StateT m) = StateT $ \s -> P.slicedWith (\(a,s') b -> (f a b, s')) $ m s
37− {-# INLINE slicedWith #-}
38− rend = lift P.rend
39− {-# INLINE rend #-}
40− restOfLine = lift P.restOfLine
41− {-# INLINE restOfLine #-}
42−#endif
43−
44−instance {-# OVERLAPPING #-} P.TokenParsing PParser where
45− someSpace = someSpace'
4629
30+type PParser = StateT PkgDesc IdrisInnerParser
4731
4832parseDesc :: FilePath -> IO PkgDesc
4933parseDesc fp = do
@@ -65,7 +49,7 @@ pPkg :: PParser PkgDesc
6549pPkg = do
6650 reserved "package"
6751 p <- pPkgName
68− someSpace'
52+ someSpace
6953 modify $ \st -> st { pkgname = p }
7054 some pClause
7155 st <- get
@@ -84,7 +68,7 @@ filename = (do
8468 -- This also moves away from tying filenames to identifiers, so
8569 -- it will also accept hyphens
8670 -- (https://github.com/idris-lang/Idris-dev/issues/2721)
87− filename <- P.stringLiteral <* someSpace'
71+ filename <- fst <$> stringLiteral
8872 -- Through at least version 0.9.19.1, IPKG executable values were
8973 -- possibly namespaced identifiers, like foo.bar.baz.
9074 <|> show . fst <$> iName []
@@ -116,10 +100,10 @@ filename = (do
116100 "filename must contain no directory component"
117101
118102textUntilEol :: MonadicParsing m => m String
119−textUntilEol = many (P.satisfy (not . isEol)) <* eol <* someSpace'
103+textUntilEol = many (P.satisfy (not . isEol)) <* eol <* someSpace
120104
121105clause :: String -> PParser a -> (PkgDesc -> a -> PkgDesc) -> PParser ()
122−clause name p f = do value <- reserved name *> lchar '=' *> p <* someSpace'
106+clause name p f = do value <- reserved name *> lchar '=' *> p <* someSpace
123107 modify $ \st -> f st value
124108
125109commaSep :: MonadicParsing m => m a -> m [a]
@@ -129,8 +113,8 @@ pClause :: PParser ()
129113pClause = clause "executable" filename (\st v -> st { execout = Just v })
130114 <|> clause "main" (fst <$> iName []) (\st v -> st { idris_main = Just v })
131115 <|> clause "sourcedir" (fst <$> identifier) (\st v -> st { sourcedir = v })
132− <|> clause "opts" (pureArgParser . words <$> P.stringLiteral) (\st v -> st { idris_opts = v ++ idris_opts st })
133− <|> clause "pkgs" (commaSep (pPkgName <* someSpace')) (\st ps ->
116+ <|> clause "opts" (pureArgParser . words . fst <$> stringLiteral) (\st v -> st { idris_opts = v ++ idris_opts st })
117+ <|> clause "pkgs" (commaSep (pPkgName <* someSpace)) (\st ps ->
134118 let pkgs = pureArgParser $ concatMap (\x -> ["-p", show x]) ps
135119 in st { pkgdeps = ps `union` pkgdeps st
136120 , idris_opts = pkgs ++ idris_opts st })
@@ -145,6 +129,6 @@ pClause = clause "executable" filename (\st v -> st { execout = Just v })
145129 <|> clause "homepage" textUntilEol (\st v -> st { pkghomepage = Just v })
146130 <|> clause "sourceloc" textUntilEol (\st v -> st { pkgsourceloc = Just v })
147131 <|> clause "bugtracker" textUntilEol (\st v -> st { pkgbugtracker = Just v })
148− <|> clause "brief" P.stringLiteral (\st v -> st { pkgbrief = Just v })
132+ <|> clause "brief" (fst <$> stringLiteral) (\st v -> st { pkgbrief = Just v })
149133 <|> clause "author" textUntilEol (\st v -> st { pkgauthor = Just v })
150134 <|> clause "maintainer" textUntilEol (\st v -> st { pkgmaintainer = Just v })
src/Idris/Parser.hs+18−19
@@ -44,12 +44,12 @@ import Prelude hiding (pi)
4444import Control.Applicative hiding (Const)
4545import Control.Monad
4646import Control.Monad.State.Strict
47−import qualified Data.ByteString.UTF8 as UTF8
4847import Data.Char
4948import Data.Foldable (asum)
5049import Data.Function
5150import Data.Generics.Uniplate.Data (descendM)
5251import Data.List
52+import qualified Data.List.NonEmpty as NonEmpty
5353import qualified Data.List.Split as Spl
5454import qualified Data.Map as M
5555import Data.Maybe
@@ -57,10 +57,10 @@ import Data.Ord
5757import qualified Data.Text as T
5858import qualified System.Directory as Dir (makeAbsolute)
5959import System.FilePath
60+import Text.Megaparsec ((<?>))
61+import qualified Text.Megaparsec as P
62+import qualified Text.Megaparsec.Char as P
6063import qualified Text.PrettyPrint.ANSI.Leijen as PP
61−import Text.Trifecta ((<?>))
62−import qualified Text.Trifecta as P
63−import qualified Text.Trifecta.Delta as P
6464
6565{-
6666@
@@ -433,20 +433,20 @@ syntaxRule syn
433433 reservedHL "syntax"
434434 return sty)
435435 syms <- some syntaxSym
436− when (all isExpr syms) $ P.unexpected "missing keywords in syntax rule"
436+ when (all isExpr syms) $ P.unexpected . P.Label . NonEmpty.fromList $ "missing keywords in syntax rule"
437437 let ns = mapMaybe getName syms
438438 when (length ns /= length (nub ns))
439− $ P.unexpected "repeated variable in syntax rule"
439+ $ P.unexpected . P.Label . NonEmpty.fromList $ "repeated variable in syntax rule"
440440 lchar '='
441441 tm <- typeExpr (allowImp syn) >>= uniquifyBinders [n | Binding n <- syms]
442442 terminator
443443 return (Rule (mkSimple syms) tm sty)
444444 <|> do reservedHL "decl"; reservedHL "syntax"
445445 syms <- some syntaxSym
446− when (all isExpr syms) $ P.unexpected "missing keywords in syntax rule"
446+ when (all isExpr syms) $ P.unexpected . P.Label . NonEmpty.fromList $ "missing keywords in syntax rule"
447447 let ns = mapMaybe getName syms
448448 when (length ns /= length (nub ns))
449− $ P.unexpected "repeated variable in syntax rule"
449+ $ P.unexpected . P.Label . NonEmpty.fromList $ "repeated variable in syntax rule"
450450 lchar '='
451451 openBlock
452452 dec <- some (decl syn)
@@ -577,7 +577,7 @@ fnDecl syn = P.try (do notEndBlock
577577@
578578-}
579579fnDecl' :: SyntaxInfo -> IdrisParser PDecl
580−fnDecl' syn = checkDeclFixity $
580+fnDecl' syn = (checkDeclFixity $
581581 do (doc, argDocs, fc, opts', n, nfc, acc) <- P.try (do
582582 pushIndent
583583 (doc, argDocs) <- docstring syn
@@ -595,7 +595,7 @@ fnDecl' syn = checkDeclFixity $
595595 return (PTy doc argDocs syn fc opts' n nfc ty)
596596 <|> postulate syn
597597 <|> caf syn
598− <|> pattern syn
598+ <|> pattern syn)
599599 <?> "function declaration"
600600
601601{-| Parses a series of function and accessbility options
@@ -1513,25 +1513,25 @@ parseElabShellStep ist = runparser (Right <$> do_ defaultSyntax <|> Left <$> ela
15131513 spaced parser = indentGt *> parser
15141514
15151515-- | Parse module header and imports
1516−parseImports :: FilePath -> String -> Idris (Maybe (Docstring ()), [String], [ImportInfo], Maybe P.Delta)
1516+parseImports :: FilePath -> String -> Idris (Maybe (Docstring ()), [String], [ImportInfo], Maybe ParseState)
15171517parseImports fname input
15181518 = do i <- getIState
1519− case P.parseString (evalStateT imports i) (P.Directed (UTF8.fromString fname) 0 0 0 0) input of
1520− P.Failure (P.ErrInfo err _) -> ifail $ show err
1521− P.Success (x, annots, i) ->
1519+ case runparser imports i fname input of
1520+ Left err -> ifail . show . parseErrorDoc $ err
1521+ Right (x, annots, i) ->
15221522 do putIState i
15231523 fname' <- runIO $ Dir.makeAbsolute fname
15241524 sendHighlighting $ addPath annots fname'
15251525 return x
15261526 where imports :: IdrisParser ((Maybe (Docstring ()), [String],
15271527 [ImportInfo],
1528− Maybe P.Delta),
1528+ Maybe ParseState),
15291529 [(FC, OutputAnnotation)], IState)
15301530 imports = do optional shebang
15311531 whiteSpace
15321532 (mdoc, mname, annots) <- moduleHeader
15331533 ps_exp <- many import_
1534− mrk <- P.mark
1534+ mrk <- P.getParserState
15351535 isEof <- lookAheadMatches P.eof
15361536 let mrk' = if isEof
15371537 then Nothing
@@ -1573,8 +1573,7 @@ fixColour True doc = doc
15731573
15741574-- | A program is a list of declarations, possibly with associated
15751575-- documentation strings.
1576−parseProg :: SyntaxInfo -> FilePath -> String -> Maybe P.Delta ->
1577− Idris [PDecl]
1576+parseProg :: SyntaxInfo -> FilePath -> String -> Maybe ParseState -> Idris [PDecl]
15781577parseProg syn fname input mrk
15791578 = do i <- getIState
15801579 case runparser mainProg i fname input of
@@ -1596,7 +1595,7 @@ parseProg syn fname input mrk
15961595 mainProg = case mrk of
15971596 Nothing -> do i <- get; return ([], i)
15981597 Just mrk -> do
1599− P.release mrk
1598+ P.setParserState mrk
16001599 ds <- prog syn
16011600 i' <- get
16021601 return (ds, i')
src/Idris/Parser/Data.hs+4−4
@@ -22,8 +22,8 @@ import Control.Applicative
2222import Control.Monad.State.Strict
2323import Data.List
2424import Data.Maybe
25−import Text.Trifecta ((<?>))
26−import qualified Text.Trifecta as P
25+import Text.Megaparsec ((<?>))
26+import qualified Text.Megaparsec as P
2727
2828{- | Parses a record type declaration
2929Record ::=
@@ -169,7 +169,7 @@ SimpleConstructorList ::=
169169 ;
170170-}
171171data_ :: SyntaxInfo -> IdrisParser PDecl
172−data_ syn = checkDeclFixity $
172+data_ syn = (checkDeclFixity $
173173 do (doc, argDocs, acc, dataOpts) <- P.try (do
174174 (doc, argDocs) <- P.option noDocs docComment
175175 pushIndent
@@ -219,7 +219,7 @@ data_ syn = checkDeclFixity $
219219 accData acc tyn (map (\ (_, _, n, _, _, _, _) -> n) cons')
220220 return $ PData doc argDocs syn fc dataOpts (PDatadecl tyn nfc ty cons'))
221221 terminator
222− return d)
222+ return d))
223223 <?> "data type declaration"
224224 where
225225 mkPApp :: FC -> PTerm -> [PTerm] -> PTerm
src/Idris/Parser/Expr.hs+15−16
@@ -5,8 +5,7 @@ Copyright :
55License : BSD3
66Maintainer : The Idris Community.
77-}
8−{-# LANGUAGE ConstraintKinds, GeneralizedNewtypeDeriving, PatternGuards,
9− TupleSections #-}
8+{-# LANGUAGE FlexibleContexts, TupleSections #-}
109module Idris.Parser.Expr where
1110
1211import Idris.AbsSyntax
@@ -25,9 +24,10 @@ import Control.Monad.State.Strict
2524import Data.Function (on)
2625import Data.List
2726import Data.Maybe
28−import Text.Parser.Expression
29−import Text.Trifecta ((<?>))
30−import qualified Text.Trifecta as P
27+import Text.Megaparsec ((<?>))
28+import qualified Text.Megaparsec as P
29+import qualified Text.Megaparsec.Char as P
30+import qualified Text.Megaparsec.Expr as P
3131
3232-- | Allow implicit type declarations
3333allowImp :: SyntaxInfo -> SyntaxInfo
@@ -76,8 +76,7 @@ expr = pi
7676-}
7777opExpr :: SyntaxInfo -> IdrisParser PTerm
7878opExpr syn = do i <- get
79− buildExpressionParser (table (idris_infixes i))
80− (expr' syn)
79+ P.makeExprParser (expr' syn) (table (idris_infixes i))
8180
8281{- | Parses either an internally defined expression or
8382 a user-defined one
@@ -1283,9 +1282,9 @@ ExprList ::=
12831282listExpr :: SyntaxInfo -> IdrisParser PTerm
12841283listExpr syn = do (FC f (l, c) _) <- getFC
12851284 lchar '['; fc <- getFC;
1286− (P.try . P.token $ do (char ']' <?> "end of list expression")
1287− (FC _ _ (l', c')) <- getFC
1288− return (mkNil (FC f (l, c) (l', c'))))
1285+ (P.try . token $ do (char ']' <?> "end of list expression")
1286+ (FC _ _ (l', c')) <- getFC
1287+ return (mkNil (FC f (l, c) (l', c'))))
12891288 <|> (do x <- expr (syn { withAppAllowed = False }) <?> "expression"
12901289 (do P.try (lchar '|') <?> "list comprehension"
12911290 qs <- P.sepBy1 (do_ syn) (lchar ',')
@@ -1466,12 +1465,12 @@ VerbatimString_t ::=
14661465;
14671466@
14681467 -}
1469−verbatimStringLiteral :: MonadicParsing m => m (String, FC)
1470−verbatimStringLiteral = P.token $ do (FC f start _) <- getFC
1471− P.try $ string "\"\"\""
1472− str <- P.manyTill P.anyChar $ P.try (string "\"\"\"")
1473− (FC _ _ end) <- getFC
1474− return (str, FC f start end)
1468+verbatimStringLiteral :: IdrisParser (String, FC)
1469+verbatimStringLiteral = token $ do (FC f start _) <- getFC
1470+ P.try $ string "\"\"\""
1471+ str <- P.manyTill P.anyChar $ P.try (string "\"\"\"")
1472+ (FC _ _ end) <- getFC
1473+ return (str, FC f start end)
14751474
14761475{- | Parses a static modifier
14771476
src/Idris/Parser/Helpers.hs+95−140
@@ -5,9 +5,7 @@ Copyright :
55License : BSD3
66Maintainer : The Idris Community.
77-}
8−{-# LANGUAGE CPP, ConstraintKinds, FlexibleInstances,
9− GeneralizedNewtypeDeriving, PatternGuards, StandaloneDeriving,
10− TypeSynonymInstances #-}
8+{-# LANGUAGE ConstraintKinds, FlexibleContexts #-}
119module Idris.Parser.Helpers where
1210
1311import Idris.AbsSyntax
@@ -23,71 +21,58 @@ import Prelude hiding (pi)
2321import Control.Applicative
2422import Control.Monad
2523import Control.Monad.State.Strict
26−import qualified Data.ByteString.UTF8 as UTF8
2724import Data.Char
2825import qualified Data.HashSet as HS
2926import Data.List
27+import qualified Data.List.NonEmpty as NonEmpty
3028import qualified Data.Map as M
3129import Data.Maybe
3230import qualified Data.Text as T
31+import Data.Void (Void(..))
3332import System.FilePath
34−import qualified Text.Parser.Char as Chr
35−import Text.Parser.LookAhead
36−import qualified Text.Parser.Token as Tok
33+import Text.Megaparsec ((<?>))
34+import qualified Text.Megaparsec as P
35+import qualified Text.Megaparsec.Char as P
36+import qualified Text.Megaparsec.Char.Lexer as P hiding (space)
3737import qualified Text.PrettyPrint.ANSI.Leijen as PP
38−import Text.Trifecta ((<?>))
39−import qualified Text.Trifecta as P
40−import qualified Text.Trifecta.Delta as P
38+
4139
4240-- | Idris parser with state used during parsing
43−type IdrisParser = StateT IState P.Parser
44−
45−#if MIN_VERSION_base(4,9,0)
46−instance {-# OVERLAPPING #-} P.DeltaParsing IdrisParser where
47− line = lift P.line
48− {-# INLINE line #-}
49− position = lift P.position
50− {-# INLINE position #-}
51− slicedWith f (StateT m) = StateT $ \s -> P.slicedWith (\(a,s') b -> (f a b, s')) $ m s
52− {-# INLINE slicedWith #-}
53− rend = lift P.rend
54− {-# INLINE rend #-}
55− restOfLine = lift P.restOfLine
56− {-# INLINE restOfLine #-}
57−#endif
58−
59−someSpace' :: MonadicParsing m => m ()
60−someSpace' = many (simpleWhiteSpace <|> singleLineComment <|> multiLineComment) *> pure ()
61−
62−instance {-# OVERLAPPING #-} P.TokenParsing IdrisParser where
63− someSpace = someSpace'
64− token p = do s <- get
65− (FC fn (sl, sc) _) <- getFC --TODO: Update after fixing getFC
66− -- See Issue #1594
67− r <- p
68− (FC fn _ (el, ec)) <- getFC
69− whiteSpace
70− put (s { lastTokenSpan = Just (FC fn (sl, sc) (el, ec)) })
71− return r
41+type IdrisParser = StateT IState IdrisInnerParser
42+type IdrisInnerParser = P.Parsec Void String
43+type ParseState = P.State String
44+data ParseError = ParseError String (P.ParseError (P.Token String) Void)
45+
46+parseErrorPretty :: ParseError -> String
47+parseErrorPretty (ParseError s err) = P.parseErrorPretty' s err
48+
49+parseErrorDoc :: ParseError -> PP.Doc
50+parseErrorDoc = PP.string . parseErrorPretty
7251
7352-- | Generalized monadic parsing constraint type
74−type MonadicParsing m = (P.DeltaParsing m, LookAheadParsing m, Monad m)
53+type MonadicParsing m = (P.MonadParsec Void String m)
7554
76−class HasLastTokenSpan m where
77− getLastTokenSpan :: m (Maybe FC)
55+someSpace :: MonadicParsing m => m ()
56+someSpace = many (simpleWhiteSpace <|> singleLineComment <|> multiLineComment) *> pure ()
7857
79−instance HasLastTokenSpan IdrisParser where
80− getLastTokenSpan = lastTokenSpan <$> get
58+tokenFC :: MonadicParsing m => m a -> m (a, FC)
59+tokenFC p = do (FC fn (sl, sc) _) <- getFC --TODO: Update after fixing getFC
60+ -- See Issue #1594
61+ r <- p
62+ (FC fn _ (el, ec)) <- getFC
63+ whiteSpace
64+ return (r, FC fn (sl, sc) (el, ec))
8165
82−newtype ParseError = ParseError { parseErrorDoc :: PP.Doc }
66+token :: MonadicParsing m => m a -> m a
67+token p = p <* whiteSpace
8368
8469-- | Helper to run Idris inner parser based stateT parsers
85−runparser :: StateT st P.Parser res -> st -> String -> String -> Either ParseError res
70+runparser :: StateT st IdrisInnerParser res -> st -> String -> String -> Either ParseError res
8671runparser p i inputname s =
87− case P.parseString (evalStateT p i)
88− (P.Directed (UTF8.fromString inputname) 0 0 0 0) s of
89− P.Failure (P.ErrInfo doc _) -> Left (ParseError doc)
90− P.Success value -> Right value
72+ case P.parse (evalStateT p i) inputname s of
73+ Left err -> Left $ ParseError s err
74+ Right v -> Right v
75+
9176
9277highlightP :: FC -> OutputAnnotation -> IdrisParser ()
9378highlightP fc annot = do ist <- get
@@ -136,7 +121,7 @@ isEol _ = False
136121
137122-- | A parser that succeeds at the end of the line
138123eol :: MonadicParsing m => m ()
139−eol = () <$ P.satisfy isEol <|> lookAhead P.eof <?> "end of line"
124+eol = () <$ P.satisfy isEol <|> P.lookAhead P.eof <?> "end of line"
140125
141126{- | Consumes a single-line comment
142127
@@ -145,10 +130,7 @@ eol = () <$ P.satisfy isEol <|> lookAhead P.eof <?> "end of line"
145130@
146131 -}
147132singleLineComment :: MonadicParsing m => m ()
148−singleLineComment = (string "--" *>
149− many (P.satisfy (not . isEol)) *>
150− eol *> pure ())
151− <?> ""
133+singleLineComment = P.hidden (() <$ string "--" *> many (P.satisfy (not . isEol)) *> eol)
152134
153135{- | Consumes a multi-line comment
154136
@@ -168,9 +150,8 @@ singleLineComment = (string "--" *>
168150@
169151-}
170152multiLineComment :: MonadicParsing m => m ()
171−multiLineComment = P.try (string "{-" *> (string "-}") *> pure ())
172− <|> string "{-" *> inCommentChars
173− <?> ""
153+multiLineComment = P.hidden $ P.try (string "{-" *> string "-}" *> pure ())
154+ <|> string "{-" *> inCommentChars
174155 where inCommentChars :: MonadicParsing m => m ()
175156 inCommentChars = string "-}" *> pure ()
176157 <|> P.try (multiLineComment) *> inCommentChars
@@ -199,56 +180,47 @@ docComment = do dc <- pushIndent *> docCommentLine
199180 map (\(n, d) -> (n, parseDocstring (T.pack d))) args)
200181
201182 where docCommentLine :: MonadicParsing m => m String
202− docCommentLine = P.try (do string "|||"
203− many (P.satisfy (==' '))
204− contents <- P.option "" (do first <- P.satisfy (\c -> not (isEol c || c == '@'))
205− res <- many (P.satisfy (not . isEol))
206− return $ first:res)
207− eol ; someSpace'
208− return contents)
209− <?> ""
210−
211− argDocCommentLine = do string "|||"
212− many (P.satisfy isSpace)
213− char '@'
214− many (P.satisfy isSpace)
183+ docCommentLine = P.hidden $ P.try $ do
184+ string "|||"
185+ many (P.satisfy (==' '))
186+ contents <- P.option "" (do first <- P.satisfy (\c -> not (isEol c || c == '@'))
187+ res <- many (P.satisfy (not . isEol))
188+ return $ first:res)
189+ eol ; someSpace
190+ return contents
191+
192+ argDocCommentLine :: IdrisParser (Name, String)
193+ argDocCommentLine = do P.string "|||"
194+ P.many (P.satisfy isSpace)
195+ P.char '@'
196+ P.many (P.satisfy isSpace)
215197 n <- fst <$> name
216− many (P.satisfy isSpace)
217− docs <- many (P.satisfy (not . isEol))
218− eol ; someSpace'
198+ P.many (P.satisfy isSpace)
199+ docs <- P.many (P.satisfy (not . isEol))
200+ P.eol ; someSpace
219201 return (n, docs)
220202
221203-- | Parses some white space
222204whiteSpace :: MonadicParsing m => m ()
223−whiteSpace = Tok.whiteSpace
205+whiteSpace = someSpace <|> pure ()
224206
225207-- | Parses a string literal
226−stringLiteral :: (MonadicParsing m, HasLastTokenSpan m) => m (String, FC)
227−stringLiteral = do str <- Tok.stringLiteral
228− fc <- getLastTokenSpan
229− return (str, fromMaybe NoFC fc)
208+stringLiteral :: MonadicParsing m => m (String, FC)
209+stringLiteral = tokenFC . P.try $ P.char '"' *> P.manyTill P.charLiteral (P.char '"')
230210
231211-- | Parses a char literal
232−charLiteral :: (MonadicParsing m, HasLastTokenSpan m) => m (Char, FC)
233−charLiteral = do ch <- Tok.charLiteral
234− fc <- getLastTokenSpan
235− return (ch, fromMaybe NoFC fc)
212+charLiteral :: IdrisParser (Char, FC)
213+charLiteral = tokenFC . P.try $ P.char '\'' *> P.charLiteral <* P.char '\''
236214
237215-- | Parses a natural number
238−natural :: (MonadicParsing m, HasLastTokenSpan m) => m (Integer, FC)
239−natural = do n <- Tok.natural
240− fc <- getLastTokenSpan
241− return (n, fromMaybe NoFC fc)
242−
243−-- | Parses an integral number
244−integer :: MonadicParsing m => m Integer
245−integer = Tok.integer
216+natural :: IdrisParser (Integer, FC)
217+natural = tokenFC ( P.try (P.char '0' *> P.char' 'x' *> P.hexadecimal)
218+ <|> P.try (P.char '0' *> P.char' 'o' *> P.octal)
219+ <|> P.try P.decimal)
246220
247221-- | Parses a floating point number
248−float :: (MonadicParsing m, HasLastTokenSpan m) => m (Double, FC)
249−float = do f <- Tok.double
250− fc <- getLastTokenSpan
251− return (f, fromMaybe NoFC fc)
222+float :: IdrisParser (Double, FC)
223+float = tokenFC . P.try $ P.float
252224
253225{- * Symbols, identifiers, names and operators -}
254226
@@ -264,30 +236,29 @@ reservedIdentifiers = HS.fromList
264236 ]
265237
266238identifierOrReserved :: MonadicParsing m => m String
267−identifierOrReserved = P.token $ P.try $ do
239+identifierOrReserved = token $ P.try $ do
268240 c <- P.satisfy isAlpha <|> P.oneOf "_"
269241 cs <- P.many (P.satisfy isAlphaNum <|> P.oneOf "_'.")
270242 return $ c : cs
271243
272244char :: MonadicParsing m => Char -> m Char
273−char = Chr.char
245+char = P.char
274246
275247string :: MonadicParsing m => String -> m String
276−string = Chr.string
248+string = P.string
277249
278250-- | Parses a character as a token
279251lchar :: MonadicParsing m => Char -> m Char
280−lchar = P.token . P.char
252+lchar = token . P.char
281253
282254-- | Parses a character as a token, returning the source span of the character
283255lcharFC :: MonadicParsing m => Char -> m FC
284256lcharFC ch = do (FC file (l, c) _) <- getFC
285− _ <- P.token (char ch)
257+ _ <- token (P.char ch)
286258 return $ FC file (l, c) (l, c+1)
287259
288−-- | Parses string as a token
289260symbol :: MonadicParsing m => String -> m ()
290−symbol = void . Tok.symbol
261+symbol = void . P.symbol someSpace
291262
292263symbolFC :: MonadicParsing m => String -> m FC
293264symbolFC str = do (FC file (l, c) _) <- getFC
@@ -296,7 +267,7 @@ symbolFC str = do (FC file (l, c) _) <- getFC
296267
297268-- | Parses a reserved identifier
298269reserved :: MonadicParsing m => String -> m ()
299−reserved name = P.token $ P.try $ do
270+reserved name = token $ P.try $ do
300271 P.string name
301272 P.notFollowedBy (P.satisfy isAlphaNum <|> P.oneOf "_'.") <?> "end of " ++ name
302273
@@ -314,7 +285,7 @@ reservedHL str = reservedFC str >>= flip highlightP AnnKeyword
314285-- Taken from Parsec (c) Daan Leijen 1999-2001, (c) Paolo Martini 2007
315286-- | Parses a reserved operator
316287reservedOp :: MonadicParsing m => String -> m ()
317−reservedOp name = P.token $ P.try $
288+reservedOp name = token $ P.try $
318289 do string name
319290 P.notFollowedBy operatorLetter <?> ("end of " ++ show name)
320291
@@ -328,8 +299,8 @@ identifier :: (MonadicParsing m) => m (String, FC)
328299identifier = P.try $ do
329300 (FC f (l, c) _) <- getFC
330301 ident <- identifierOrReserved
331− when (ident `HS.member` reservedIdentifiers) $ P.unexpected $ "reserved " ++ ident
332− when (ident == "_") $ P.unexpected "wildcard"
302+ when (ident `HS.member` reservedIdentifiers) $ P.unexpected . P.Label . NonEmpty.fromList $ "reserved " ++ ident
303+ when (ident == "_") $ P.unexpected . P.Label . NonEmpty.fromList $ "wildcard"
333304 return (ident, FC f (l, c) (l, c + length ident))
334305
335306-- | Parses an identifier with possible namespace as a name
@@ -340,8 +311,8 @@ iName bad = maybeWithNS identifier False bad <?> "name"
340311maybeWithNS :: (MonadicParsing m) => m (String, FC) -> Bool -> [String] -> m (Name, FC)
341312maybeWithNS parser ascend bad = do
342313 fc <- getFC
343− i <- P.option "" (lookAhead (fst <$> identifier))
344− when (i `elem` bad) $ P.unexpected "reserved identifier"
314+ i <- P.option "" (P.lookAhead (fst <$> identifier))
315+ when (i `elem` bad) $ P.unexpected . P.Label . NonEmpty.fromList $ "reserved identifier"
345316 let transf = if ascend then id else reverse
346317 (x, xs, fc) <- P.choice (transf (parserNoNS parser : parsersNS parser i))
347318 return (mkName (x, xs), fc)
@@ -410,7 +381,7 @@ invalidOperators = [":", "=>", "->", "<-", "=", "?=", "|", "**", "==>", "\\", "%
410381
411382-- | Parses an operator
412383symbolicOperator :: MonadicParsing m => m String
413−symbolicOperator = do op <- P.token . some $ operatorLetter
384+symbolicOperator = do op <- token . some $ operatorLetter
414385 when (op `elem` (invalidOperators ++ commentMarkers)) $
415386 fail $ op ++ " is not a valid operator"
416387 return op
@@ -422,32 +393,17 @@ symbolicOperatorFC = do (FC f (l, c) _) <- getFC
422393 return (op, FC f (l, c) (l, c + length op))
423394
424395{- * Position helpers -}
425−{- | Get filename from position (returns "(interactive)" when no source file is given) -}
426−fileName :: P.Delta -> String
427−fileName (P.Directed fn _ _ _ _) = UTF8.toString fn
428−fileName _ = "(interactive)"
429−
430−{- | Get line number from position -}
431−lineNum :: P.Delta -> Int
432−lineNum (P.Lines l _ _ _) = fromIntegral l + 1
433−lineNum (P.Directed _ l _ _ _) = fromIntegral l + 1
434−lineNum _ = 0
435−
436−{- | Get column number from position -}
437−columnNum :: P.Delta -> Int
438−columnNum pos = fromIntegral (P.column pos) + 1
439−
440−
441396{- | Get file position as FC -}
442397getFC :: MonadicParsing m => m FC
443−getFC = do s <- P.position
444− let (dir, file) = splitFileName (fileName s)
445− let f = if dir == addTrailingPathSeparator "." then file else fileName s
446− return $ FC f (lineNum s, columnNum s) (lineNum s, columnNum s) -- TODO: Change to actual spanning
398+getFC = do pos <- P.getPosition
399+ let columnNumber = P.unPos . P.sourceColumn $ pos
400+ let lineNumber = P.unPos . P.sourceLine $ pos
401+ let (dir, file) = splitFileName (P.sourceName pos)
402+ let f = if dir == addTrailingPathSeparator "." then file else P.sourceName pos
403+ return $ FC f (lineNumber, columnNumber) (lineNumber, columnNumber) -- TODO: Change to actual spanning
447404 -- Issue #1594 on the Issue Tracker.
448405 -- https://github.com/idris-lang/Idris-dev/issues/1594
449406
450−
451407{-* Syntax helpers-}
452408-- | Bind constraints to term
453409bindList :: (RigCount -> Name -> FC -> PTerm -> PTerm -> PTerm) -> [(RigCount, Name, FC, PTerm)] -> PTerm -> PTerm
@@ -457,15 +413,15 @@ bindList b ((r, n, fc, t):bs) sc = b r n fc t (bindList b bs sc)
457413{- | @commaSeparated p@ parses one or more occurences of `p`,
458414 separated by commas and optional whitespace. -}
459415commaSeparated :: MonadicParsing m => m a -> m [a]
460−commaSeparated p = p `P.sepBy1` (P.spaces >> P.char ',' >> P.spaces)
416+commaSeparated p = p `P.sepBy1` (P.space >> P.char ',' >> P.space)
461417
462418{- * Layout helpers -}
463419
464420-- | Push indentation to stack
465421pushIndent :: IdrisParser ()
466−pushIndent = do pos <- P.position
422+pushIndent = do columnNumber <- indent
467423 ist <- get
468− put (ist { indent_stack = (fromIntegral (P.column pos) + 1) : indent_stack ist })
424+ put (ist { indent_stack = columnNumber : indent_stack ist })
469425
470426-- | Pops indentation from stack
471427popIndent :: IdrisParser ()
@@ -476,8 +432,8 @@ popIndent = do ist <- get
476432
477433
478434-- | Gets current indentation
479−indent :: IdrisParser Int
480−indent = liftM ((+1) . fromIntegral . P.column) P.position
435+indent :: MonadicParsing m => m Int
436+indent = P.unPos . P.sourceColumn <$> P.getPosition
481437
482438-- | Gets last indentation
483439lastIndent :: IdrisParser Int
@@ -520,8 +476,7 @@ indentedBlockS p = do openBlock
520476
521477-- | Checks if the following character matches provided parser
522478lookAheadMatches :: MonadicParsing m => m a -> m Bool
523−lookAheadMatches p = do match <- lookAhead (optional p)
524− return $ isJust match
479+lookAheadMatches p = isJust <$> P.lookAhead (P.optional p)
525480
526481-- | Parses a start of block
527482openBlock :: IdrisParser ()
@@ -565,7 +520,7 @@ terminator = do lchar ';'; popIndent
565520 if c <= l then popIndent else fail "not a terminator"
566521 <|> do isParen <- lookAheadMatches (P.oneOf ")}")
567522 if isParen then popIndent else fail "not a terminator"
568− <|> lookAhead P.eof
523+ <|> P.lookAhead P.eof
569524
570525-- | Parses and keeps a terminator
571526keepTerminator :: IdrisParser ()
@@ -575,7 +530,7 @@ keepTerminator = () <$ lchar ';'
575530 <|> do isParen <- lookAheadMatches (P.oneOf ")}|")
576531 isIn <- lookAheadMatches (reserved "in")
577532 unless (isIn || isParen) $ fail "not a terminator"
578− <|> lookAhead P.eof
533+ <|> P.lookAhead P.eof
579534
580535-- | Checks if application expression does not end
581536notEndApp :: IdrisParser ()
@@ -587,7 +542,7 @@ notEndBlock :: IdrisParser ()
587542notEndBlock = do ist <- get
588543 case brace_stack ist of
589544 Just lvl : xs -> do i <- indent
590− isParen <- lookAheadMatches (char ')')
545+ isParen <- lookAheadMatches (P.char ')')
591546 when (i < lvl || isParen) (fail "end of block")
592547 _ -> return ()
593548
src/Idris/Parser/Ops.hs+26−24
@@ -21,39 +21,40 @@ import Control.Monad
2121import Control.Monad.State.Strict
2222import Data.Char (isAlpha)
2323import Data.List
24−import Text.Parser.Expression
25−import Text.Trifecta ((<?>))
26−import qualified Text.Trifecta as P
24+import Data.List.NonEmpty (fromList)
25+import Text.Megaparsec ((<?>))
26+import qualified Text.Megaparsec as P
27+import qualified Text.Megaparsec.Expr as P
2728
2829-- | Creates table for fixity declarations to build expression parser
2930-- using pre-build and user-defined operator/fixity declarations
30−table :: [FixDecl] -> OperatorTable IdrisParser PTerm
31+table :: [FixDecl] -> [[P.Operator IdrisParser PTerm]]
3132table fixes
3233 = [[prefix "-" (\fc x -> PApp fc (PRef fc [fc] (sUN "negate")) [pexp x])]] ++
3334 toTable (reverse fixes) ++
3435 [[noFixityBacktickOperator],
35− [binary "$" AssocRight $ \fc _ x y -> flatten $ PApp fc x [pexp y]],
36− [binary "=" AssocLeft $ \fc _ x y -> PApp fc (PRef fc [fc] eqTy) [pexp x, pexp y]],
36+ [binary "$" P.InfixR $ \fc _ x y -> flatten $ PApp fc x [pexp y]],
37+ [binary "=" P.InfixL $ \fc _ x y -> PApp fc (PRef fc [fc] eqTy) [pexp x, pexp y]],
3738 [noFixityOperator]]
3839 where
3940 flatten :: PTerm -> PTerm -- flatten application
4041 flatten (PApp fc (PApp _ f as) bs) = flatten (PApp fc f (as ++ bs))
4142 flatten t = t
4243
43− noFixityBacktickOperator :: Operator IdrisParser PTerm
44− noFixityBacktickOperator = flip Infix AssocNone $ do
44+ noFixityBacktickOperator :: P.Operator IdrisParser PTerm
45+ noFixityBacktickOperator = P.InfixN $ do
4546 (n, fc) <- backtickOperator
4647 return $ \x y -> PApp fc (PRef fc [fc] n) [pexp x, pexp y]
4748
4849 -- | Operator without fixity (throws an error)
49− noFixityOperator :: Operator IdrisParser PTerm
50− noFixityOperator = flip Infix AssocNone $ do
50+ noFixityOperator :: P.Operator IdrisParser PTerm
51+ noFixityOperator = P.InfixN $ do
5152 indentGt
5253 op <- P.try symbolicOperator
53− P.unexpected $ "Operator without known fixity: " ++ op
54+ P.unexpected . P.Label . fromList $ "Operator without known fixity: " ++ op
5455
5556 -- | Calculates table for fixity declarations
56− toTable :: [FixDecl] -> OperatorTable IdrisParser PTerm
57+ toTable :: [FixDecl] -> [[P.Operator IdrisParser PTerm]]
5758 toTable fs = map (map toBin) (groupBy (\ (Fix x _) (Fix y _) -> prec x == prec y) fs)
5859
5960 toBin (Fix (PrefixN _) op) = prefix op $ \fc x ->
@@ -61,31 +62,32 @@ table fixes
6162 toBin (Fix f op) = binary op (assoc f) $ \fc n x y ->
6263 PApp fc (PRef fc [] n) [pexp x,pexp y]
6364
64− assoc (Infixl _) = AssocLeft
65− assoc (Infixr _) = AssocRight
66− assoc (InfixN _) = AssocNone
65+ assoc (Infixl _) = P.InfixL
66+ assoc (Infixr _) = P.InfixR
67+ assoc (InfixN _) = P.InfixN
6768
6869 isBacktick :: String -> Bool
6970 isBacktick (c : _) = c == '_' || isAlpha c
7071 isBacktick _ = False
7172
72− binary :: String -> Assoc -> (FC -> Name -> PTerm -> PTerm -> PTerm) -> Operator IdrisParser PTerm
73− binary name assoc f
74− | isBacktick name = flip Infix assoc $ P.try $ do
73+ binary :: String -> (IdrisParser (PTerm -> PTerm -> PTerm) -> P.Operator IdrisParser PTerm) -> (FC -> Name -> PTerm -> PTerm -> PTerm) -> P.Operator IdrisParser PTerm
74+ binary name ctor f
75+ | isBacktick name = ctor $ P.try $ do
7576 (n, fc) <- backtickOperator
7677 guard $ show (nsroot n) == name
7778 return $ f fc n
78− | otherwise = flip Infix assoc $ do
79+ | otherwise = ctor $ do
7980 indentGt
8081 fc <- reservedOpFC name
8182 indentGt
8283 return $ f fc (sUN name)
8384
84− prefix :: String -> (FC -> PTerm -> PTerm) -> Operator IdrisParser PTerm
85− prefix name f = Prefix (do reservedOp name
86− fc <- getFC
87− indentGt
88− return (f fc))
85+ prefix :: String -> (FC -> PTerm -> PTerm) -> P.Operator IdrisParser PTerm
86+ prefix name f = P.Prefix $ do
87+ reservedOp name
88+ fc <- getFC
89+ indentGt
90+ return (f fc)
8991
9092{- | Parses a function used as an operator -- enclosed in backticks
9193
src/Idris/REPL/Parser.hs+70−69
@@ -4,6 +4,7 @@ Description : Parser for the REPL commands.
44License : BSD3
55Maintainer : The Idris Community.
66-}
7+{-# LANGUAGE FlexibleContexts #-}
78module Idris.REPL.Parser (
89 parseCmd
910 , help
@@ -31,8 +32,8 @@ import Data.List
3132import Data.List.Split (splitOn)
3233import System.Console.ANSI (Color(..))
3334import System.FilePath ((</>))
34−import Text.Parser.Char (anyChar, oneOf)
35−import Text.Parser.Combinators
35+import qualified Text.Megaparsec as P
36+import qualified Text.Megaparsec.Char as P
3637
3738parseCmd :: IState -> String -> String -> Either IP.ParseError (Either String Command)
3839parseCmd i inputname = IP.runparser pCmd i inputname . trim
@@ -67,7 +68,7 @@ parserCommandsForHelp =
6768 , nameArgCmd ["miss", "missing"] Missing "Show missing clauses"
6869 , (["doc"], NameArg, "Show internal documentation", cmd_doc)
6970 , (["mkdoc"], NamespaceArg, "Generate IdrisDoc for namespace(s) and dependencies"
70− , genArg "namespace" (many anyChar) MakeDoc)
71+ , genArg "namespace" (P.many P.anyChar) MakeDoc)
7172 , (["apropos"], SeqArgs (OptionalArg PkgArgs) NameArg, " Search names, types, and documentation"
7273 , cmd_apropos)
7374 , (["s", "search"], SeqArgs (OptionalArg PkgArgs) ExprArg
@@ -169,7 +170,7 @@ parserCommands =
169170 , "(Debugging) Try to unify two expressions", const $ do
170171 l <- IP.simpleExpr defaultSyntax
171172 r <- IP.simpleExpr defaultSyntax
172− eof
173+ P.eof
173174 return (Right (DebugUnify l r))
174175 )
175176 ]
@@ -188,25 +189,25 @@ proofArgCmd names command doc =
188189 (names, NoArg, doc, proofArg command)
189190
190191pCmd :: IP.IdrisParser (Either String Command)
191−pCmd = choice [ do c <- cmd names; parser c
192− | (names, _, _, parser) <- parserCommandsForHelp ++ parserCommands ]
192+pCmd = P.choice [ do c <- cmd names; parser c
193+ | (names, _, _, parser) <- parserCommandsForHelp ++ parserCommands ]
193194 <|> unrecognized
194195 <|> nop
195196 <|> eval
196− where nop = do eof; return (Right NOP)
197+ where nop = do P.eof; return (Right NOP)
197198 unrecognized = do
198199 IP.lchar ':'
199− cmd <- many anyChar
200+ cmd <- P.many P.anyChar
200201 let cmd' = takeWhile (/=' ') cmd
201202 return (Left $ "Unrecognized command: " ++ cmd')
202203
203204cmd :: [String] -> IP.IdrisParser String
204−cmd xs = try $ do
205+cmd xs = P.try $ do
205206 IP.lchar ':'
206207 docmd sorted_xs
207208
208209 where docmd [] = fail "Could not parse command"
209− docmd (x:xs) = try (IP.reserved x >> return x) <|> docmd xs
210+ docmd (x:xs) = P.try (IP.reserved x >> return x) <|> docmd xs
210211
211212 sorted_xs = sortBy (\x y -> compare (length y) (length x)) xs
212213
@@ -214,7 +215,7 @@ cmd xs = try $ do
214215noArgs :: Command -> String -> IP.IdrisParser (Either String Command)
215216noArgs cmd name = do
216217 let emptyArgs = do
217− eof
218+ P.eof
218219 return (Right cmd)
219220
220221 let failure = return (Left $ ":" ++ name ++ " takes no arguments")
@@ -229,27 +230,27 @@ eval = do
229230exprArg :: (PTerm -> Command) -> String -> IP.IdrisParser (Either String Command)
230231exprArg cmd name = do
231232 let noArg = do
232− eof
233+ P.eof
233234 return $ Left ("Usage is :" ++ name ++ " <expression>")
234235
235236 let justOperator = do
236237 (op, fc) <- IP.symbolicOperatorFC
237− eof
238+ P.eof
238239 return $ Right $ cmd (PRef fc [] (sUN op))
239240
240241 let properArg = do
241242 t <- IP.fullExpr defaultSyntax
242243 return $ Right (cmd t)
243− try noArg <|> try justOperator <|> properArg
244+ P.try noArg <|> P.try justOperator <|> properArg
244245
245246genArg :: String -> IP.IdrisParser a -> (a -> Command)
246247 -> String -> IP.IdrisParser (Either String Command)
247248genArg argName argParser cmd name = do
248− let emptyArgs = do eof; failure
249+ let emptyArgs = do P.eof; failure
249250 oneArg = do arg <- argParser
250− eof
251+ P.eof
251252 return (Right (cmd arg))
252− try emptyArgs <|> oneArg <|> failure
253+ P.try emptyArgs <|> oneArg <|> failure
253254 where
254255 failure = return $ Left ("Usage is :" ++ name ++ " <" ++ argName ++ ">")
255256
@@ -258,7 +259,7 @@ nameArg = genArg "name" $ fst <$> IP.name
258259fnNameArg = genArg "functionname" $ fst <$> IP.fnName
259260
260261strArg :: (String -> Command) -> String -> IP.IdrisParser (Either String Command)
261−strArg = genArg "string" (many anyChar)
262+strArg = genArg "string" (P.many P.anyChar)
262263
263264moduleArg :: (FilePath -> Command) -> String -> IP.IdrisParser (Either String Command)
264265moduleArg = genArg "module" (fmap (toPath . fst) IP.identifier)
@@ -273,18 +274,18 @@ namespaceArg = genArg "namespace" (fmap (toNS . fst) IP.identifier)
273274optArg :: (Opt -> Command) -> String -> IP.IdrisParser (Either String Command)
274275optArg cmd name = do
275276 let emptyArgs = do
276− eof
277+ P.eof
277278 return $ Left ("Usage is :" ++ name ++ " <option>")
278279
279280 let oneArg = do
280281 o <- pOption
281282 IP.whiteSpace
282− eof
283+ P.eof
283284 return (Right (cmd o))
284285
285286 let failure = return $ Left "Unrecognized setting"
286287
287− try emptyArgs <|> oneArg <|> failure
288+ P.try emptyArgs <|> oneArg <|> failure
288289
289290 where
290291 pOption :: IP.IdrisParser Opt
@@ -292,7 +293,7 @@ optArg cmd name = do
292293
293294proofArg :: (Bool -> Int -> Name -> Command) -> String -> IP.IdrisParser (Either String Command)
294295proofArg cmd name = do
295− upd <- option False $ do
296+ upd <- P.option False $ do
296297 IP.lchar '!'
297298 return True
298299 l <- fst <$> IP.natural
@@ -303,17 +304,17 @@ cmd_doc :: String -> IP.IdrisParser (Either String Command)
303304cmd_doc name = do
304305 let constant = do
305306 c <- fmap fst IP.constant
306− eof
307+ P.eof
307308 return $ Right (DocStr (Right c) FullDocs)
308309
309310 let pType = do
310311 IP.reserved "Type"
311− eof
312+ P.eof
312313 return $ Right (DocStr (Left $ IP.mkName ("Type", "")) FullDocs)
313314
314315 let fnName = fnNameArg (\n -> DocStr (Left n) FullDocs) name
315316
316− try constant <|> pType <|> fnName
317+ P.try constant <|> pType <|> fnName
317318
318319cmd_consolewidth :: String -> IP.IdrisParser (Either String Command)
319320cmd_consolewidth name = do
@@ -333,19 +334,19 @@ cmd_printdepth _ = do d <- optional (fmap (fromInteger . fst) IP.natural)
333334
334335cmd_execute :: String -> IP.IdrisParser (Either String Command)
335336cmd_execute name = do
336− tm <- option maintm (IP.fullExpr defaultSyntax)
337+ tm <- P.option maintm (IP.fullExpr defaultSyntax)
337338 return (Right (Execute tm))
338339 where
339340 maintm = PRef (fileFC "(repl)") [] (sNS (sUN "main") ["Main"])
340341
341342cmd_dynamic :: String -> IP.IdrisParser (Either String Command)
342343cmd_dynamic name = do
343− let optArg = do l <- many anyChar
344+ let optArg = do l <- P.many P.anyChar
344345 if (l /= "")
345346 then return $ Right (DynamicLink l)
346347 else return $ Right ListDynamic
347348 let failure = return $ Left $ "Usage is :" ++ name ++ " [<library>]"
348− try optArg <|> failure
349+ P.try optArg <|> failure
349350
350351cmd_pprint :: String -> IP.IdrisParser (Either String Command)
351352cmd_pprint name = do
@@ -375,43 +376,43 @@ cmd_compile name = do
375376 let hasOneArg = do
376377 i <- get
377378 f <- fst <$> IP.identifier
378− eof
379+ P.eof
379380 return $ Right (Compile defaultCodegen f)
380381
381382 let hasTwoArgs = do
382383 i <- get
383384 codegen <- codegenOption
384385 f <- fst <$> IP.identifier
385− eof
386+ P.eof
386387 return $ Right (Compile codegen f)
387388
388389 let failure = return $ Left $ "Usage is :" ++ name ++ " [<codegen>] <filename>"
389− try hasTwoArgs <|> try hasOneArg <|> failure
390+ P.try hasTwoArgs <|> P.try hasOneArg <|> failure
390391
391392cmd_addproof :: String -> IP.IdrisParser (Either String Command)
392393cmd_addproof name = do
393− n <- option Nothing $ do
394+ n <- P.option Nothing $ do
394395 x <- fst <$> IP.name
395396 return (Just x)
396− eof
397+ P.eof
397398 return (Right (AddProof n))
398399
399400cmd_log :: String -> IP.IdrisParser (Either String Command)
400401cmd_log name = do
401402 i <- fmap (fromIntegral . fst) IP.natural
402− eof
403+ P.eof
403404 return (Right (LogLvl i))
404405
405406cmd_verb :: String -> IP.IdrisParser (Either String Command)
406407cmd_verb name = do
407408 i <- fmap (fromIntegral . fst) IP.natural
408− eof
409+ P.eof
409410 return (Right (Verbosity i))
410411
411412cmd_cats :: String -> IP.IdrisParser (Either String Command)
412413cmd_cats name = do
413− cs <- sepBy pLogCats (IP.whiteSpace)
414− eof
414+ cs <- P.sepBy pLogCats (IP.whiteSpace)
415+ P.eof
415416 return $ Right $ LogCategory (concat cs)
416417 where
417418 badCat = do
@@ -419,26 +420,26 @@ cmd_cats name = do
419420 fail $ "Category: " ++ c ++ " is not recognised."
420421
421422 pLogCats :: IP.IdrisParser [LogCat]
422− pLogCats = try (parserCats <$ IP.symbol (strLogCat IParse))
423− <|> try (elabCats <$ IP.symbol (strLogCat IElab))
424− <|> try (codegenCats <$ IP.symbol (strLogCat ICodeGen))
425− <|> try ([ICoverage] <$ IP.symbol (strLogCat ICoverage))
426− <|> try ([IIBC] <$ IP.symbol (strLogCat IIBC))
427− <|> try ([IErasure] <$ IP.symbol (strLogCat IErasure))
423+ pLogCats = P.try (parserCats <$ IP.symbol (strLogCat IParse))
424+ <|> P.try (elabCats <$ IP.symbol (strLogCat IElab))
425+ <|> P.try (codegenCats <$ IP.symbol (strLogCat ICodeGen))
426+ <|> P.try ([ICoverage] <$ IP.symbol (strLogCat ICoverage))
427+ <|> P.try ([IIBC] <$ IP.symbol (strLogCat IIBC))
428+ <|> P.try ([IErasure] <$ IP.symbol (strLogCat IErasure))
428429 <|> badCat
429430
430431cmd_let :: String -> IP.IdrisParser (Either String Command)
431432cmd_let name = do
432− defn <- concat <$> many (IP.decl defaultSyntax)
433+ defn <- concat <$> P.many (IP.decl defaultSyntax)
433434 return (Right (NewDefn defn))
434435
435436cmd_unlet :: String -> IP.IdrisParser (Either String Command)
436−cmd_unlet name = (Right . Undefine) `fmap` many (fst <$> IP.name)
437+cmd_unlet name = (Right . Undefine) `fmap` P.many (fst <$> IP.name)
437438
438439cmd_loadto :: String -> IP.IdrisParser (Either String Command)
439440cmd_loadto name = do
440441 toline <- fmap (fromInteger . fst) IP.natural
441− f <- many anyChar;
442+ f <- P.many P.anyChar
442443 return (Right (Load f (Just toline)))
443444
444445cmd_colour :: String -> IP.IdrisParser (Either String Command)
@@ -460,27 +461,27 @@ cmd_colour name = fmap Right pSetColourCmd
460461 pSetColourCmd :: IP.IdrisParser Command
461462 pSetColourCmd = (do c <- pColourType
462463 let defaultColour = IdrisColour Nothing True False False False
463− opts <- sepBy pColourMod (IP.whiteSpace)
464+ opts <- P.sepBy pColourMod (IP.whiteSpace)
464465 let colour = foldr ($) defaultColour $ reverse opts
465466 return $ SetColour c colour)
466− <|> try (IP.symbol "on" >> return ColourOn)
467− <|> try (IP.symbol "off" >> return ColourOff)
467+ <|> P.try (IP.symbol "on" >> return ColourOn)
468+ <|> P.try (IP.symbol "off" >> return ColourOff)
468469
469470 pColour :: IP.IdrisParser (Maybe Color)
470471 pColour = doColour colours
471472 where doColour [] = fail "Unknown colour"
472− doColour ((s, c):cs) = (try (IP.symbol s) >> return c) <|> doColour cs
473+ doColour ((s, c):cs) = (P.try (IP.symbol s) >> return c) <|> doColour cs
473474
474475 pColourMod :: IP.IdrisParser (IdrisColour -> IdrisColour)
475− pColourMod = try (doVivid <$ IP.symbol "vivid")
476− <|> try (doDull <$ IP.symbol "dull")
477− <|> try (doUnderline <$ IP.symbol "underline")
478− <|> try (doNoUnderline <$ IP.symbol "nounderline")
479− <|> try (doBold <$ IP.symbol "bold")
480− <|> try (doNoBold <$ IP.symbol "nobold")
481− <|> try (doItalic <$ IP.symbol "italic")
482− <|> try (doNoItalic <$ IP.symbol "noitalic")
483− <|> try (pColour >>= return . doSetColour)
476+ pColourMod = P.try (doVivid <$ IP.symbol "vivid")
477+ <|> P.try (doDull <$ IP.symbol "dull")
478+ <|> P.try (doUnderline <$ IP.symbol "underline")
479+ <|> P.try (doNoUnderline <$ IP.symbol "nounderline")
480+ <|> P.try (doBold <$ IP.symbol "bold")
481+ <|> P.try (doNoBold <$ IP.symbol "nobold")
482+ <|> P.try (doItalic <$ IP.symbol "italic")
483+ <|> P.try (doNoItalic <$ IP.symbol "noitalic")
484+ <|> P.try (pColour >>= return . doSetColour)
484485 where doVivid i = i { vivid = True }
485486 doDull i = i { vivid = False }
486487 doUnderline i = i { underline = True }
@@ -500,9 +501,9 @@ cmd_colour name = fmap Right pSetColourCmd
500501 pColourType = doColourType colourTypes
501502 where doColourType [] = fail $ "Unknown colour category. Options: " ++
502503 (concat . intersperse ", " . map fst) colourTypes
503− doColourType ((s,ct):cts) = (try (IP.symbol s) >> return ct) <|> doColourType cts
504+ doColourType ((s,ct):cts) = (P.try (IP.symbol s) >> return ct) <|> doColourType cts
504505
505−idChar = oneOf (['a'..'z'] ++ ['A'..'Z'] ++ ['0'..'9'] ++ ['_'])
506+idChar = P.oneOf (['a'..'z'] ++ ['A'..'Z'] ++ ['0'..'9'] ++ ['_'])
506507
507508cmd_apropos :: String -> IP.IdrisParser (Either String Command)
508509cmd_apropos = packageBasedCmd (some idChar) Apropos
@@ -510,11 +511,11 @@ cmd_apropos = packageBasedCmd (some idChar) Apropos
510511packageBasedCmd :: IP.IdrisParser a -> ([PkgName] -> a -> Command)
511512 -> String -> IP.IdrisParser (Either String Command)
512513packageBasedCmd valParser cmd name =
513− try (do IP.lchar '('
514− pkgs <- sepBy (pkg <* IP.whiteSpace) (IP.lchar ',')
515− IP.lchar ')'
516− val <- valParser
517− return (Right (cmd pkgs val)))
514+ P.try (do IP.lchar '('
515+ pkgs <- P.sepBy (pkg <* IP.whiteSpace) (IP.lchar ',')
516+ IP.lchar ')'
517+ val <- valParser
518+ return (Right (cmd pkgs val)))
518519 <|> do val <- valParser
519520 return (Right (cmd [] val))
520521 where
@@ -526,14 +527,14 @@ cmd_search = packageBasedCmd
526527
527528cmd_proofsearch :: String -> IP.IdrisParser (Either String Command)
528529cmd_proofsearch name = do
529− upd <- option False (True <$ IP.lchar '!')
530+ upd <- P.option False (True <$ IP.lchar '!')
530531 l <- fmap (fromInteger . fst) IP.natural; n <- fst <$> IP.name
531− hints <- many (fst <$> IP.fnName)
532+ hints <- P.many (fst <$> IP.fnName)
532533 return (Right (DoProofSearch upd True l n hints))
533534
534535cmd_refine :: String -> IP.IdrisParser (Either String Command)
535536cmd_refine name = do
536− upd <- option False (do IP.lchar '!'; return True)
537+ upd <- P.option False (do IP.lchar '!'; return True)
537538 l <- fmap (fromInteger . fst) IP.natural; n <- fst <$> IP.name
538539 hint <- fst <$> IP.fnName
539540 return (Right (DoProofSearch upd False l n [hint]))
test/interactive010/expected+14−10
@@ -7,14 +7,18 @@ Usage is :printdef <functionname>
77pat {ty_503} : Type toplevel.u. pat {__interface_504} : Prelude.Interfaces.Fractional {ty_503}. Prelude.Interfaces./ {ty_503} {__interface_504}
88
99 : pty {ty_503} : Type toplevel.u. pty {__interface_504} : Prelude.Interfaces.Fractional {ty_503}. {ty_503} -> {ty_503} -> {ty_503}
10−(input):1:1: error: expected: ":",
11− dependent type signature,
12− end of input
13−/<EOF>
14−^
15−(input):1:1: error: expected: ":",
16− dependent type signature,
17− end of input
18−++<EOF>
19−^
10+(input):1:1:
11+ |
12+1 | /
13+ | ^
14+unexpected '/'
15+expecting ':', dependent type signature, or end of input
16+
17+(input):1:1:
18+ |
19+1 | ++
20+ | ^
21+unexpected "++"
22+expecting ':', dependent type signature, or end of input
23+
2024Can't find implementation for Fractional ty
test/layout001/expected+67−70
@@ -1,76 +1,73 @@
1−./layout001a.idr:5:1: error: Wrong
2− indention: should be greater
3− than context
4− indentation, expected: space
5−y
6−^
7−./layout001b.idr:5:3: error: Wrong
8− indention: should be greater
9− than context
10− indentation, expected: space
11−= y
12− ^
13−./layout001c.idr:3:1: error: Wrong
14− indention: should be greater
15− than context
16− indentation, expected: space
17−2
18−^
19−./layout001e.idr:6:1: error: Wrong
20− indention: should be greater
21− than context
22− indentation, expected: space
23−3
24−^
25−./layout001f.idr:6:2: error: Wrong
26− indention: should be greater
27− than context
28− indentation, expected: space
29− 3
30− ^
31−./layout001g.idr:6:3: error: Wrong
32− indention: should be greater
33− than context
34− indentation, expected: space
35− 3
36− ^
37−./layout001h.idr:6:3: error: Wrong
38− indention: should be greater
39− than context
40− indentation, expected: space
41− 3
42− ^
43−./layout001i.idr:6:4: error: Wrong
44− indention: should be greater
45− than context
46− indentation, expected: space
47− 3
48− ^
49−./layout001j.idr:6:5: error: Wrong
50− indention: should be greater
51− than context
52− indentation, expected: space
53− 3
54− ^
55−./layout001l.idr:6:1: error: Wrong
56− indention: should be greater
57− than context
58− indentation, expected: space
59−y
60−^
1+./layout001a.idr:5:1:
2+ |
3+5 | y
4+ | ^
5+Wrong indention: should be greater than context indentation
6+
7+./layout001b.idr:5:3:
8+ |
9+5 | = y
10+ | ^
11+Wrong indention: should be greater than context indentation
12+
13+./layout001c.idr:3:1:
14+ |
15+3 | 2
16+ | ^
17+= is not a valid operator
18+Wrong indention: should be greater than context indentation
19+
20+./layout001e.idr:6:1:
21+ |
22+6 | 3
23+ | ^
24+Wrong indention: should be greater than context indentation
25+
26+./layout001f.idr:6:2:
27+ |
28+6 | 3
29+ | ^
30+Wrong indention: should be greater than context indentation
31+
32+./layout001g.idr:6:3:
33+ |
34+6 | 3
35+ | ^
36+Wrong indention: should be greater than context indentation
37+
38+./layout001h.idr:6:3:
39+ |
40+6 | 3
41+ | ^
42+Wrong indention: should be greater than context indentation
43+
44+./layout001i.idr:6:4:
45+ |
46+6 | 3
47+ | ^
48+Wrong indention: should be greater than context indentation
49+
50+./layout001j.idr:6:5:
51+ |
52+6 | 3
53+ | ^
54+Wrong indention: should be greater than context indentation
55+
56+./layout001l.idr:6:1:
57+ |
58+6 | y
59+ | ^
60+Wrong indention: should be greater than context indentation
61+
6162mplus1.idr:13:31:When checking right hand side of term with expected type
6263 Maybe Int
6364
6465When checking an application of function Prelude.Applicative.pure:
6566 No such variable f
66−./mplus2.idr:17:37: error: not
67− end of block, expected: ")",
68− "->", ";", "in",
69− ambiguous use of a left-associative operator,
70− ambiguous use of a non-associative operator,
71− ambiguous use of a right-associative operator,
72− do block expression,
73− end of input
74− `mplus` pure f
75− ^
67+./mplus2.idr:17:37:
68+ |
69+17 | `mplus` pure f
70+ | ^
71+not end of block
72+
7673mplus3.idr:11:1:warning - Unreachable case: term
test/pkg004/expected+6−5
@@ -1,5 +1,6 @@
1−Uncaught error: user error (test.ipkg:9:1: error: filename
2− must contain no directory
3− component, expected: space
4−<EOF>
5−^ )
1+Uncaught error: user error (test.ipkg:9:1:
2+ |
3+9 | <empty line>
4+ | ^
5+filename must contain no directory component
6+)
test/pkg004/test.ipkg+1−1
@@ -5,4 +5,4 @@ modules = Main
55opts = "--warnpartial --warnreach --nocolour --quiet --consolewidth 80"
66
77main = Main
8−executable = "filenames/cannot include\a directory separator"
8+executable = "filenames/cannot include\\a directory separator"
test/regression002/expected+24−24
@@ -72,16 +72,18 @@ reg049.idr:5:6:When checking right hand side of uhOh with expected type
7272 Void
7373
7474No such variable Bogus
75−./badbangop.idr:7:1: error: ! is
76− not a valid
77− operator, expected: space
78−(!) : List a -> Nat -> Maybe a
79−^
80−./baddoublebang.idr:6:28: error: unexpected
81− Operator without known fixity:
82− !!, expected: space
83−doubleBang mmn = do pure !!mmn
84− ^
75+./badbangop.idr:7:1:
76+ |
77+7 | (!) : List a -> Nat -> Maybe a
78+ | ^
79+! is not a valid operator
80+
81+./baddoublebang.idr:6:28:
82+ |
83+6 | doubleBang mmn = do pure !!mmn
84+ | ^
85+unexpected Operator without known fixity: !!
86+
8587reg054.idr:18:5:When checking left hand side of inf:
8688When checking an application of constructor Main.MkInfer:
8789 Attempting concrete match on polymorphic argument: 0
@@ -118,20 +120,18 @@ Type level variable nat is not Main.nat
118120Mod.idr:11:1:public export Mod.natexp can't refer to export Mod.natfn
119121reg070.idr:7:1:
120122Test_show.Te implementation of Prelude.Show.Show is possibly not total due to: Prelude.Show.Test_show.Te implementation of Prelude.Show.Show, method show
121−./reg076.idr:8:1: error: Missing
122− fixity declaration for
123− Main.:>, expected: "->", "=>",
124− ambiguous use of a left-associative operator,
125− ambiguous use of a non-associative operator,
126− ambiguous use of a right-associative operator
127−<EOF>
128−^
129−./reg077.idr:3:1: error: Missing
130− fixity declaration for
131− Main.:>>, expected: ")", ";",
132− "in", start of block
133−<EOF>
134−^
123+./reg076.idr:8:1:
124+ |
125+8 | <empty line>
126+ | ^
127+Missing fixity declaration for Main.:>
128+
129+./reg077.idr:3:1:
130+ |
131+3 | <empty line>
132+ | ^
133+Missing fixity declaration for Main.:>>
134+
135135DoubleEquality.idr:4:87:When checking right hand side of oops with expected type
136136 Void
137137