module Text.XML.Light.Extractors.Extra where
import Text.Read (readMaybe)
float :: (Floating a, Read a) => String -> Either String a
float :: String -> Either String a
float = Either String a
-> (a -> Either String a) -> Maybe a -> Either String a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> Either String a
forall a b. a -> Either a b
Left String
"float") a -> Either String a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe a -> Either String a)
-> (String -> Maybe a) -> String -> Either String a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe a
forall a. Read a => String -> Maybe a
readMaybe
integer :: (Integral a, Read a) => String -> Either String a
integer :: String -> Either String a
integer = Either String a
-> (a -> Either String a) -> Maybe a -> Either String a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> Either String a
forall a b. a -> Either a b
Left String
"integer") a -> Either String a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe a -> Either String a)
-> (String -> Maybe a) -> String -> Either String a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe a
forall a. Read a => String -> Maybe a
readMaybe