diff --git a/src/Data/Scientific/Exts.hs b/src/Data/Scientific/Exts.hs index 9f43028f1..50df2a55d 100644 --- a/src/Data/Scientific/Exts.hs +++ b/src/Data/Scientific/Exts.hs @@ -3,16 +3,15 @@ module Data.Scientific.Exts , parseScientific ) where -import Prelude hiding (filter, null, takeWhile) - import Control.Applicative -import Control.Monad +import Control.Monad hiding (fail) import Data.Attoparsec.ByteString.Char8 import Data.ByteString.Char8 hiding (readInt, takeWhile) import Data.Char (isOctDigit) import Data.Scientific -import Data.Semigroup import Numeric +import Prelude hiding (fail, filter, null, takeWhile) +import Prologue hiding (null) import Text.Read (readMaybe) parseScientific :: ByteString -> Either String Scientific @@ -38,9 +37,9 @@ parser = signed (choice [hex, oct, bin, dec]) where -- The ending stanza. Note the explicit endOfInput call to ensure we haven't left any dangling input. done = skipWhile (inClass "iIjJlL") *> endOfInput - -- Wrapper around readMaybe. Analogous to maybeFail in the Prologue, but no need to pull that in. + -- Wrapper around readMaybe. attempt :: Read a => String -> Parser a - attempt str = maybe (fail ("No parse: " <> str)) pure (readMaybe str) + attempt str = maybeM (fail ("No parse: " <> str)) (readMaybe str) -- Parse a hex value, leaning on the parser provided by Attoparsec. hex = fromIntegral <$> (string "0x" *> hexadecimal @Integer)