-- | NML is a convenient syntax for writing XML documents without
-- the excess line-noise while preserving (for the most part) the
-- semantics and niceties of XML documents. NML was originally
-- proposed by Erik Naggum, and his formulation can be seen at
-- <http://www.schnada.de/grapt/eriknaggum-enamel.html#impressum>.
--
-- This module exports the types 'NMLPair' and 'NMLElem' from
-- "Data.NML.Parse", which are strictly more expressive than XML.
-- For example, @\<one \<two|three\>\>@ corresponds to the XML fragment
-- @\<one two=\"three\"/\>@, but @\<one \<two\<a|b\>|c\>\>@ has no XML
-- analogue, as attributes cannot recursively possess attributes. This
-- means that functions which render NML to XML generally return an
-- @Either@ type, to account for possible failure.
--
-- Other modules are provided that expose an interface in terms of
-- the @xml@ package and the @xml-types@ package at
-- "Data.NML.XMLLight" and "Data.NML.XMLTypes", respectively.
module Data.NML
( encode
, decode
, module Data.NML.Parse
) where
import Data.Text (Text, pack)
import Data.NML.Parse
toMaybe :: Either a b -> Maybe b
toMaybe (Right x) = Just x
toMaybe _ = Nothing
-- | Parse an NML fragment as an NML Pair
decode :: Text -> Maybe NMLPair
decode = toMaybe . parseNML
-- | Convert an NML Pair to an NML fragment
encode :: NMLPair -> Text
encode = undefined