@@ -6,12 +6,12 @@ module Servant.Common.Text
66 , ToText(..)
77 ) where
88
9+import Control.Applicative ((<$>))
910import Data.Int (Int16, Int32, Int64, Int8)
1011import Data.String.Conversions (cs)
1112import Data.Text (Text)
1213import Data.Text.Read (Reader, decimal, rational, signed)
1314import Data.Word (Word, Word16, Word32, Word64, Word8)
14−import GHC.Float (double2Float)
1515
1616-- | For getting values from url captures and query string parameters
1717-- Instances should obey:
@@ -125,7 +125,7 @@ instance ToText Integer where
125125 toText = cs . show
126126
127127instance FromText Double where
128− fromText = runReader rational
128+ fromText x = fromRational <$> runReader rational x
129129
130130instance ToText Double where
131131 toText = cs . show
@@ -133,7 +133,7 @@ instance ToText Double where
133133instance FromText Float where
134134 -- Double is more practically accurate due to weird rounding when using
135135 -- rational. We convert to double and then convert to Float.
136− fromText = fmap double2Float . runReader rational
136+ fromText x = fromRational <$> runReader rational x
137137
138138instance ToText Float where
139139 toText = cs . show