diff --git a/package.yaml b/package.yaml index fba307e..92cd3f2 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: structural-xml -version: 0.2.0.1 +version: 0.2.0.2 description: Structural XML parsing and unparsing. license: BSD3 license-file: LICENSE diff --git a/src/Data/XML/Parse/Types.hs b/src/Data/XML/Parse/Types.hs index e85464c..d01cb4a 100644 --- a/src/Data/XML/Parse/Types.hs +++ b/src/Data/XML/Parse/Types.hs @@ -90,12 +90,10 @@ readContent text i = case readMaybe $ Text.unpack text of <> show (typeRep @a) instance FromElement a => FromElement (OrEmpty a) where - fromElement el = case fromElement el of - Right a -> pure . OrEmpty $ Just a - Left err -> - if isEmptyElement el - then pure $ OrEmpty Nothing - else Left err + fromElement el = + if isEmptyElement el + then pure $ OrEmpty Nothing + else OrEmpty . Just <$> fromElement el -- | A 'choice' element corresponds to the 'choice' schema element, which encodes sum types: -- diff --git a/src/Data/XML/Types.hs b/src/Data/XML/Types.hs index 2f5077a..6ce9581 100644 --- a/src/Data/XML/Types.hs +++ b/src/Data/XML/Types.hs @@ -79,8 +79,7 @@ data AnnotatedNode i newtype ContentElement a = ContentElement {content :: a} deriving stock (Show, Eq, Ord, Generic) --- | Encodes `Nothing` as emptyElement. Parses the empty element as `Nothing`, --- unless the parser for `a` succeeds on the empty element. +-- | Encodes `Nothing` as emptyElement. Parses the empty element as `Nothing`. newtype OrEmpty a = OrEmpty {unOrEmpty :: Maybe a} instance Semigroup Element where diff --git a/structural-xml.cabal b/structural-xml.cabal index fee6d0f..673a274 100644 --- a/structural-xml.cabal +++ b/structural-xml.cabal @@ -5,7 +5,7 @@ cabal-version: 1.12 -- see: https://github.com/sol/hpack name: structural-xml -version: 0.2.0.1 +version: 0.2.0.2 description: Structural XML parsing and unparsing. author: Frederik Ramcke maintainer: Frederik Ramcke