Safe Haskell | None |
---|---|
Language | Haskell2010 |
This reworks Stream
to split interfaces.
See Text.Megaparsec.Stream.
Synopsis
- class Chunked (Chunk s) (Token s) => Stream s where
- type Chunk s :: Type
- type Token s :: Type
- type Pos s :: Type
- streamViewPos :: s -> Pos s
- streamTake1 :: s -> Maybe (Token s, s)
- streamTakeN :: Int -> s -> Maybe (Chunk s, s)
- streamTakeWhile :: (Token s -> Bool) -> s -> (Chunk s, s)
- streamDropN :: Int -> s -> Maybe (Int, s)
- streamDropWhile :: (Token s -> Bool) -> s -> (Int, s)
- type TextualStream s = (Stream s, Token s ~ Char, TextualChunked (Chunk s))
- defaultStreamDropN :: Stream s => Int -> s -> Maybe (Int, s)
- defaultStreamDropWhile :: Stream s => (Token s -> Bool) -> s -> (Int, s)
- newtype Offset = Offset {}
- data OffsetStream s = OffsetStream {}
- newOffsetStream :: s -> OffsetStream s
- newtype Line = Line {}
- newtype Col = Col {}
- data LinePos = LinePos {}
- data LinePosStream s = LinePosStream {
- lpsLinePos :: !LinePos
- lpsState :: !s
- newLinePosStream :: s -> LinePosStream s
- data Span p = Span {}
Documentation
class Chunked (Chunk s) (Token s) => Stream s where Source #
Stream
lets us peel off tokens and chunks for parsing
with explicit state passing.
streamViewPos :: s -> Pos s Source #
streamTake1 :: s -> Maybe (Token s, s) Source #
streamTakeN :: Int -> s -> Maybe (Chunk s, s) Source #
streamTakeWhile :: (Token s -> Bool) -> s -> (Chunk s, s) Source #
streamDropN :: Int -> s -> Maybe (Int, s) Source #
streamDropWhile :: (Token s -> Bool) -> s -> (Int, s) Source #
Instances
type TextualStream s = (Stream s, Token s ~ Char, TextualChunked (Chunk s)) Source #
data OffsetStream s Source #
Stream wrapper that maintains an offset position.
Instances
newOffsetStream :: s -> OffsetStream s Source #
A 0-based line/col position in a character-based stream.
data LinePosStream s Source #
Stream wrapper that maintains a line/col position.
LinePosStream | |
|
Instances
newLinePosStream :: s -> LinePosStream s Source #