Safe Haskell | Safe-Inferred |
---|---|
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
- 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))
- class Stream s => PosStream s where
- type Pos s :: Type
- streamViewPos :: s -> Pos 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 {}
- class HasLinePos p where
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.
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 #
class Stream s => PosStream s where Source #
streamViewPos :: s -> Pos s Source #
Instances
(Stream s, Token s ~ Char) => PosStream (LinePosStream s) Source # | |
Defined in SimpleParser.Stream type Pos (LinePosStream s) Source # streamViewPos :: LinePosStream s -> Pos (LinePosStream s) Source # | |
Stream s => PosStream (OffsetStream s) Source # | |
Defined in SimpleParser.Stream type Pos (OffsetStream s) Source # streamViewPos :: OffsetStream s -> Pos (OffsetStream s) Source # | |
PosStream (LexedStream p a) Source # | |
Defined in SimpleParser.Lexer type Pos (LexedStream p a) Source # streamViewPos :: LexedStream p a -> Pos (LexedStream p a) 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 #
A range between two positions.
class HasLinePos p where Source #
Allows projections into (Line, Col) for more exotic stream positions.