| Copyright | ©2020 James Alexander Feldman-Crough |
|---|---|
| License | MPL-2.0 |
| Maintainer | alex@fldcr.com |
| Safe Haskell | None |
| Language | Haskell2010 |
Prosidy.Compile.Core
Description
Synopsis
- data Rules t f a
- data Rule t f a
- rule :: RuleFor t f a -> Rules t f a
- local :: Functor f => f a -> Rules t f a
- self :: Rules t f t
- runRules :: Alternative g => (forall b. Rule t f b -> g b) -> Rules t f a -> g a
- mapRules :: forall a a' t t' f. (Functor f, Functor (RuleFor t' f)) => (forall x. RuleFor t f x -> RuleFor t' f x) -> (t' -> t) -> (a -> a') -> Rules t f a -> Rules t' f a'
- hoist :: HoistRuleFor t => (forall b. f b -> g b) -> Rules t f a -> Rules t g a
- class HoistRuleFor t
- type family RuleFor t = (rule :: (* -> *) -> * -> *) | rule -> t where ...
- data BlockRule f a
- = BlockRuleBlockTag (Rules BlockTag f a)
- | BlockRuleLiteralTag (Rules LiteralTag f a)
- | BlockRuleParagraph (Rules Paragraph f a)
- newtype DocumentRule f a = DocumentRule (RegionRule (Series Block) f a)
- data FragmentRule f a
- = FragmentRuleLocation (Maybe Location -> a)
- | FragmentRuleText (Text -> a)
- data InlineRule f a
- = InlineRuleBreak a
- | InlineRuleFragment (Rules Fragment f a)
- | InlineRuleInlineTag (Rules InlineTag f a)
- data MetadataRule f a
- = MetadataRuleProperty (Bool -> a) Key
- | MetadataRuleSetting (Text -> Either String a) (Maybe a) Key
- | MetadataRuleAllowUnknown a
- data ParagraphRule f a
- = ParagraphRuleContent (Rules (SeriesNE Inline) f a)
- | ParagraphRuleLocation (Maybe Location -> a)
- data RegionRule t f a
- = RegionRuleLocation (Maybe Location -> a)
- | RegionRuleMetadata (MetadataRule f a)
- | RegionRuleContent (Rules t f a)
- data SeriesNERule t f a = forall b c. SeriesNERule (b -> c -> a) (Rules t f b) (Rules (Series t) f c)
- data SeriesRule t f a
- = SeriesRuleNext (SeriesNERule t f a)
- | SeriesRuleEmpty a
- data TagRule t f a
- = TagRuleKey Key a
- | TagRuleRegion (RegionRule t f a)
- class Applicative f => Alternative (f :: Type -> Type) where
- class (forall i. Alternative (t i)) => Context t where
- class Context t => Interpret t i where
- interpret :: forall t i a. Interpret t i => Rules i (Local t) a -> t i a
Documentation
A container for building up compilation rules.
An individual Rule in isolation.
Arguments
| :: forall a a' t t' f. (Functor f, Functor (RuleFor t' f)) | |
| => (forall x. RuleFor t f x -> RuleFor t' f x) | Maps over rules themselves, keeping the context and output types the same. |
| -> (t' -> t) | Maps over the input to rules. |
| -> (a -> a') | Maps over the output of rules. |
| -> Rules t f a | |
| -> Rules t' f a' |
Map over Rules.
hoist :: HoistRuleFor t => (forall b. f b -> g b) -> Rules t f a -> Rules t g a Source #
Map over the contextual functor f in Rules.
class HoistRuleFor t Source #
A class defining how to map over the contextual parameter f in a rule for
the type t.
Minimal complete definition
hoistRuleFor
Instances
Context-aware ADT rules.
type family RuleFor t = (rule :: (* -> *) -> * -> *) | rule -> t where ... Source #
Defines a relationship between input types and rules specific to those input types.
Equations
| RuleFor Block = BlockRule | |
| RuleFor Document = DocumentRule | |
| RuleFor Fragment = FragmentRule | |
| RuleFor Inline = InlineRule | |
| RuleFor Metadata = MetadataRule | |
| RuleFor Paragraph = ParagraphRule | |
| RuleFor (Region a) = RegionRule a | |
| RuleFor (Series a) = SeriesRule a | |
| RuleFor (SeriesNE a) = SeriesNERule a | |
| RuleFor (Tag a) = TagRule a | |
| RuleFor a = Void a |
Rules for matching specific types of Block nodes.
Constructors
| BlockRuleBlockTag (Rules BlockTag f a) | |
| BlockRuleLiteralTag (Rules LiteralTag f a) | |
| BlockRuleParagraph (Rules Paragraph f a) |
newtype DocumentRule f a Source #
Rules applying to Documents.
Constructors
| DocumentRule (RegionRule (Series Block) f a) |
Instances
| Functor (DocumentRule f) Source # | |
Defined in Prosidy.Compile.Core.Rules Methods fmap :: (a -> b) -> DocumentRule f a -> DocumentRule f b # (<$) :: a -> DocumentRule f b -> DocumentRule f a # | |
data FragmentRule f a Source #
Rules applying to Fragments (i.e. plain text).
Constructors
| FragmentRuleLocation (Maybe Location -> a) | |
| FragmentRuleText (Text -> a) |
Instances
| Functor (FragmentRule f) Source # | |
Defined in Prosidy.Compile.Core.Rules Methods fmap :: (a -> b) -> FragmentRule f a -> FragmentRule f b # (<$) :: a -> FragmentRule f b -> FragmentRule f a # | |
data InlineRule f a Source #
Rules for matching specific types of Inline nodes.
Constructors
| InlineRuleBreak a | |
| InlineRuleFragment (Rules Fragment f a) | |
| InlineRuleInlineTag (Rules InlineTag f a) |
Instances
| Functor (InlineRule f) Source # | |
Defined in Prosidy.Compile.Core.Rules Methods fmap :: (a -> b) -> InlineRule f a -> InlineRule f b # (<$) :: a -> InlineRule f b -> InlineRule f a # | |
data MetadataRule f a Source #
Rules for operating on properties and settings.
Constructors
| MetadataRuleProperty (Bool -> a) Key | |
| MetadataRuleSetting (Text -> Either String a) (Maybe a) Key | |
| MetadataRuleAllowUnknown a |
Instances
| Functor (MetadataRule f) Source # | |
Defined in Prosidy.Compile.Core.Rules Methods fmap :: (a -> b) -> MetadataRule f a -> MetadataRule f b # (<$) :: a -> MetadataRule f b -> MetadataRule f a # | |
data ParagraphRule f a Source #
Rules for accessing paragraphs.
Constructors
| ParagraphRuleContent (Rules (SeriesNE Inline) f a) | |
| ParagraphRuleLocation (Maybe Location -> a) |
Instances
| Functor (ParagraphRule f) Source # | |
Defined in Prosidy.Compile.Core.Rules Methods fmap :: (a -> b) -> ParagraphRule f a -> ParagraphRule f b # (<$) :: a -> ParagraphRule f b -> ParagraphRule f a # | |
data RegionRule t f a Source #
Rules for operating on a Region.
Constructors
| RegionRuleLocation (Maybe Location -> a) | |
| RegionRuleMetadata (MetadataRule f a) | |
| RegionRuleContent (Rules t f a) |
Instances
| Functor (RegionRule t f) Source # | |
Defined in Prosidy.Compile.Core.Rules Methods fmap :: (a -> b) -> RegionRule t f a -> RegionRule t f b # (<$) :: a -> RegionRule t f b -> RegionRule t f a # | |
data SeriesNERule t f a Source #
Operates sequentially against a non-empty collection of nodes.
Constructors
| forall b c. SeriesNERule (b -> c -> a) (Rules t f b) (Rules (Series t) f c) |
Instances
| Functor (SeriesNERule t f) Source # | |
Defined in Prosidy.Compile.Core.Rules Methods fmap :: (a -> b) -> SeriesNERule t f a -> SeriesNERule t f b # (<$) :: a -> SeriesNERule t f b -> SeriesNERule t f a # | |
data SeriesRule t f a Source #
Operates sequentially against a collection of nodes.
Constructors
| SeriesRuleNext (SeriesNERule t f a) | |
| SeriesRuleEmpty a |
Instances
| Functor (SeriesRule t f) Source # | |
Defined in Prosidy.Compile.Core.Rules Methods fmap :: (a -> b) -> SeriesRule t f a -> SeriesRule t f b # (<$) :: a -> SeriesRule t f b -> SeriesRule t f a # | |
Rules for operating on Tags.
Constructors
| TagRuleKey Key a | |
| TagRuleRegion (RegionRule t f a) |
Reëxports
class Applicative f => Alternative (f :: Type -> Type) where #
A monoid on applicative functors.
If defined, some and many should be the least solutions
of the equations:
Methods
The identity of <|>
(<|>) :: f a -> f a -> f a infixl 3 #
An associative binary operation
One or more.
Zero or more.
Instances
class (forall i. Alternative (t i)) => Context t where Source #
A base class for interpreters of Rules.
Minimal complete definition
Associated Types
type Local t :: * -> * Source #
A type for expressions that can be lifted by the interpreter.
This type defaults to an uninhabited type. Only override this type
if you intend on overriding liftRule, as well.
Methods
Access the current focus of an interpreter. This function is similar
in purpose to ask.
class Context t => Interpret t i where Source #
Instructs a Context how to interpret a single rule.
Minimal complete definition
Nothing
Instances
| Applicative f => Interpret (RunT f) Text Source # | |
| Applicative f => Interpret (RunT f) Paragraph Source # | |
| Applicative f => Interpret (RunT f) Metadata Source # | |
| Applicative f => Interpret (RunT f) Inline Source # | |
| Applicative f => Interpret (RunT f) Fragment Source # | |
| Applicative f => Interpret (RunT f) Document Source # | |
| Applicative f => Interpret (RunT f) Block Source # | |
| (Applicative f, Interpret (RunT f) t) => Interpret (RunT f) (SeriesNE t) Source # | |
| (Applicative f, Interpret (RunT f) t) => Interpret (RunT f) (Series t) Source # | |
| (Applicative f, Interpret (RunT f) t) => Interpret (RunT f) (Tag t) Source # | |
| (Applicative f, Interpret (RunT f) t) => Interpret (RunT f) (Region t) Source # | |