prosidyc-0.2.0.0: A DSL for processing Prosidy documents.
Copyright©2020 James Alexander Feldman-Crough
LicenseMPL-2.0
Maintaineralex@fldcr.com
Safe HaskellNone
LanguageHaskell2010

Prosidy.Compile.Match

Description

 
Synopsis

DSL for matching cases

type Match i e f a = MatchM i e a f () Source #

The type of fallible pattern specifications.

data MatchM i e a f r Source #

A monadic interface for defining fallible patterns. In practice, r will always be instantiated to ()Match can be more clear.

Instances

Instances details
Monad (MatchM i e a f) Source # 
Instance details

Defined in Prosidy.Compile.Match

Methods

(>>=) :: MatchM i e a f a0 -> (a0 -> MatchM i e a f b) -> MatchM i e a f b #

(>>) :: MatchM i e a f a0 -> MatchM i e a f b -> MatchM i e a f b #

return :: a0 -> MatchM i e a f a0 #

Functor (MatchM i e a f) Source # 
Instance details

Defined in Prosidy.Compile.Match

Methods

fmap :: (a0 -> b) -> MatchM i e a f a0 -> MatchM i e a f b #

(<$) :: a0 -> MatchM i e a f b -> MatchM i e a f a0 #

Applicative (MatchM i e a f) Source # 
Instance details

Defined in Prosidy.Compile.Match

Methods

pure :: a0 -> MatchM i e a f a0 #

(<*>) :: MatchM i e a f (a0 -> b) -> MatchM i e a f a0 -> MatchM i e a f b #

liftA2 :: (a0 -> b -> c) -> MatchM i e a f a0 -> MatchM i e a f b -> MatchM i e a f c #

(*>) :: MatchM i e a f a0 -> MatchM i e a f b -> MatchM i e a f b #

(<*) :: MatchM i e a f a0 -> MatchM i e a f b -> MatchM i e a f a0 #

match :: (Applicative f, CanMatch i) => Match i e f a -> RuleT i e f a Source #

Finalize a Match into a rule. This is often used to offset a match block:

blocktags :: Match Block Void Identity String
blocktags = match $ do
   ...

Specific matchers

break :: RuleT () e f a -> Match Inline e f a Source #

Match against a Break.

breakWith :: a -> Match Inline e f a Source #

Replace all Breaks with the provided value.

paragraph :: RuleT (SeriesNE Inline) e f a -> Match Block e f a Source #

Match Paragraphs in a block context.

text :: RuleT Text e f a -> Match Inline e f a Source #

Match plain Text in an inline context.

Tag matchers which strictly enforce metadata.

blockTag :: Applicative f => Key -> RuleT BlockRegion e f a -> Match Block e f a Source #

Strict: match a BlockTag with the given Key.

inlineTag :: Applicative f => Key -> RuleT InlineRegion e f a -> Match Inline e f a Source #

Strict: match an InlineTag with the given Key.

literalTag :: Applicative f => Key -> RuleT LiteralRegion e f a -> Match Block e f a Source #

Strict: match an LiteralTag with the given Key.

Tag matchers which loosely enforce metadata.

blockTag' :: Key -> RuleT BlockRegion e f a -> Match Block e f a Source #

Lax: match a BlockTag with the given Key.

inlineTag' :: Key -> RuleT InlineRegion e f a -> Match Inline e f a Source #

Lax: match an InlineTag with the given Key.

literalTag' :: Key -> RuleT LiteralRegion e f a -> Match Block e f a Source #

Lax: match an LiteralTag with the given Key.