ogmarkup-5.0: A lightweight markup language for story writers

Copyright(c) Ogma Project 2016
LicenseMIT
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell2010

Text.Ogmarkup.Private.Ast

Description

An abstract representation of an ogmarkup document.

Synopsis

Documentation

type Document a = [Section a] Source #

A ogmarkup document internal representation waiting to be used in order to generate an output.

data Section a Source #

A Section within an ogmarkup document is a sequence of paragraphs. It can be part of the story or an aside section like a letter, a song, etc. We make the distinction between the two cases because we want to be able to apply different style depending on the situation.

Constructors

Story [Paragraph a]

The story as it goes

Aside (Maybe a) [Paragraph a]

Something else. Maybe a letter, a flashback, etc.

Failing a 

Instances

Eq a => Eq (Section a) Source # 

Methods

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

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

Show a => Show (Section a) Source # 

Methods

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

show :: Section a -> String #

showList :: [Section a] -> ShowS #

type Paragraph a = [Component a] Source #

A Paragraph is just a sequence of Component.

data Component a Source #

A Component is either a narrative text, a character's line of dialogue or a character's inner thought.

We also embed an error Component in case we fail to parse a valid component. This way, we can resume parsing when we meet a new paragraph.

Constructors

Teller [Format a]

A narrative description

Dialogue (Reply a) (Maybe a)

A dialogue reply

Thought (Reply a) (Maybe a)

Inner dialogue of the character

IllFormed a

If none of the above matched, then output what follows as-is, the parsing will be resumed at the next paragraph

Instances

Eq a => Eq (Component a) Source # 

Methods

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

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

Show a => Show (Component a) Source # 

data Reply a Source #

A character's line of dialogue. A reply may contain a descriptive part, which is not part of what the character actually says or thinks. We call the latter a "with say" reply untill someone gives use a better name for it.

Constructors

Simple [Format a]

A reply of the form: "Good morning."

WithSay [Format a] [Format a] [Format a]

A reply of the form: "Good morning," she says. "How are you?"

Instances

Eq a => Eq (Reply a) Source # 

Methods

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

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

Show a => Show (Reply a) Source # 

Methods

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

show :: Reply a -> String #

showList :: [Reply a] -> ShowS #

data Format a Source #

A nested formatted text

Constructors

Raw [Atom a]

No particular emphasis is required on this sequence

Emph [Format a]

Surrounded by *.

StrongEmph [Format a]

Surrounded by **.

Quote [Format a] 

Instances

Eq a => Eq (Format a) Source # 

Methods

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

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

Show a => Show (Format a) Source # 

Methods

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

show :: Format a -> String #

showList :: [Format a] -> ShowS #

data Atom a Source #

An Atom is the atomic component of a Ogmarkup document. It can be either a punctuation mark or a word, that is a string.

Note that, by construction, OpenQuote and CloseQuote are not valid Mark values here. Indeed, they are implicit with the Quote constructor. This design allows the parser to enforce that an opened quote needs to be closed.

Constructors

Word a

A wrapped string

Punctuation Mark

A punctuation mark

Instances

Eq a => Eq (Atom a) Source # 

Methods

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

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

Show a => Show (Atom a) Source # 

Methods

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

show :: Atom a -> String #

showList :: [Atom a] -> ShowS #

MonadState (a, Maybe (Atom a)) (Generator c a) # 

Methods

get :: Generator c a (a, Maybe (Atom a)) #

put :: (a, Maybe (Atom a)) -> Generator c a () #

state :: ((a, Maybe (Atom a)) -> (a, (a, Maybe (Atom a)))) -> Generator c a a #

data Mark Source #

Mostly in order to deal with typographic spaces, main punctuation marks are tokenized during the parsing of an Ogmarkup document.

Constructors

Semicolon

The character ;

Colon

The character ,

Question

The character ?

Exclamation

The character !

OpenQuote

The character "

CloseQuote

The character "

Dash

The character – or the sequence --

LongDash

The character — or the sequence ---

Comma

The character ,

Point

The character .

Hyphen

The character -

SuspensionPoints

Two or more . or the character …

Apostrophe

The characters ' or

Interrobang

The strange character , obtained ?! or ?!

Irony

The character ؟, obtained with ??

Instances

Eq Mark Source # 

Methods

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

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

Show Mark Source # 

Methods

showsPrec :: Int -> Mark -> ShowS #

show :: Mark -> String #

showList :: [Mark] -> ShowS #