Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
The parser for Unison’s Doc
syntax.
This is completely independent of the Unison language, and requires a couple parsers to be passed in to then
provide a parser for Doc
applied to any host language.
- an identifer parser
- a code parser (that accepts a termination parser)
- a termination parser, for this parser to know when to give up
Each of those parsers is expected to satisfy (
.Ord
e, MonadParsec
e String
m)
Synopsis
- type Tree ident code = Cofree (Top code (Leaves ident code)) Ann
- type Leaves ident code = Cofree (Leaf ident code) Ann
- initialEnv :: ParsingEnv
- doc :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m end -> m (UntitledSection (Tree ident code))
- untitledSection :: MonadParsec e String m => m a -> m (UntitledSection a)
- sectionElem :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> ReaderT ParsingEnv m (Top code (Leaves ident code) (Tree ident code))
- leaf :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> m (Leaf ident code (Leaves ident code))
- section :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> ReaderT ParsingEnv m (Top code (Leaves ident code) (Tree ident code))
- eval :: MonadParsec e String m => (m () -> m code) -> m (Top code (Leaves ident code) (Tree ident code))
- exampleBlock :: MonadParsec e String m => (m () -> m code) -> m (Top code (Leaves ident code) (Tree ident code))
- codeBlock :: (Ord e, MonadParsec e String m) => m (Top code (Leaves ident code) (Tree ident code))
- list :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> ReaderT ParsingEnv m (List (Leaves ident code))
- bulletedList :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> ReaderT ParsingEnv m (List (Leaves ident code))
- numberedList :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> ReaderT ParsingEnv m (List (Leaves ident code))
- paragraph :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> m (Paragraph (Leaves ident code))
- link :: (Ord e, MonadParsec e String m) => m ident -> m (Leaf ident code a)
- namedLink :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> m (Leaf ident code (Leaves ident code))
- example :: MonadParsec e String m => (m () -> m code) -> m (Leaf ident code void)
- transclude :: MonadParsec e String m => (m () -> m code) -> m (Transclude code)
- bold :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> m (Leaf ident code (Leaves ident code))
- italic :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> m (Leaf ident code (Leaves ident code))
- strikethrough :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> m (Leaf ident code (Leaves ident code))
- verbatim :: (Ord e, MonadParsec e String m) => m (Leaf ident code a)
- keyedInline :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m (Leaf ident code a)
- group :: MonadParsec e s m => m (NonEmpty (Leaves ident code)) -> m (Group (Leaves ident code))
- word :: (Ord e, MonadParsec e String m) => m end -> m Word
- column' :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> Int -> ReaderT ParsingEnv m (Column (Leaves ident code))
- embedLink :: (Ord e, MonadParsec e s m, TraversableStream s) => m ident -> m (EmbedLink ident)
- join :: MonadParsec e s m => m (NonEmpty a) -> m (Join a)
Documentation
initialEnv :: ParsingEnv Source #
doc :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m end -> m (UntitledSection (Tree ident code)) Source #
untitledSection :: MonadParsec e String m => m a -> m (UntitledSection a) Source #
This is the actual Doc
lexer. Unlike doc2
, it doesn’t do any Unison-side lexing (i.e., it doesn’t know that
Unison wraps Doc
literals in `}}`).
sectionElem :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> ReaderT ParsingEnv m (Top code (Leaves ident code) (Tree ident code)) Source #
leaf :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> m (Leaf ident code (Leaves ident code)) Source #
section elements
section :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> ReaderT ParsingEnv m (Top code (Leaves ident code) (Tree ident code)) Source #
## Section title A paragraph under this section. Part of the same paragraph. Blanklines separate paragraphs. ### A subsection title A paragraph under this subsection. # A section title (not a subsection)
eval :: MonadParsec e String m => (m () -> m code) -> m (Top code (Leaves ident code) (Tree ident code)) Source #
exampleBlock :: MonadParsec e String m => (m () -> m code) -> m (Top code (Leaves ident code) (Tree ident code)) Source #
codeBlock :: (Ord e, MonadParsec e String m) => m (Top code (Leaves ident code) (Tree ident code)) Source #
list :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> ReaderT ParsingEnv m (List (Leaves ident code)) Source #
Not an actual node, but this pattern is referenced in multiple places
bulletedList :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> ReaderT ParsingEnv m (List (Leaves ident code)) Source #
FIXME: This should take a P
a
numberedList :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> ReaderT ParsingEnv m (List (Leaves ident code)) Source #
FIXME: This should take a P
a
paragraph :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> m (Paragraph (Leaves ident code)) Source #
leaves
namedLink :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> m (Leaf ident code (Leaves ident code)) Source #
transclude :: MonadParsec e String m => (m () -> m code) -> m (Transclude code) Source #
bold :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> m (Leaf ident code (Leaves ident code)) Source #
italic :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> m (Leaf ident code (Leaves ident code)) Source #
strikethrough :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> m (Leaf ident code (Leaves ident code)) Source #
keyedInline :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m (Leaf ident code a) Source #
A syntactic pattern of “@keyword{…}”, where we process the contents differently depending on the keyword provided.
group :: MonadParsec e s m => m (NonEmpty (Leaves ident code)) -> m (Group (Leaves ident code)) Source #
FIXME: This should just take a
and P
code
.P
a
other components
column' :: (Ord e, MonadParsec e String m) => m ident -> (m () -> m code) -> m () -> Int -> ReaderT ParsingEnv m (Column (Leaves ident code)) Source #
embedLink :: (Ord e, MonadParsec e s m, TraversableStream s) => m ident -> m (EmbedLink ident) Source #
Not an actual node, but this pattern is referenced in multiple places