prosidy-1.6.0.0: A simple language for writing documents.
Copyright©2020 James Alexander Feldman-Crough
LicenseMPL-2.0
Maintaineralex@fldcr.com
Safe HaskellNone
LanguageHaskell2010

Prosidy.Optics.Types

Description

 
Synopsis

Classy optics

Items with Metadata

class HasMetadata t where Source #

A classy optic for focusing on items with Metadata, including Tags, Regions, and Documents.

Methods

metadata :: Lens' t Metadata Source #

Instances

Instances details
HasMetadata Metadata Source # 
Instance details

Defined in Prosidy.Optics.Types

HasMetadata Document Source # 
Instance details

Defined in Prosidy.Optics.Types

HasMetadata (Tag a) Source # 
Instance details

Defined in Prosidy.Optics.Types

Methods

metadata :: Lens' (Tag a) Metadata Source #

HasMetadata (Region a) Source # 
Instance details

Defined in Prosidy.Optics.Types

Methods

metadata :: Lens' (Region a) Metadata Source #

properties :: HasMetadata m => Lens' m (Set Key) Source #

Fetch all properties from items which contain metadata.

settings :: HasMetadata m => Lens' m (Assoc Key Text) Source #

Fetch all settings defined on items which contain metadata.

hasProperty :: HasMetadata m => Key -> Lens' m Bool Source #

Check if a property is attached to an item with metadata. Using this optic as a setter will add a property if set to True and remove the property when set to False.

atSetting :: HasMetadata m => Key -> Lens' m (Maybe Text) Source #

Select a setting from an item attached to metadata. Returns Nothing if no value is set.

Items wrapping content

class HasContent t where Source #

An optic for selecting children of an item in a recursive structure.

Associated Types

type Content t Source #

The type of all of the children collectively. For instance, type Content Document = Series Block, as Document has zero or more contained Blocks.

Methods

content :: Lens' t (Content t) Source #

Instances

Instances details
HasContent Paragraph Source # 
Instance details

Defined in Prosidy.Optics.Types

Associated Types

type Content Paragraph Source #

HasContent Document Source # 
Instance details

Defined in Prosidy.Optics.Types

Associated Types

type Content Document Source #

HasContent (Tag a) Source # 
Instance details

Defined in Prosidy.Optics.Types

Associated Types

type Content (Tag a) Source #

Methods

content :: Lens' (Tag a) (Content (Tag a)) Source #

HasContent (Region a) Source # 
Instance details

Defined in Prosidy.Optics.Types

Associated Types

type Content (Region a) Source #

Methods

content :: Lens' (Region a) (Content (Region a)) Source #

Accessors for fields not otherwise covered

tag :: Lens' (Tag a) Key Source #

Focus on the name of a Tag.

fragment :: Lens' Fragment Text Source #

Get the contents of a Fragment.

Conversion between Tags and Regions.

tagged :: Key -> Prism' (Tag a) (Region a) Source #

Focus on the inner Region of Tags with a name. This can be used to filter Tags to a specific subset for manipulation.

Prisms on Block contexts

_BlockTag :: Prism' Block BlockTag Source #

Focus only on block tags.

_BlockLiteral :: Prism' Block LiteralTag Source #

Focus only on literal tags.

_BlockParagraph :: Prism' Block Paragraph Source #

Focus only on paragraphs'

Prisms on Inline contexts

_InlineTag :: Prism' Inline InlineTag Source #

Focus only on inline tags.

_Text :: Prism' Inline Fragment Source #

Focus only on text nodes.

_Break :: Prism' Inline () Source #

Focus only on breaks.

Optics on common types

key :: Prism' Text Key Source #

A Prism from Text into a valid Key.

_Assoc :: Iso (Assoc k v) (Assoc k' v') (HashMap k v) (HashMap k' v') Source #

An isomorphism between Prosidy's Assoc wrapper and HashMap.

_NonEmpty :: Prism' (Series a) (SeriesNE a) Source #

A prism between possibly-empty and non-empty containers.

_Series :: Iso (Series a) (Series b) (Seq a) (Seq b) Source #

An isomorpism between Prosidy's Series wrapper and Seq.

_SeriesNE :: Prism' (Seq a) (SeriesNE a) Source #

A prism from a non-empty Seq into a SeriesNE.

_Set :: Iso (Set a) (Set b) (HashSet a) (HashSet b) Source #

An isomorphism between Prosidy's Set wrapper and HashSet.