@@ -17,6 +17,7 @@ module Text.XML.DOM.Parser.Class
1717 , readBool
1818 , unitFromDom
1919 , voidFromDom
20+ , scientificFromDom
2021 ) where
2122
2223import Control.Applicative
@@ -24,6 +25,7 @@ import Control.Lens
2425import Data.Fixed
2526import Data.Monoid
2627import Data.OpenUnion
28+import Data.Scientific
2729import Data.Text (Text)
2830import qualified Data.Text as T
2931import Data.Typeable
@@ -77,12 +79,13 @@ instance FromDom Bool where
7779instance FromDom (Union '[]) where
7880 fromDom = empty
7981
80−instance ( Typeable a, FromDom a, FromDom (Union as)
81− , SubList as (a ': as) )
82− => FromDom (Union (a ': as)) where
82+instance
83+ ( Typeable a, FromDom a, FromDom (Union as)
84+ , SubList as (a ': as) )
85+ => FromDom (Union (a ': as)) where
8386 -- fromDom :: forall m. (DomParserMonad m) => m a
8487 fromDom = (liftUnion <$> (proxyFromDom (Proxy :: Proxy a)))
85− <|> (reUnion <$> (proxyFromDom (Proxy :: Proxy (Union as))))
88+ <|> (reUnion <$> (proxyFromDom (Proxy :: Proxy (Union as))))
8689
8790instance FromDom Element where
8891 fromDom = elementFromDom
@@ -127,6 +130,9 @@ fixedFromDom
127130 => DomParserT Identity m (Fixed a)
128131fixedFromDom = parseContent readContent
129132
133+scientificFromDom :: Monad m => DomParserT Identity m Scientific
134+scientificFromDom = parseContent readContent
135+
130136-- | Expects content to be y, yes, t, true or 1 for True value. n, no,
131137-- f, false or 0 for False value. Case is not significant, blank
132138-- characters are striped.
@@ -140,10 +146,11 @@ readBool t =
140146 lowt = T.toLower $ T.strip t
141147 tvals = ["y", "yes", "t", "true", "1"]
142148 fvals = ["n", "no", "f", "false", "0"]
143− in if | lowt `elem` tvals -> Right True
144− | lowt `elem` fvals -> Right False
145− | otherwise ->
146− Left $ "Could not read " <> t <> " as Bool"
149+ in if
150+ | lowt `elem` tvals -> Right True
151+ | lowt `elem` fvals -> Right False
152+ | otherwise ->
153+ Left $ "Could not read " <> t <> " as Bool"
147154
148155-- | Always successfully parses any DOM to @()@
149156unitFromDom :: (Monad m) => DomParserT Identity m ()