trifecta-1.7: A modern parser combinator library with convenient diagnostics

Copyright(C) 2011-2015 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Text.Trifecta.Rendering

Contents

Description

The type for Lines will very likely change over time, to enable drawing lit up multi-character versions of control characters for ^Z, ^[, 0xff, etc. This will make for much nicer diagnostics when working with protocols.

Synopsis

Documentation

data Rendering Source #

Constructors

Rendering !Delta !Int64 !Int64 (Lines -> Lines) (Delta -> Lines -> Lines) 

Instances

Show Rendering Source # 
Semigroup Rendering Source # 
Monoid Rendering Source # 
Pretty Rendering Source # 
HasDelta Rendering Source # 
Renderable Rendering Source # 
HasRendering Rendering Source # 
Reducer Fixit Rendering Source # 
Reducer Span Rendering Source # 
Reducer Caret Rendering Source # 
Reducer (Spanned a) Rendering Source # 
Reducer (Careted a) Rendering Source # 

class Source t where Source #

Minimal complete definition

source

Methods

source :: t -> (Int64, Int64, Lines -> Lines) Source #

rendered :: Source s => Delta -> s -> Rendering Source #

create a drawing surface

data Rendered a Source #

Constructors

a :@ Rendering 

Instances

Functor Rendered Source # 

Methods

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

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

Foldable Rendered Source # 

Methods

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

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

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

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

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

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

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

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

toList :: Rendered a -> [a] #

null :: Rendered a -> Bool #

length :: Rendered a -> Int #

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

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

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

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

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

Traversable Rendered Source # 

Methods

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

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

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

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

Comonad Rendered Source # 

Methods

extract :: Rendered a -> a #

duplicate :: Rendered a -> Rendered (Rendered a) #

extend :: (Rendered a -> b) -> Rendered a -> Rendered b #

ComonadApply Rendered Source # 

Methods

(<@>) :: Rendered (a -> b) -> Rendered a -> Rendered b #

(@>) :: Rendered a -> Rendered b -> Rendered b #

(<@) :: Rendered a -> Rendered b -> Rendered a #

Show a => Show (Rendered a) Source # 

Methods

showsPrec :: Int -> Rendered a -> ShowS #

show :: Rendered a -> String #

showList :: [Rendered a] -> ShowS #

HasDelta (Rendered a) Source # 

Methods

delta :: Rendered a -> Delta Source #

HasBytes (Rendered a) Source # 

Methods

bytes :: Rendered a -> Int64 Source #

Renderable (Rendered a) Source # 

Carets

data Caret Source #

In file included from baz.c:9
In file included from bar.c:4
foo.c:8:36: note
int main(int argc, char ** argv) { int; }
                                   ^

Constructors

Caret !Delta !ByteString 

Instances

Eq Caret Source # 

Methods

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

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

Data Caret Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Caret -> c Caret #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Caret #

toConstr :: Caret -> Constr #

dataTypeOf :: Caret -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Caret) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Caret) #

gmapT :: (forall b. Data b => b -> b) -> Caret -> Caret #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Caret -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Caret -> r #

gmapQ :: (forall d. Data d => d -> u) -> Caret -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Caret -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Caret -> m Caret #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Caret -> m Caret #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Caret -> m Caret #

Ord Caret Source # 

Methods

compare :: Caret -> Caret -> Ordering #

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

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

(>) :: Caret -> Caret -> Bool #

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

max :: Caret -> Caret -> Caret #

min :: Caret -> Caret -> Caret #

Show Caret Source # 

Methods

showsPrec :: Int -> Caret -> ShowS #

show :: Caret -> String #

showList :: [Caret] -> ShowS #

Generic Caret Source # 

Associated Types

type Rep Caret :: * -> * #

Methods

from :: Caret -> Rep Caret x #

to :: Rep Caret x -> Caret #

Semigroup Caret Source # 

Methods

(<>) :: Caret -> Caret -> Caret #

sconcat :: NonEmpty Caret -> Caret #

stimes :: Integral b => b -> Caret -> Caret #

Hashable Caret Source # 

Methods

hashWithSalt :: Int -> Caret -> Int #

hash :: Caret -> Int #

HasDelta Caret Source # 

Methods

delta :: Caret -> Delta Source #

HasBytes Caret Source # 

Methods

bytes :: Caret -> Int64 Source #

HasCaret Caret Source # 
Renderable Caret Source # 
Reducer Caret Rendering Source # 
type Rep Caret Source # 
type Rep Caret = D1 (MetaData "Caret" "Text.Trifecta.Rendering" "trifecta-1.7-JbDrfuEnY4pL19DKxHFrrK" False) (C1 (MetaCons "Caret" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Delta)) (S1 (MetaSel (Nothing Symbol) SourceUnpack SourceStrict DecidedUnpack) (Rec0 ByteString))))

class HasCaret t where Source #

Minimal complete definition

caret

Methods

caret :: Lens' t Caret Source #

data Careted a Source #

Constructors

a :^ Caret 

Instances

Functor Careted Source # 

Methods

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

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

Foldable Careted Source # 

Methods

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

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

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

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

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

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

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

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

toList :: Careted a -> [a] #

null :: Careted a -> Bool #

length :: Careted a -> Int #

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

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

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

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

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

Traversable Careted Source # 

Methods

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

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

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

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

Comonad Careted Source # 

Methods

extract :: Careted a -> a #

duplicate :: Careted a -> Careted (Careted a) #

extend :: (Careted a -> b) -> Careted a -> Careted b #

ComonadApply Careted Source # 

Methods

(<@>) :: Careted (a -> b) -> Careted a -> Careted b #

(@>) :: Careted a -> Careted b -> Careted b #

(<@) :: Careted a -> Careted b -> Careted a #

Eq a => Eq (Careted a) Source # 

Methods

(==) :: Careted a -> Careted a -> Bool #

(/=) :: Careted a -> Careted a -> Bool #

Data a => Data (Careted a) Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Careted a -> c (Careted a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Careted a) #

toConstr :: Careted a -> Constr #

dataTypeOf :: Careted a -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (Careted a)) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Careted a)) #

gmapT :: (forall b. Data b => b -> b) -> Careted a -> Careted a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Careted a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Careted a -> r #

gmapQ :: (forall d. Data d => d -> u) -> Careted a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Careted a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Careted a -> m (Careted a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Careted a -> m (Careted a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Careted a -> m (Careted a) #

Ord a => Ord (Careted a) Source # 

Methods

compare :: Careted a -> Careted a -> Ordering #

(<) :: Careted a -> Careted a -> Bool #

(<=) :: Careted a -> Careted a -> Bool #

(>) :: Careted a -> Careted a -> Bool #

(>=) :: Careted a -> Careted a -> Bool #

max :: Careted a -> Careted a -> Careted a #

min :: Careted a -> Careted a -> Careted a #

Show a => Show (Careted a) Source # 

Methods

showsPrec :: Int -> Careted a -> ShowS #

show :: Careted a -> String #

showList :: [Careted a] -> ShowS #

Generic (Careted a) Source # 

Associated Types

type Rep (Careted a) :: * -> * #

Methods

from :: Careted a -> Rep (Careted a) x #

to :: Rep (Careted a) x -> Careted a #

Hashable a => Hashable (Careted a) Source # 

Methods

hashWithSalt :: Int -> Careted a -> Int #

hash :: Careted a -> Int #

HasDelta (Careted a) Source # 

Methods

delta :: Careted a -> Delta Source #

HasBytes (Careted a) Source # 

Methods

bytes :: Careted a -> Int64 Source #

HasCaret (Careted a) Source # 
Renderable (Careted a) Source # 
Reducer (Careted a) Rendering Source # 
type Rep (Careted a) Source # 

Spans

data Span Source #

Constructors

Span !Delta !Delta !ByteString 

Instances

Eq Span Source # 

Methods

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

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

Data Span Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Span -> c Span #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Span #

toConstr :: Span -> Constr #

dataTypeOf :: Span -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Span) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Span) #

gmapT :: (forall b. Data b => b -> b) -> Span -> Span #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Span -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Span -> r #

gmapQ :: (forall d. Data d => d -> u) -> Span -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Span -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Span -> m Span #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Span -> m Span #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Span -> m Span #

Ord Span Source # 

Methods

compare :: Span -> Span -> Ordering #

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

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

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

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

max :: Span -> Span -> Span #

min :: Span -> Span -> Span #

Show Span Source # 

Methods

showsPrec :: Int -> Span -> ShowS #

show :: Span -> String #

showList :: [Span] -> ShowS #

Generic Span Source # 

Associated Types

type Rep Span :: * -> * #

Methods

from :: Span -> Rep Span x #

to :: Rep Span x -> Span #

Semigroup Span Source # 

Methods

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

sconcat :: NonEmpty Span -> Span #

stimes :: Integral b => b -> Span -> Span #

Hashable Span Source # 

Methods

hashWithSalt :: Int -> Span -> Int #

hash :: Span -> Int #

HasSpan Span Source # 
Renderable Span Source # 
Reducer Span Rendering Source # 
type Rep Span Source # 

class HasSpan t where Source #

Minimal complete definition

span

Methods

span :: Lens' t Span Source #

data Spanned a Source #

Constructors

a :~ Span 

Instances

Functor Spanned Source # 

Methods

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

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

Foldable Spanned Source # 

Methods

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

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

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

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

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

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

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

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

toList :: Spanned a -> [a] #

null :: Spanned a -> Bool #

length :: Spanned a -> Int #

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

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

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

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

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

Traversable Spanned Source # 

Methods

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

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

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

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

Comonad Spanned Source # 

Methods

extract :: Spanned a -> a #

duplicate :: Spanned a -> Spanned (Spanned a) #

extend :: (Spanned a -> b) -> Spanned a -> Spanned b #

ComonadApply Spanned Source # 

Methods

(<@>) :: Spanned (a -> b) -> Spanned a -> Spanned b #

(@>) :: Spanned a -> Spanned b -> Spanned b #

(<@) :: Spanned a -> Spanned b -> Spanned a #

Eq a => Eq (Spanned a) Source # 

Methods

(==) :: Spanned a -> Spanned a -> Bool #

(/=) :: Spanned a -> Spanned a -> Bool #

Data a => Data (Spanned a) Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Spanned a -> c (Spanned a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Spanned a) #

toConstr :: Spanned a -> Constr #

dataTypeOf :: Spanned a -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (Spanned a)) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Spanned a)) #

gmapT :: (forall b. Data b => b -> b) -> Spanned a -> Spanned a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Spanned a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Spanned a -> r #

gmapQ :: (forall d. Data d => d -> u) -> Spanned a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Spanned a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Spanned a -> m (Spanned a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Spanned a -> m (Spanned a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Spanned a -> m (Spanned a) #

Ord a => Ord (Spanned a) Source # 

Methods

compare :: Spanned a -> Spanned a -> Ordering #

(<) :: Spanned a -> Spanned a -> Bool #

(<=) :: Spanned a -> Spanned a -> Bool #

(>) :: Spanned a -> Spanned a -> Bool #

(>=) :: Spanned a -> Spanned a -> Bool #

max :: Spanned a -> Spanned a -> Spanned a #

min :: Spanned a -> Spanned a -> Spanned a #

Show a => Show (Spanned a) Source # 

Methods

showsPrec :: Int -> Spanned a -> ShowS #

show :: Spanned a -> String #

showList :: [Spanned a] -> ShowS #

Generic (Spanned a) Source # 

Associated Types

type Rep (Spanned a) :: * -> * #

Methods

from :: Spanned a -> Rep (Spanned a) x #

to :: Rep (Spanned a) x -> Spanned a #

Hashable a => Hashable (Spanned a) Source # 

Methods

hashWithSalt :: Int -> Spanned a -> Int #

hash :: Spanned a -> Int #

HasSpan (Spanned a) Source # 

Methods

span :: Lens' (Spanned a) Span Source #

Renderable (Spanned a) Source # 
Reducer (Spanned a) Rendering Source # 
type Rep (Spanned a) Source # 
type Rep (Spanned a) = D1 (MetaData "Spanned" "Text.Trifecta.Rendering" "trifecta-1.7-JbDrfuEnY4pL19DKxHFrrK" False) (C1 (MetaCons ":~" (InfixI LeftAssociative 9) False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Span))))

addSpan :: Delta -> Delta -> Rendering -> Rendering Source #

int main(int argc, char ** argv) { int; }
                                   ^~~

Fixits

data Fixit Source #

Constructors

Fixit 

Instances

Eq Fixit Source # 

Methods

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

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

Data Fixit Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Fixit -> c Fixit #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Fixit #

toConstr :: Fixit -> Constr #

dataTypeOf :: Fixit -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Fixit) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Fixit) #

gmapT :: (forall b. Data b => b -> b) -> Fixit -> Fixit #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Fixit -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Fixit -> r #

gmapQ :: (forall d. Data d => d -> u) -> Fixit -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Fixit -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Fixit -> m Fixit #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Fixit -> m Fixit #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Fixit -> m Fixit #

Ord Fixit Source # 

Methods

compare :: Fixit -> Fixit -> Ordering #

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

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

(>) :: Fixit -> Fixit -> Bool #

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

max :: Fixit -> Fixit -> Fixit #

min :: Fixit -> Fixit -> Fixit #

Show Fixit Source # 

Methods

showsPrec :: Int -> Fixit -> ShowS #

show :: Fixit -> String #

showList :: [Fixit] -> ShowS #

Generic Fixit Source # 

Associated Types

type Rep Fixit :: * -> * #

Methods

from :: Fixit -> Rep Fixit x #

to :: Rep Fixit x -> Fixit #

Hashable Fixit Source # 

Methods

hashWithSalt :: Int -> Fixit -> Int #

hash :: Fixit -> Int #

HasSpan Fixit Source # 
Renderable Fixit Source # 
HasFixit Fixit Source # 
Reducer Fixit Rendering Source # 
type Rep Fixit Source # 
type Rep Fixit = D1 (MetaData "Fixit" "Text.Trifecta.Rendering" "trifecta-1.7-JbDrfuEnY4pL19DKxHFrrK" False) (C1 (MetaCons "Fixit" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "_fixitSpan") SourceUnpack SourceStrict DecidedUnpack) (Rec0 Span)) (S1 (MetaSel (Just Symbol "_fixitReplacement") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 ByteString))))

Drawing primitives

type Lines = Array (Int, Int64) ([SGR], Char) Source #

draw :: [SGR] -> Int -> Int64 -> String -> Lines -> Lines Source #