Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.Frontmatter
- frontmatter :: Parser ByteString
- frontmatterYaml :: FromJSON a => Parser a
- parseFrontmatter :: ByteString -> Result ByteString
- parseFrontmatterMaybe :: ByteString -> Maybe ByteString
- parseFrontmatterEither :: ByteString -> Either String ByteString
- parseYamlFrontmatter :: FromJSON a => ByteString -> Result a
- parseYamlFrontmatterMaybe :: FromJSON a => ByteString -> Maybe a
- parseYamlFrontmatterEither :: FromJSON a => ByteString -> Either String a
- parse :: Parser a -> ByteString -> Result a
- maybeResult :: Result r -> Maybe r
- eitherResult :: Result r -> Either String r
- type Parser = Parser ByteString
- type Result = IResult ByteString
- data IResult i r :: * -> * -> *
Frontmatter parser
frontmatter :: Parser ByteString Source
A parser for a frontmatter; returns it as a ByteString
. Doesn't fail even
if it's empty. When it fails; returns a a IResult with the whole input
rather than consuming it.
frontmatterYaml :: FromJSON a => Parser a Source
Parses a YAML frontmatter or JSON frontmatter from a ByteString
as a
Value
. Because of how Data.Yaml
is implemented using aeson
, this will
succeed for JSON frontmatters as well as YAML ones.
Utility functions
parseFrontmatter :: ByteString -> Result ByteString Source
Parse a frontmatter from a ByteString
returning a Result
. Just extracts
whatever is on the frontmatter; doesn't care what it is.
parseFrontmatterMaybe :: ByteString -> Maybe ByteString Source
parseFrontmatter
but returning a Maybe
parseFrontmatterEither :: ByteString -> Either String ByteString Source
parseFrontmatter
but returning an Either
parseYamlFrontmatter :: FromJSON a => ByteString -> Result a Source
Parse a frontmatter from a ByteString
returning a 'FromJSON a'. Will parse
both JSON and YAML.
parseYamlFrontmatterMaybe :: FromJSON a => ByteString -> Maybe a Source
parseYamlFrontmatter
but returning a Maybe
parseYamlFrontmatterEither :: FromJSON a => ByteString -> Either String a Source
parseYamlFrontmatter
but returning an Either
Re-exports
parse :: Parser a -> ByteString -> Result a
Run a parser.
maybeResult :: Result r -> Maybe r
eitherResult :: Result r -> Either String r
type Parser = Parser ByteString
type Result = IResult ByteString
data IResult i r :: * -> * -> *
The result of a parse. This is parameterised over the type i
of string that was processed.
This type is an instance of Functor
, where fmap
transforms the
value in a Done
result.
Constructors
Fail i [String] String | The parse failed. The |
Partial (i -> IResult i r) | Supply this continuation with more input so that the parser can resume. To indicate that no more input is available, pass an empty string to the continuation. Note: if you get a |
Done i r | The parse succeeded. The |