on master help sign in
Remove unused parsing typeclasses
commit6cb8f749c368d9db5fa74b1b2f6f7a4cfdda6dd2 authorJason Felice <jason.m.felice@gmail.com> dateSun 29 Oct 2017, 19:33 (9 years ago) parent6263397
2 files changed+9−15
src/Idris/Package/Parser.hs+4−8 src/Idris/Parser/Helpers.hs+5−7
src/Idris/Package/Parser.hs+4−8
@@ -11,10 +11,9 @@ module Idris.Package.Parser where
1111import Idris.CmdOptions
1212import Idris.Imports
1313import Idris.Package.Common
14−import Idris.Parser.Helpers (HasLastTokenSpan, IdrisInnerParser, MonadicParsing,
15− eol, getLastTokenSpan, iName, identifier, isEol,
16− lchar, multiLineComment, packageName,
17− parseErrorDoc, reserved, runparser,
14+import Idris.Parser.Helpers (IdrisInnerParser, MonadicParsing, eol, iName,
15+ identifier, isEol, lchar, multiLineComment,
16+ packageName, parseErrorDoc, reserved, runparser,
1817 simpleWhiteSpace, singleLineComment)
1918
2019import Control.Applicative
@@ -29,9 +28,6 @@ import qualified Text.Trifecta as P
2928
3029type PParser = StateT PkgDesc IdrisInnerParser
3130
32−instance HasLastTokenSpan PParser where
33− getLastTokenSpan = return Nothing
34−
3531#if MIN_VERSION_base(4,9,0)
3632instance {-# OVERLAPPING #-} P.DeltaParsing PParser where
3733 line = lift P.line
@@ -83,7 +79,7 @@ pPkgName = (either fail pure . pkgName =<< packageName) <?> "PkgName"
8379-- | Parses a filename.
8480-- |
8581-- | Treated for now as an identifier or a double-quoted string.
86−filename :: (MonadicParsing m, HasLastTokenSpan m) => m String
82+filename :: (MonadicParsing m) => m String
8783filename = (do
8884 filename <- P.token $
8985 -- Treat a double-quoted string as a filename to support spaces.
src/Idris/Parser/Helpers.hs+5−7
@@ -59,7 +59,6 @@ instance {-# OVERLAPPING #-} P.DeltaParsing IdrisParser where
5959 {-# INLINE rend #-}
6060 restOfLine = lift P.restOfLine
6161 {-# INLINE restOfLine #-}
62−
6362#endif
6463
6564instance {-# OVERLAPPING #-} P.TokenParsing IdrisParser where
@@ -72,8 +71,9 @@ instance {-# OVERLAPPING #-} P.TokenParsing IdrisParser where
7271 whiteSpace
7372 put (s { lastTokenSpan = Just (FC fn (sl, sc) (el, ec)) })
7473 return r
74+
7575-- | Generalized monadic parsing constraint type
76−type MonadicParsing m = (P.DeltaParsing m, LookAheadParsing m, P.TokenParsing m, Monad m)
76+type MonadicParsing m = (P.DeltaParsing m, LookAheadParsing m, Monad m)
7777
7878class HasLastTokenSpan m where
7979 getLastTokenSpan :: m (Maybe FC)
@@ -335,13 +335,11 @@ identifier = P.try $ do
335335 return (ident, FC f (l, c) (l, c + length ident))
336336
337337-- | Parses an identifier with possible namespace as a name
338−iName :: (MonadicParsing m, HasLastTokenSpan m) => [String] -> m (Name, FC)
339−iName bad = do (n, fc) <- maybeWithNS identifier False bad
340− return (n, fc)
341− <?> "name"
338+iName :: (MonadicParsing m) => [String] -> m (Name, FC)
339+iName bad = maybeWithNS identifier False bad <?> "name"
342340
343341-- | Parses an string possibly prefixed by a namespace
344−maybeWithNS :: (MonadicParsing m, HasLastTokenSpan m) => m (String, FC) -> Bool -> [String] -> m (Name, FC)
342+maybeWithNS :: (MonadicParsing m) => m (String, FC) -> Bool -> [String] -> m (Name, FC)
345343maybeWithNS parser ascend bad = do
346344 fc <- getFC
347345 i <- P.option "" (lookAhead (fst <$> identifier))