Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Struct parser.
We do still have to do failure checking, because unlike C we check some types (e.g. bitfields). Hopefully inlining can remove those checks when unnecessary.
Synopsis
- type PureMode = Proxy# Void
- type IOMode = State# RealWorld
- type STMode s = State# s
- type ParserT# (st :: ZeroBitType) e a = ForeignPtrContents -> Addr# -> Int# -> st -> Res# st e a
- newtype ParserT (st :: ZeroBitType) e a = ParserT {
- runParserT# :: ParserT# st e a
- type Parser = ParserT PureMode
- type ParserIO = ParserT IOMode
- type ParserST s = ParserT (STMode s)
- type Res# (st :: ZeroBitType) e a = (# st, ResI# e a #)
- type ResI# e a = (# (# a #) | (# #) | (# e #) #)
- pattern OK# :: (st :: ZeroBitType) -> a -> Res# st e a
- pattern Fail# :: (st :: ZeroBitType) -> Res# st e a
- pattern Err# :: (st :: ZeroBitType) -> e -> Res# st e a
- unsafeRunParserBs :: forall a e. ByteString -> Parser e a -> Result e a
- unsafeRunParserPtr :: forall a e. Ptr Word8 -> Parser e a -> Result e a
- unsafeRunParserFPtr :: forall a e. ForeignPtr Word8 -> Parser e a -> Result e a
- unsafeRunParser' :: forall a e. Addr# -> ForeignPtrContents -> Parser e a -> Result e a
- data Result e a
- constParse :: a -> ParserT st e a
- sequenceParsers :: Int -> (a -> b -> c) -> ParserT st e a -> ParserT st e b -> ParserT st e c
- prim :: forall a st e. Prim' a => ParserT st e a
- lit :: Eq a => a -> ParserT st e a -> ParserT st e ()
- withLit :: Eq a => Int# -> a -> ParserT st e a -> ParserT st e r -> ParserT st e r
Documentation
type ParserT# (st :: ZeroBitType) e a Source #
= ForeignPtrContents | pointer provenance |
-> Addr# | base address |
-> Int# | cursor offset from base |
-> st | state token |
-> Res# st e a |
newtype ParserT (st :: ZeroBitType) e a Source #
ParserT | |
|
type Res# (st :: ZeroBitType) e a = (# st, ResI# e a #) Source #
pattern OK# :: (st :: ZeroBitType) -> a -> Res# st e a Source #
Res#
constructor for a successful parse.
Contains the return value and a state token.
pattern Fail# :: (st :: ZeroBitType) -> Res# st e a Source #
Res#
constructor for recoverable failure.
Contains only a state token.
pattern Err# :: (st :: ZeroBitType) -> e -> Res# st e a Source #
Res#
constructor for errors which are by default non-recoverable.
Contains the error, plus a state token.
unsafeRunParserBs :: forall a e. ByteString -> Parser e a -> Result e a Source #
caller must guarantee that buffer is long enough for parser!!
unsafeRunParserPtr :: forall a e. Ptr Word8 -> Parser e a -> Result e a Source #
caller must guarantee that buffer is long enough for parser!!
unsafeRunParserFPtr :: forall a e. ForeignPtr Word8 -> Parser e a -> Result e a Source #
caller must guarantee that buffer is long enough for parser!!
unsafeRunParser' :: forall a e. Addr# -> ForeignPtrContents -> Parser e a -> Result e a Source #
caller must guarantee that buffer is long enough for parser!!
Higher-level boxed data type for parsing results.
constParse :: a -> ParserT st e a Source #
can't provide via pure
as no Applicative