markup-parse
Safe HaskellNone
LanguageGHC2024

Data.Markup.Warn

Description

Warning helpers for markup parsing.

Synopsis

Documentation

data MarkupWarning Source #

markup-parse generally tries to continue on parse errors, and return what has/can still be parsed, together with any warnings.

Constructors

BadEmptyElemTag

A tag ending with "/>" that is not an element of selfClosers (Html only).

SelfCloserWithChildren

A tag ending with "/>" that has children. Cannot happen in the parsing phase.

LeafWithChildren

Only a StartTag can have child tokens.

TagMismatch NameTag NameTag

A CloseTag with a different name to the currently open StartTag.

UnmatchedEndTag

An EndTag with no corresponding StartTag.

UnclosedTag

An StartTag with no corresponding EndTag.

EndTagInTree

An EndTag should never appear in Markup

EmptyContent

Empty Content, Comment, Decl or Doctype

BadDecl

Badly formed declaration

MarkupParser ParserWarning 

Instances

Instances details
Eq MarkupWarning Source # 
Instance details

Defined in Data.Markup.Warn

Ord MarkupWarning Source # 
Instance details

Defined in Data.Markup.Warn

Data MarkupWarning Source # 
Instance details

Defined in Data.Markup.Warn

Methods

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

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

toConstr :: MarkupWarning -> Constr #

dataTypeOf :: MarkupWarning -> DataType #

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

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

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

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

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

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

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

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

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

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

Generic MarkupWarning Source # 
Instance details

Defined in Data.Markup.Warn

Associated Types

type Rep MarkupWarning 
Instance details

Defined in Data.Markup.Warn

type Rep MarkupWarning = D1 ('MetaData "MarkupWarning" "Data.Markup.Warn" "markup-parse-0.3.0.0-inplace" 'False) (((C1 ('MetaCons "BadEmptyElemTag" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SelfCloserWithChildren" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "LeafWithChildren" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "TagMismatch" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NameTag) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NameTag)) :+: C1 ('MetaCons "UnmatchedEndTag" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "UnclosedTag" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "EndTagInTree" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "EmptyContent" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "BadDecl" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MarkupParser" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ParserWarning))))))
Show MarkupWarning Source # 
Instance details

Defined in Data.Markup.Warn

type Rep MarkupWarning Source # 
Instance details

Defined in Data.Markup.Warn

type Rep MarkupWarning = D1 ('MetaData "MarkupWarning" "Data.Markup.Warn" "markup-parse-0.3.0.0-inplace" 'False) (((C1 ('MetaCons "BadEmptyElemTag" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SelfCloserWithChildren" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "LeafWithChildren" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "TagMismatch" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NameTag) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NameTag)) :+: C1 ('MetaCons "UnmatchedEndTag" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "UnclosedTag" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "EndTagInTree" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "EmptyContent" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "BadDecl" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MarkupParser" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ParserWarning))))))

data ParserWarning Source #

Warnings originating in the stream/token parser.

Instances

Instances details
Eq ParserWarning Source # 
Instance details

Defined in Data.Markup.Warn

Ord ParserWarning Source # 
Instance details

Defined in Data.Markup.Warn

Data ParserWarning Source # 
Instance details

Defined in Data.Markup.Warn

Methods

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

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

toConstr :: ParserWarning -> Constr #

dataTypeOf :: ParserWarning -> DataType #

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

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

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

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

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

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

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

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

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

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

Generic ParserWarning Source # 
Instance details

Defined in Data.Markup.Warn

Associated Types

type Rep ParserWarning 
Instance details

Defined in Data.Markup.Warn

type Rep ParserWarning = D1 ('MetaData "ParserWarning" "Data.Markup.Warn" "markup-parse-0.3.0.0-inplace" 'False) (C1 ('MetaCons "ParserLeftover" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: (C1 ('MetaCons "ParserError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "ParserUncaught" 'PrefixI 'False) (U1 :: Type -> Type)))
Show ParserWarning Source # 
Instance details

Defined in Data.Markup.Warn

type Rep ParserWarning Source # 
Instance details

Defined in Data.Markup.Warn

type Rep ParserWarning = D1 ('MetaData "ParserWarning" "Data.Markup.Warn" "markup-parse-0.3.0.0-inplace" 'False) (C1 ('MetaCons "ParserLeftover" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: (C1 ('MetaCons "ParserError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "ParserUncaught" 'PrefixI 'False) (U1 :: Type -> Type)))

type Warn a = These [MarkupWarning] a Source #

A type synonym for the common returning type of many functions. A common computation pipeline is to take advantage of the These Monad instance eg

markup s bs = bs & (tokenize s >=> gather s) & second (Markup s)

warnError :: Warn a -> a Source #

Convert any warnings to an error

warnEither :: Warn a -> Either [MarkupWarning] a Source #

Returns Left on any warnings

warnMaybe :: Warn a -> Maybe a Source #

Returns results, if any, ignoring warnings.

concatWarns :: [Warn [a]] -> Warn [a] Source #