Expose the endOfLine parser through MonadParser to allow enforcing reaching the end of input in page parser
This commit is contained in:
parent
ecfd682b34
commit
3f6b0651f3
1 changed files with 5 additions and 1 deletions
|
@ -17,7 +17,8 @@ import Control.Monad.Fail (MonadFail(..))
|
|||
import Control.Monad.State (StateT(..), evalStateT)
|
||||
import Control.Monad.Trans (MonadTrans(..))
|
||||
import qualified Data.Attoparsec.ByteString.Char8 as Atto (
|
||||
Parser, char, parseOnly, satisfy, string, take, takeWhile, takeWhile1
|
||||
Parser, char, endOfInput, parseOnly, satisfy, string, take, takeWhile
|
||||
, takeWhile1
|
||||
)
|
||||
import Data.ByteString (ByteString)
|
||||
import Data.ByteString.Char8.Util (B16Int(..))
|
||||
|
@ -32,6 +33,7 @@ class MonadDeps m => MonadParser m where
|
|||
block :: Int -> m ByteString
|
||||
char :: Char -> m Char
|
||||
decNumber :: m ByteString
|
||||
endOfInput :: m ()
|
||||
hexNumber :: m B16Int
|
||||
oneOf :: String -> m Char
|
||||
string :: ByteString -> m ByteString
|
||||
|
@ -41,6 +43,7 @@ class MonadDeps m => MonadParser m where
|
|||
instance MonadParser Atto.Parser where
|
||||
block = Atto.take
|
||||
char = Atto.char
|
||||
endOfInput = Atto.endOfInput
|
||||
decNumber = Atto.takeWhile1 (`Set.member` digits)
|
||||
hexNumber = B16Int <$> Atto.takeWhile1 (`Set.member` hexDigits)
|
||||
oneOf charSet = Atto.satisfy (`elem` charSet)
|
||||
|
@ -51,6 +54,7 @@ instance MonadParser Atto.Parser where
|
|||
instance (MonadParser m, MonadTrans t, MonadDeps (t m)) => MonadParser (t m) where
|
||||
block = lift . block
|
||||
char = lift . char
|
||||
endOfInput = lift $ endOfInput
|
||||
decNumber = lift $ decNumber
|
||||
hexNumber = lift $ hexNumber
|
||||
oneOf = lift . oneOf
|
||||
|
|
Loading…
Reference in a new issue