git.iko.soy/typeable/http-api-data
on master help sign in
Rename parseBoundedCaseInsensitiveTextData
commit46b2df70628600595d5778a413f4d8d66233e9dc authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateSun 11 Oct 2015, 00:02 (11 years ago) parentbf75392
2 files changed+13−13
Web/HttpApiData.hs+1−1 Web/HttpApiData/Internal.hs+12−12
Web/HttpApiData.hs+1−1
@@ -17,7 +17,7 @@ module Web.HttpApiData (
1717 -- * Helpers
1818 showTextData,
1919 readTextData,
20− parseBoundedCaseInsensitiveTextData,
20+ parseBoundedTextData,
2121 parseUrlPieceWithPrefix,
2222) where
2323
Web/HttpApiData/Internal.hs+12−12
@@ -167,9 +167,9 @@ parseUrlPieceWithPrefix pattern input
167167#if USE_TEXT_SHOW
168168-- | Parse values case insensitively based on @'TextShow'@ instance.
169169--
170−-- >>> parseBoundedCaseInsensitiveTextData "true" :: Either Text Bool
170+-- >>> parseBoundedTextData "true" :: Either Text Bool
171171-- Right True
172−-- >>> parseBoundedCaseInsensitiveTextData "FALSE" :: Either Text Bool
172+-- >>> parseBoundedTextData "FALSE" :: Either Text Bool
173173-- Right False
174174--
175175-- This can be used as a default implementation for enumeration types:
@@ -181,26 +181,26 @@ parseUrlPieceWithPrefix pattern input
181181-- showt = genericShowt
182182--
183183-- instance FromHttpApiData MyData where
184−-- parseUrlPiece = parseBoundedCaseInsensitiveTextData
184+-- parseUrlPiece = parseBoundedTextData
185185-- @
186−parseBoundedCaseInsensitiveTextData :: forall a. (TextShow a, Bounded a, Enum a) => Text -> Either Text a
186+parseBoundedTextData :: forall a. (TextShow a, Bounded a, Enum a) => Text -> Either Text a
187187#else
188188-- | Parse values case insensitively based on @'Show'@ instance.
189189--
190−-- >>> parseBoundedCaseInsensitiveTextData "true" :: Either Text Bool
190+-- >>> parseBoundedTextData "true" :: Either Text Bool
191191-- Right True
192−-- >>> parseBoundedCaseInsensitiveTextData "FALSE" :: Either Text Bool
192+-- >>> parseBoundedTextData "FALSE" :: Either Text Bool
193193-- Right False
194194--
195195-- This can be used as a default implementation for enumeration types:
196196--
197197-- >>> data MyData = Foo | Bar | Baz deriving (Show, Bounded, Enum)
198−-- >>> instance FromHttpApiData MyData where parseUrlPiece = parseBoundedCaseInsensitiveTextData
198+-- >>> instance FromHttpApiData MyData where parseUrlPiece = parseBoundedTextData
199199-- >>> parseUrlPiece "foo" :: Either Text MyData
200200-- Right Foo
201−parseBoundedCaseInsensitiveTextData :: forall a. (Show a, Bounded a, Enum a) => Text -> Either Text a
201+parseBoundedTextData :: forall a. (Show a, Bounded a, Enum a) => Text -> Either Text a
202202#endif
203−parseBoundedCaseInsensitiveTextData = parseMaybeTextData (flip lookup values . T.toLower)
203+parseBoundedTextData = parseMaybeTextData (flip lookup values . T.toLower)
204204 where
205205 values = map (showTextData &&& id) [minBound..maxBound :: a]
206206
@@ -221,7 +221,7 @@ readMaybeTextData = readMaybe . T.unpack
221221-- >>> readTextData "true" :: Either Text Bool
222222-- Left "could not parse: `true'"
223223--
224−-- See @'parseBoundedCaseInsensitiveTextData'@.
224+-- See @'parseBoundedTextData'@.
225225readTextData :: Read a => Text -> Either Text a
226226readTextData = parseMaybeTextData readMaybeTextData
227227
@@ -346,8 +346,8 @@ instance FromHttpApiData Void where
346346 parseUrlPiece _ = Left "Void cannot be parsed!"
347347#endif
348348
349−instance FromHttpApiData Bool where parseUrlPiece = parseBoundedCaseInsensitiveTextData
350−instance FromHttpApiData Ordering where parseUrlPiece = parseBoundedCaseInsensitiveTextData
349+instance FromHttpApiData Bool where parseUrlPiece = parseBoundedTextData
350+instance FromHttpApiData Ordering where parseUrlPiece = parseBoundedTextData
351351instance FromHttpApiData Double where parseUrlPiece = runReader rational
352352instance FromHttpApiData Float where parseUrlPiece = runReader rational
353353instance FromHttpApiData Int where parseUrlPiece = parseBounded (signed decimal)