simple-parser-0.6.0: Simple parser combinators
Safe HaskellNone
LanguageHaskell2010

SimpleParser.Stream

Description

This reworks Stream to split interfaces. See Text.Megaparsec.Stream.

Synopsis

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.

Minimal complete definition

streamTake1, streamTakeN, streamTakeWhile

Associated Types

type Chunk s :: Type Source #

type Token s :: Type Source #

Methods

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

Instances details
Stream Text Source # 
Instance details

Defined in SimpleParser.Stream

Associated Types

type Chunk Text Source #

type Token Text Source #

Stream [a] Source # 
Instance details

Defined in SimpleParser.Stream

Associated Types

type Chunk [a] Source #

type Token [a] Source #

Methods

streamTake1 :: [a] -> Maybe (Token [a], [a]) Source #

streamTakeN :: Int -> [a] -> Maybe (Chunk [a], [a]) Source #

streamTakeWhile :: (Token [a] -> Bool) -> [a] -> (Chunk [a], [a]) Source #

streamDropN :: Int -> [a] -> Maybe (Int, [a]) Source #

streamDropWhile :: (Token [a] -> Bool) -> [a] -> (Int, [a]) Source #

Stream (Seq a) Source # 
Instance details

Defined in SimpleParser.Stream

Associated Types

type Chunk (Seq a) Source #

type Token (Seq a) Source #

Methods

streamTake1 :: Seq a -> Maybe (Token (Seq a), Seq a) Source #

streamTakeN :: Int -> Seq a -> Maybe (Chunk (Seq a), Seq a) Source #

streamTakeWhile :: (Token (Seq a) -> Bool) -> Seq a -> (Chunk (Seq a), Seq a) Source #

streamDropN :: Int -> Seq a -> Maybe (Int, Seq a) Source #

streamDropWhile :: (Token (Seq a) -> Bool) -> Seq a -> (Int, Seq a) Source #

(Stream s, Token s ~ Char) => Stream (LinePosStream s) Source # 
Instance details

Defined in SimpleParser.Stream

Associated Types

type Chunk (LinePosStream s) Source #

type Token (LinePosStream s) Source #

Stream s => Stream (OffsetStream s) Source # 
Instance details

Defined in SimpleParser.Stream

Associated Types

type Chunk (OffsetStream s) Source #

type Token (OffsetStream s) Source #

defaultStreamDropWhile :: Stream s => (Token s -> Bool) -> s -> (Int, s) Source #

class Stream s => PosStream s where Source #

PosStream adds position tracking to a Stream.

Associated Types

type Pos s :: Type Source #

Methods

streamViewPos :: s -> Pos s Source #

Instances

Instances details
(Stream s, Token s ~ Char) => PosStream (LinePosStream s) Source # 
Instance details

Defined in SimpleParser.Stream

Associated Types

type Pos (LinePosStream s) Source #

Stream s => PosStream (OffsetStream s) Source # 
Instance details

Defined in SimpleParser.Stream

Associated Types

type Pos (OffsetStream s) Source #

newtype Offset Source #

Constructors

Offset 

Fields

Instances

Instances details
Enum Offset Source # 
Instance details

Defined in SimpleParser.Stream

Eq Offset Source # 
Instance details

Defined in SimpleParser.Stream

Methods

(==) :: Offset -> Offset -> Bool #

(/=) :: Offset -> Offset -> Bool #

Integral Offset Source # 
Instance details

Defined in SimpleParser.Stream

Num Offset Source # 
Instance details

Defined in SimpleParser.Stream

Ord Offset Source # 
Instance details

Defined in SimpleParser.Stream

Real Offset Source # 
Instance details

Defined in SimpleParser.Stream

Show Offset Source # 
Instance details

Defined in SimpleParser.Stream

data OffsetStream s Source #

Stream wrapper that maintains an offset position.

Constructors

OffsetStream 

Fields

Instances

Instances details
Functor OffsetStream Source # 
Instance details

Defined in SimpleParser.Stream

Methods

fmap :: (a -> b) -> OffsetStream a -> OffsetStream b #

(<$) :: a -> OffsetStream b -> OffsetStream a #

Foldable OffsetStream Source # 
Instance details

Defined in SimpleParser.Stream

Methods

fold :: Monoid m => OffsetStream m -> m #

foldMap :: Monoid m => (a -> m) -> OffsetStream a -> m #

foldMap' :: Monoid m => (a -> m) -> OffsetStream a -> m #

foldr :: (a -> b -> b) -> b -> OffsetStream a -> b #

foldr' :: (a -> b -> b) -> b -> OffsetStream a -> b #

foldl :: (b -> a -> b) -> b -> OffsetStream a -> b #

foldl' :: (b -> a -> b) -> b -> OffsetStream a -> b #

foldr1 :: (a -> a -> a) -> OffsetStream a -> a #

foldl1 :: (a -> a -> a) -> OffsetStream a -> a #

toList :: OffsetStream a -> [a] #

null :: OffsetStream a -> Bool #

length :: OffsetStream a -> Int #

elem :: Eq a => a -> OffsetStream a -> Bool #

maximum :: Ord a => OffsetStream a -> a #

minimum :: Ord a => OffsetStream a -> a #

sum :: Num a => OffsetStream a -> a #

product :: Num a => OffsetStream a -> a #

Traversable OffsetStream Source # 
Instance details

Defined in SimpleParser.Stream

Methods

traverse :: Applicative f => (a -> f b) -> OffsetStream a -> f (OffsetStream b) #

sequenceA :: Applicative f => OffsetStream (f a) -> f (OffsetStream a) #

mapM :: Monad m => (a -> m b) -> OffsetStream a -> m (OffsetStream b) #

sequence :: Monad m => OffsetStream (m a) -> m (OffsetStream a) #

Eq s => Eq (OffsetStream s) Source # 
Instance details

Defined in SimpleParser.Stream

Show s => Show (OffsetStream s) Source # 
Instance details

Defined in SimpleParser.Stream

Stream s => PosStream (OffsetStream s) Source # 
Instance details

Defined in SimpleParser.Stream

Associated Types

type Pos (OffsetStream s) Source #

Stream s => Stream (OffsetStream s) Source # 
Instance details

Defined in SimpleParser.Stream

Associated Types

type Chunk (OffsetStream s) Source #

type Token (OffsetStream s) Source #

type Pos (OffsetStream s) Source # 
Instance details

Defined in SimpleParser.Stream

type Chunk (OffsetStream s) Source # 
Instance details

Defined in SimpleParser.Stream

type Chunk (OffsetStream s) = Chunk s
type Token (OffsetStream s) Source # 
Instance details

Defined in SimpleParser.Stream

type Token (OffsetStream s) = Token s

newtype Line Source #

Constructors

Line 

Fields

Instances

Instances details
Enum Line Source # 
Instance details

Defined in SimpleParser.Stream

Methods

succ :: Line -> Line #

pred :: Line -> Line #

toEnum :: Int -> Line #

fromEnum :: Line -> Int #

enumFrom :: Line -> [Line] #

enumFromThen :: Line -> Line -> [Line] #

enumFromTo :: Line -> Line -> [Line] #

enumFromThenTo :: Line -> Line -> Line -> [Line] #

Eq Line Source # 
Instance details

Defined in SimpleParser.Stream

Methods

(==) :: Line -> Line -> Bool #

(/=) :: Line -> Line -> Bool #

Integral Line Source # 
Instance details

Defined in SimpleParser.Stream

Methods

quot :: Line -> Line -> Line #

rem :: Line -> Line -> Line #

div :: Line -> Line -> Line #

mod :: Line -> Line -> Line #

quotRem :: Line -> Line -> (Line, Line) #

divMod :: Line -> Line -> (Line, Line) #

toInteger :: Line -> Integer #

Num Line Source # 
Instance details

Defined in SimpleParser.Stream

Methods

(+) :: Line -> Line -> Line #

(-) :: Line -> Line -> Line #

(*) :: Line -> Line -> Line #

negate :: Line -> Line #

abs :: Line -> Line #

signum :: Line -> Line #

fromInteger :: Integer -> Line #

Ord Line Source # 
Instance details

Defined in SimpleParser.Stream

Methods

compare :: Line -> Line -> Ordering #

(<) :: Line -> Line -> Bool #

(<=) :: Line -> Line -> Bool #

(>) :: Line -> Line -> Bool #

(>=) :: Line -> Line -> Bool #

max :: Line -> Line -> Line #

min :: Line -> Line -> Line #

Real Line Source # 
Instance details

Defined in SimpleParser.Stream

Methods

toRational :: Line -> Rational #

Show Line Source # 
Instance details

Defined in SimpleParser.Stream

Methods

showsPrec :: Int -> Line -> ShowS #

show :: Line -> String #

showList :: [Line] -> ShowS #

newtype Col Source #

Constructors

Col 

Fields

Instances

Instances details
Enum Col Source # 
Instance details

Defined in SimpleParser.Stream

Methods

succ :: Col -> Col #

pred :: Col -> Col #

toEnum :: Int -> Col #

fromEnum :: Col -> Int #

enumFrom :: Col -> [Col] #

enumFromThen :: Col -> Col -> [Col] #

enumFromTo :: Col -> Col -> [Col] #

enumFromThenTo :: Col -> Col -> Col -> [Col] #

Eq Col Source # 
Instance details

Defined in SimpleParser.Stream

Methods

(==) :: Col -> Col -> Bool #

(/=) :: Col -> Col -> Bool #

Integral Col Source # 
Instance details

Defined in SimpleParser.Stream

Methods

quot :: Col -> Col -> Col #

rem :: Col -> Col -> Col #

div :: Col -> Col -> Col #

mod :: Col -> Col -> Col #

quotRem :: Col -> Col -> (Col, Col) #

divMod :: Col -> Col -> (Col, Col) #

toInteger :: Col -> Integer #

Num Col Source # 
Instance details

Defined in SimpleParser.Stream

Methods

(+) :: Col -> Col -> Col #

(-) :: Col -> Col -> Col #

(*) :: Col -> Col -> Col #

negate :: Col -> Col #

abs :: Col -> Col #

signum :: Col -> Col #

fromInteger :: Integer -> Col #

Ord Col Source # 
Instance details

Defined in SimpleParser.Stream

Methods

compare :: Col -> Col -> Ordering #

(<) :: Col -> Col -> Bool #

(<=) :: Col -> Col -> Bool #

(>) :: Col -> Col -> Bool #

(>=) :: Col -> Col -> Bool #

max :: Col -> Col -> Col #

min :: Col -> Col -> Col #

Real Col Source # 
Instance details

Defined in SimpleParser.Stream

Methods

toRational :: Col -> Rational #

Show Col Source # 
Instance details

Defined in SimpleParser.Stream

Methods

showsPrec :: Int -> Col -> ShowS #

show :: Col -> String #

showList :: [Col] -> ShowS #

data LinePos Source #

A 0-based line/col position in a character-based stream.

Constructors

LinePos 

Fields

Instances

Instances details
Eq LinePos Source # 
Instance details

Defined in SimpleParser.Stream

Methods

(==) :: LinePos -> LinePos -> Bool #

(/=) :: LinePos -> LinePos -> Bool #

Ord LinePos Source # 
Instance details

Defined in SimpleParser.Stream

Show LinePos Source # 
Instance details

Defined in SimpleParser.Stream

data LinePosStream s Source #

Stream wrapper that maintains a line/col position.

Constructors

LinePosStream 

Fields

Instances

Instances details
Functor LinePosStream Source # 
Instance details

Defined in SimpleParser.Stream

Methods

fmap :: (a -> b) -> LinePosStream a -> LinePosStream b #

(<$) :: a -> LinePosStream b -> LinePosStream a #

Foldable LinePosStream Source # 
Instance details

Defined in SimpleParser.Stream

Methods

fold :: Monoid m => LinePosStream m -> m #

foldMap :: Monoid m => (a -> m) -> LinePosStream a -> m #

foldMap' :: Monoid m => (a -> m) -> LinePosStream a -> m #

foldr :: (a -> b -> b) -> b -> LinePosStream a -> b #

foldr' :: (a -> b -> b) -> b -> LinePosStream a -> b #

foldl :: (b -> a -> b) -> b -> LinePosStream a -> b #

foldl' :: (b -> a -> b) -> b -> LinePosStream a -> b #

foldr1 :: (a -> a -> a) -> LinePosStream a -> a #

foldl1 :: (a -> a -> a) -> LinePosStream a -> a #

toList :: LinePosStream a -> [a] #

null :: LinePosStream a -> Bool #

length :: LinePosStream a -> Int #

elem :: Eq a => a -> LinePosStream a -> Bool #

maximum :: Ord a => LinePosStream a -> a #

minimum :: Ord a => LinePosStream a -> a #

sum :: Num a => LinePosStream a -> a #

product :: Num a => LinePosStream a -> a #

Traversable LinePosStream Source # 
Instance details

Defined in SimpleParser.Stream

Methods

traverse :: Applicative f => (a -> f b) -> LinePosStream a -> f (LinePosStream b) #

sequenceA :: Applicative f => LinePosStream (f a) -> f (LinePosStream a) #

mapM :: Monad m => (a -> m b) -> LinePosStream a -> m (LinePosStream b) #

sequence :: Monad m => LinePosStream (m a) -> m (LinePosStream a) #

Eq s => Eq (LinePosStream s) Source # 
Instance details

Defined in SimpleParser.Stream

Show s => Show (LinePosStream s) Source # 
Instance details

Defined in SimpleParser.Stream

(Stream s, Token s ~ Char) => PosStream (LinePosStream s) Source # 
Instance details

Defined in SimpleParser.Stream

Associated Types

type Pos (LinePosStream s) Source #

(Stream s, Token s ~ Char) => Stream (LinePosStream s) Source # 
Instance details

Defined in SimpleParser.Stream

Associated Types

type Chunk (LinePosStream s) Source #

type Token (LinePosStream s) Source #

type Pos (LinePosStream s) Source # 
Instance details

Defined in SimpleParser.Stream

type Chunk (LinePosStream s) Source # 
Instance details

Defined in SimpleParser.Stream

type Token (LinePosStream s) Source # 
Instance details

Defined in SimpleParser.Stream

data Span p Source #

A range between two positions.

Constructors

Span 

Fields

Instances

Instances details
Eq p => Eq (Span p) Source # 
Instance details

Defined in SimpleParser.Stream

Methods

(==) :: Span p -> Span p -> Bool #

(/=) :: Span p -> Span p -> Bool #

Ord p => Ord (Span p) Source # 
Instance details

Defined in SimpleParser.Stream

Methods

compare :: Span p -> Span p -> Ordering #

(<) :: Span p -> Span p -> Bool #

(<=) :: Span p -> Span p -> Bool #

(>) :: Span p -> Span p -> Bool #

(>=) :: Span p -> Span p -> Bool #

max :: Span p -> Span p -> Span p #

min :: Span p -> Span p -> Span p #

Show p => Show (Span p) Source # 
Instance details

Defined in SimpleParser.Stream

Methods

showsPrec :: Int -> Span p -> ShowS #

show :: Span p -> String #

showList :: [Span p] -> ShowS #