packages feed

http-api-data (empty) → 0.1.0

raw patch · 9 files changed

+627/−0 lines, 9 filesdep +Globdep +HUnitdep +QuickChecksetup-changed

Dependencies added: Glob, HUnit, QuickCheck, base, bytestring, doctest, hspec, http-api-data, text, time

Files

+ CHANGELOG.md view
@@ -0,0 +1,1 @@+
+ LICENSE view
@@ -0,0 +1,25 @@+The following license covers this documentation, and the source code, except+where otherwise indicated.++Copyright 2009, Michael Snoyman. All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++* Redistributions of source code must retain the above copyright notice, this+  list of conditions and the following disclaimer.++* Redistributions in binary form must reproduce the above copyright notice,+  this list of conditions and the following disclaimer in the documentation+  and/or other materials provided with the distribution.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY EXPRESS OR+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO+EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,+OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,52 @@+# http-api-data++[![Build Status](https://secure.travis-ci.org/fizruk/http-api-data.png?branch=master)](http://travis-ci.org/fizruk/http-api-data)++This package defines typeclasses used for converting Haskell data types to and from HTTP API data.++### Examples++Booleans:++```+>>> toUrlPiece True+"True"+>>> parseUrlPiece "False" :: Either Text Bool+Right False+>>> parseUrlPiece "something else" :: Either Text Bool+Left "could not parse: `something else'"+```++Numbers:++```+>>> toUrlPiece 45.2+"45.2"+>>> parseUrlPiece "452" :: Either Text Int+Right 452+>>> parseUrlPiece "256" :: Either Text Int8+Left "out of bounds: `256' (should be between -128 and 127)"+```++Strings:++```+>>> toHeader "hello"+"hello"+>>> parseHeader "world" :: Either Text String+Right "world"+```++Calendar day:++```+>>> toQueryParam (fromGregorian 2015 10 03)+"2015-10-03"+>>> toGregorian <$> parseQueryParam "2016-12-01"+Right (2016,12,1)+```++## Contributing++Contributions and bug reports are welcome!+
+ Setup.lhs view
@@ -0,0 +1,7 @@+#!/usr/bin/env runhaskell++> module Main where+> import Distribution.Simple++> main :: IO ()+> main = defaultMain
+ Web/HttpApiData.hs view
@@ -0,0 +1,57 @@+-- |+-- Convert Haskell values to and from HTTP API data+-- such as URL pieces, headers and query parameters.+module Web.HttpApiData (+  -- * Examples+  -- $examples++  -- * Classes+  ToHttpApiData (..),+  FromHttpApiData (..),+) where++import Web.HttpApiData.Internal++-- $setup+--+-- >>> :set -XOverloadedStrings+-- >>> import Control.Applicative+-- >>> import Data.Time+-- >>> import Data.Int+-- >>> import Data.Text (Text)+-- >>> import Data.Time (Day)+-- >>> import Data.Version++-- $examples+--+-- Booleans:+--+-- >>> toUrlPiece True+-- "true"+-- >>> parseUrlPiece "false" :: Either Text Bool+-- Right False+-- >>> parseUrlPiece "something else" :: Either Text Bool+-- Left "could not parse: `something else'"+--+-- Numbers:+--+-- >>> toUrlPiece 45.2+-- "45.2"+-- >>> parseUrlPiece "452" :: Either Text Int+-- Right 452+-- >>> parseUrlPiece "256" :: Either Text Int8+-- Left "out of bounds: `256' (should be between -128 and 127)"+--+-- Strings:+--+-- >>> toHeader "hello"+-- "hello"+-- >>> parseHeader "world" :: Either Text String+-- Right "world"+--+-- Calendar day:+--+-- >>> toQueryParam (fromGregorian 2015 10 03)+-- "2015-10-03"+-- >>> toGregorian <$> parseQueryParam "2016-12-01"+-- Right (2016,12,1)
+ Web/HttpApiData/Internal.hs view
@@ -0,0 +1,322 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE DefaultSignatures #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeSynonymInstances #-}+-- |+-- Convert Haskell values to and from HTTP API data+-- such as URL pieces, headers and query parameters.+module Web.HttpApiData.Internal where++import Control.Applicative+import Control.Arrow ((&&&))++import Data.Monoid+import Data.ByteString (ByteString)++import Data.Int+import Data.Word++import Data.Text (Text)+import Data.Text.Encoding (encodeUtf8, decodeUtf8)+import Data.Text.Read (signed, decimal, rational, Reader)+import qualified Data.Text as T+import qualified Data.Text.Lazy as L++import Data.Time (Day)+import Data.Version++#if MIN_VERSION_base(4,8,0)+import Data.Void+#endif++import Text.Read (readMaybe)+import Text.ParserCombinators.ReadP (readP_to_S)++-- | Convert value to HTTP API data.+class ToHttpApiData a where+  {-# MINIMAL toUrlPiece | toQueryParam #-}+  -- | Convert to URL path piece.+  toUrlPiece :: a -> Text+  toUrlPiece = toQueryParam++  -- | Convert to HTTP header value.+  toHeader :: a -> ByteString+  toHeader = encodeUtf8 . toUrlPiece++  -- | Convert to query param value.+  toQueryParam :: a -> Text+  toQueryParam = toUrlPiece++-- | Parse value from HTTP API data.+class FromHttpApiData a where+  {-# MINIMAL parseUrlPiece | parseQueryParam #-}+  -- | Parse URL path piece.+  parseUrlPiece :: Text -> Either Text a+  parseUrlPiece = parseQueryParam++  -- | Parse HTTP header value.+  parseHeader :: ByteString -> Either Text a+  parseHeader = parseUrlPiece . decodeUtf8++  -- | Parse query param value.+  parseQueryParam :: Text -> Either Text a+  parseQueryParam = parseUrlPiece++-- | Parse URL path piece in a @'Maybe'@.+--+-- >>> parseUrlPieceMaybe "12" :: Maybe Int+-- Just 12+parseUrlPieceMaybe :: FromHttpApiData a => Text -> Maybe a+parseUrlPieceMaybe = either (const Nothing) Just . parseUrlPiece++-- | Parse HTTP header value in a @'Maybe'@.+--+-- >>> parseHeaderMaybe "hello" :: Maybe Text+-- Just "hello"+parseHeaderMaybe :: FromHttpApiData a => ByteString -> Maybe a+parseHeaderMaybe = either (const Nothing) Just . parseHeader++-- | Parse query param value in a @'Maybe'@.+--+-- >>> parseQueryParamMaybe "true" :: Maybe Bool+-- Just True+parseQueryParamMaybe :: FromHttpApiData a => Text -> Maybe a+parseQueryParamMaybe = either (const Nothing) Just . parseQueryParam++-- | Default parsing error.+defaultParseError :: Text -> Either Text a+defaultParseError input = Left ("could not parse: `" <> input <> "'")++-- | Convert @'Maybe'@ parser into @'Either' 'Text'@ parser with default error message.+parseMaybeTextData :: (Text -> Maybe a) -> (Text -> Either Text a)+parseMaybeTextData parse input =+  case parse input of+    Nothing  -> defaultParseError input+    Just val -> Right val++-- | Convert to URL piece using @'Show'@ instance.+-- The result is always lower cased.+--+-- >>> showTextData True+-- "true"+--+-- This can be used as a default implementation for enumeration types:+--+-- >>> data MyData = Foo | Bar | Baz deriving (Show)+-- >>> instance ToHttpApiData MyData where toUrlPiece = showTextData+-- >>> toUrlPiece Foo+-- "foo"+showTextData :: Show a => a -> Text+showTextData = T.toLower . T.pack . show++-- | Parse given text case insensitive and return the rest of the input.+--+-- >>> parseUrlPieceWithPrefix "Just " "just 10" :: Either Text Int+-- Right 10+-- >>> parseUrlPieceWithPrefix "Left " "left" :: Either Text Bool+-- Left "could not parse: `left'"+--+-- This can be used to implement @'FromHttpApiData'@ for single field constructors:+--+-- >>> data Foo = Foo Int deriving (Show)+-- >>> instance FromHttpApiData Foo where parseUrlPiece s = Foo <$> parseUrlPieceWithPrefix "Foo " s+-- >>> parseUrlPiece "foo 1" :: Either Text Foo+-- Right (Foo 1)+parseUrlPieceWithPrefix :: FromHttpApiData a => Text -> Text -> Either Text a+parseUrlPieceWithPrefix pattern input+  | T.toLower pattern == T.toLower prefix = parseUrlPiece rest+  | otherwise                             = defaultParseError input+  where+    (prefix, rest) = T.splitAt (T.length pattern) input++-- | Parse values case insensitively based on @'Show'@ instance.+--+-- >>> parseBoundedCaseInsensitiveTextData "true" :: Either Text Bool+-- Right True+-- >>> parseBoundedCaseInsensitiveTextData "FALSE" :: Either Text Bool+-- Right False+--+-- This can be used as a default implementation for enumeration types:+--+-- >>> data MyData = Foo | Bar | Baz deriving (Show, Bounded, Enum)+-- >>> instance FromHttpApiData MyData where parseUrlPiece = parseBoundedCaseInsensitiveTextData+-- >>> parseUrlPiece "foo" :: Either Text MyData+-- Right Foo+parseBoundedCaseInsensitiveTextData :: forall a. (Show a, Bounded a, Enum a) => Text -> Either Text a+parseBoundedCaseInsensitiveTextData = parseMaybeTextData (flip lookup values . T.toLower)+  where+    values = map (showTextData &&& id) [minBound..maxBound :: a]++-- | Parse URL piece using @'Read'@ instance.+readMaybeTextData :: Read a => Text -> Maybe a+readMaybeTextData = readMaybe . T.unpack++-- | Parse URL piece using @'Read'@ instance.+readEitherTextData :: Read a => Text -> Either Text a+readEitherTextData = parseMaybeTextData readMaybeTextData++-- | Run @'Reader'@ as HTTP API data parser.+runReader :: Reader a -> Text -> Either Text a+runReader reader input =+  case reader input of+    Left err          -> Left (T.pack err)+    Right (x, rest)+      | T.null rest -> Right x+      | otherwise   -> defaultParseError input++-- | Run @'Reader'@ to parse bounded integral value with bounds checking.+--+-- >>> parseBounded decimal "256" :: Either Text Word8+-- Left "out of bounds: `256' (should be between 0 and 255)"+parseBounded :: forall a. (Bounded a, Integral a) => Reader Integer -> Text -> Either Text a+parseBounded reader input = do+  n <- runReader reader input+  if (n > h || n < l)+    then Left  ("out of bounds: `" <> input <> "' (should be between " <> T.pack (show l) <> " and " <> T.pack (show h) <> ")")+    else Right (fromInteger n)+  where+    l = toInteger (minBound :: a)+    h = toInteger (maxBound :: a)++-- |+-- >>> toUrlPiece ()+-- "_"+instance ToHttpApiData () where+  toUrlPiece () = "_"++instance ToHttpApiData Char     where toUrlPiece = T.singleton++-- |+-- >>> toUrlPiece (Version [1, 2, 3] [])+-- "1.2.3"+instance ToHttpApiData Version where+  toUrlPiece = T.pack . showVersion++#if MIN_VERSION_base(4,8,0)+instance ToHttpApiData Void where+  toUrlPiece = absurd+#endif++instance ToHttpApiData Bool     where toUrlPiece = showTextData+instance ToHttpApiData Ordering where toUrlPiece = showTextData+instance ToHttpApiData Double   where toUrlPiece = showTextData+instance ToHttpApiData Float    where toUrlPiece = showTextData+instance ToHttpApiData Int      where toUrlPiece = showTextData+instance ToHttpApiData Int8     where toUrlPiece = showTextData+instance ToHttpApiData Int16    where toUrlPiece = showTextData+instance ToHttpApiData Int32    where toUrlPiece = showTextData+instance ToHttpApiData Int64    where toUrlPiece = showTextData+instance ToHttpApiData Integer  where toUrlPiece = showTextData+instance ToHttpApiData Word     where toUrlPiece = showTextData+instance ToHttpApiData Word8    where toUrlPiece = showTextData+instance ToHttpApiData Word16   where toUrlPiece = showTextData+instance ToHttpApiData Word32   where toUrlPiece = showTextData+instance ToHttpApiData Word64   where toUrlPiece = showTextData+instance ToHttpApiData String   where toUrlPiece = T.pack+instance ToHttpApiData Text     where toUrlPiece = id+instance ToHttpApiData L.Text   where toUrlPiece = L.toStrict+instance ToHttpApiData Day      where toUrlPiece = showTextData++instance ToHttpApiData All where toUrlPiece = toUrlPiece . getAll+instance ToHttpApiData Any where toUrlPiece = toUrlPiece . getAny++instance ToHttpApiData a => ToHttpApiData (Dual a)    where toUrlPiece = toUrlPiece . getDual+instance ToHttpApiData a => ToHttpApiData (Sum a)     where toUrlPiece = toUrlPiece . getSum+instance ToHttpApiData a => ToHttpApiData (Product a) where toUrlPiece = toUrlPiece . getProduct+instance ToHttpApiData a => ToHttpApiData (First a)   where toUrlPiece = toUrlPiece . getFirst+instance ToHttpApiData a => ToHttpApiData (Last a)    where toUrlPiece = toUrlPiece . getLast++-- |+-- >>> toUrlPiece (Just "Hello")+-- "just Hello"+instance ToHttpApiData a => ToHttpApiData (Maybe a) where+  toUrlPiece (Just x) = "just " <> toUrlPiece x+  toUrlPiece Nothing  = "nothing"++-- |+-- >>> toUrlPiece (Left "err" :: Either String Int)+-- "left err"+-- >>> toUrlPiece (Right 3 :: Either String Int)+-- "right 3"+instance (ToHttpApiData a, ToHttpApiData b) => ToHttpApiData (Either a b) where+  toUrlPiece (Left x)  = "left " <> toUrlPiece x+  toUrlPiece (Right x) = "right " <> toUrlPiece x++-- |+-- >>> parseUrlPiece "_" :: Either Text ()+-- Right ()+instance FromHttpApiData () where+  parseUrlPiece "_" = return ()+  parseUrlPiece s   = defaultParseError s++instance FromHttpApiData Char where+  parseUrlPiece s =+    case T.uncons s of+      Just (c, s') | T.null s' -> return c+      _                        -> defaultParseError s++-- |+-- >>> showVersion <$> parseUrlPiece "1.2.3"+-- Right "1.2.3"+instance FromHttpApiData Version where+  parseUrlPiece s =+    case reverse (readP_to_S parseVersion (T.unpack s)) of+      ((x, ""):_) -> return x+      _           -> defaultParseError s++#if MIN_VERSION_base(4,8,0)+instance FromHttpApiData Void where+  parseUrlPiece _ = Left "Void cannot be parsed!"+#endif++instance FromHttpApiData Bool     where parseUrlPiece = parseBoundedCaseInsensitiveTextData+instance FromHttpApiData Ordering where parseUrlPiece = parseBoundedCaseInsensitiveTextData+instance FromHttpApiData Double   where parseUrlPiece = runReader rational+instance FromHttpApiData Float    where parseUrlPiece = runReader rational+instance FromHttpApiData Int      where parseUrlPiece = parseBounded (signed decimal)+instance FromHttpApiData Int8     where parseUrlPiece = parseBounded (signed decimal)+instance FromHttpApiData Int16    where parseUrlPiece = parseBounded (signed decimal)+instance FromHttpApiData Int32    where parseUrlPiece = parseBounded (signed decimal)+instance FromHttpApiData Int64    where parseUrlPiece = parseBounded (signed decimal)+instance FromHttpApiData Integer  where parseUrlPiece = runReader (signed decimal)+instance FromHttpApiData Word     where parseUrlPiece = parseBounded decimal+instance FromHttpApiData Word8    where parseUrlPiece = parseBounded decimal+instance FromHttpApiData Word16   where parseUrlPiece = parseBounded decimal+instance FromHttpApiData Word32   where parseUrlPiece = parseBounded decimal+instance FromHttpApiData Word64   where parseUrlPiece = parseBounded decimal+instance FromHttpApiData String   where parseUrlPiece = Right . T.unpack+instance FromHttpApiData Text     where parseUrlPiece = Right+instance FromHttpApiData L.Text   where parseUrlPiece = Right . L.fromStrict+instance FromHttpApiData Day      where parseUrlPiece = readEitherTextData++instance FromHttpApiData All where parseUrlPiece = fmap All . parseUrlPiece+instance FromHttpApiData Any where parseUrlPiece = fmap Any . parseUrlPiece++instance FromHttpApiData a => FromHttpApiData (Dual a)    where parseUrlPiece = fmap Dual    . parseUrlPiece+instance FromHttpApiData a => FromHttpApiData (Sum a)     where parseUrlPiece = fmap Sum     . parseUrlPiece+instance FromHttpApiData a => FromHttpApiData (Product a) where parseUrlPiece = fmap Product . parseUrlPiece+instance FromHttpApiData a => FromHttpApiData (First a)   where parseUrlPiece = fmap First   . parseUrlPiece+instance FromHttpApiData a => FromHttpApiData (Last a)    where parseUrlPiece = fmap Last    . parseUrlPiece++-- |+-- >>> parseUrlPiece "Just 123" :: Either Text (Maybe Int)+-- Right (Just 123)+instance FromHttpApiData a => FromHttpApiData (Maybe a) where+  parseUrlPiece s+    | T.toLower (T.take 7 s) == "nothing" = return Nothing+    | otherwise                           = Just <$> parseUrlPieceWithPrefix "Just " s++-- |+-- >>> parseUrlPiece "Right 123" :: Either Text (Either String Int)+-- Right (Right 123)+instance (FromHttpApiData a, FromHttpApiData b) => FromHttpApiData (Either a b) where+  parseUrlPiece s =+        Right <$> parseUrlPieceWithPrefix "Right " s+    <!> Left  <$> parseUrlPieceWithPrefix "Left " s+    where+      infixl 3 <!>+      Left _ <!> y = y+      x      <!> _ = x+
+ http-api-data.cabal view
@@ -0,0 +1,50 @@+name:            http-api-data+version:         0.1.0+license:         BSD3+license-file:    LICENSE+author:          Michael Snoyman <michael@snoyman.com>+maintainer:      Nickolay Kudasov <nickolay.kudasov@gmail.com>+synopsis:        Converting to/from HTTP API data like URL pieces, headers and query parameters.+description:     Please see README.md+homepage:        http://github.com/fizruk/http-api-data+category:        Web+stability:       unstable+cabal-version:   >= 1.8+build-type:      Simple+extra-source-files:+  test/*.hs+  CHANGELOG.md+  README.md++library+    build-depends:   base             >= 4       && < 5+                   , text             >= 0.5+                   , bytestring+                   , time+    exposed-modules:+      Web.HttpApiData+      Web.HttpApiData.Internal+    ghc-options:     -Wall++test-suite spec+    type:          exitcode-stdio-1.0+    main-is:       Spec.hs+    hs-source-dirs: test+    ghc-options:   -Wall+    build-depends:   HUnit+                   , hspec >= 1.3+                   , base >= 4 && < 5+                   , QuickCheck+                   , http-api-data+                   , text+                   , time++test-suite doctest+    build-depends:    base, doctest, Glob+    hs-source-dirs:   test+    main-is:          DocTest.hs+    type:             exitcode-stdio-1.0++source-repository head+  type:     git+  location: https://github.com/fizruk/http-api-data
+ test/DocTest.hs view
@@ -0,0 +1,7 @@+module Main (main) where++import System.FilePath.Glob (glob)+import Test.DocTest (doctest)++main :: IO ()+main = glob "Web/**/*.hs" >>= doctest
+ test/Spec.hs view
@@ -0,0 +1,106 @@+{-# Language ScopedTypeVariables #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+module Main where++import Control.Applicative++import Data.Int+import Data.Char+import Data.Word+import Data.Time+import qualified Data.Text as T+import qualified Data.Text.Lazy as L+import Data.Version++import Test.Hspec+import Test.Hspec.QuickCheck(prop)+import Test.QuickCheck++import Web.HttpApiData+import Web.HttpApiData.Internal++instance Arbitrary T.Text where+  arbitrary = T.pack <$> arbitrary++instance Arbitrary L.Text where+  arbitrary = L.pack <$> arbitrary++instance Arbitrary Day where+  arbitrary = liftA3 fromGregorian (fmap abs arbitrary) arbitrary arbitrary++instance Arbitrary Version where+  arbitrary = (version . map abs) <$> nonempty+    where+      version branch = Version branch []+      nonempty = liftA2 (:) arbitrary arbitrary++main :: IO ()+main = hspec spec++(<=>) :: Eq a => (a -> b) -> (b -> Either T.Text a) -> a -> Bool+(f <=> g) x = g (f x) == Right x++data Proxy a = Proxy++checkUrlPiece :: forall a. (Eq a, ToHttpApiData a, FromHttpApiData a, Show a, Arbitrary a) => Proxy a -> String -> Spec+checkUrlPiece _ name = prop name (toUrlPiece <=> parseUrlPiece :: a -> Bool)++data RandomCase a = RandomCase [Bool] a++instance ToHttpApiData a => Show (RandomCase a) where+  show rc@(RandomCase _ x) = show (toUrlPiece rc) ++ " (original: " ++ show (toUrlPiece x) ++ ")"++instance Eq a => Eq (RandomCase a) where+  RandomCase _ x == RandomCase _ y = x == y++instance Arbitrary a => Arbitrary (RandomCase a) where+  arbitrary = liftA2 RandomCase nonempty arbitrary+    where+      nonempty = liftA2 (:) arbitrary arbitrary++instance ToHttpApiData a => ToHttpApiData (RandomCase a) where+  toUrlPiece (RandomCase us x) = T.pack (zipWith (\u -> if u then toUpper else toLower) (cycle us) (T.unpack (toUrlPiece x)))++instance FromHttpApiData a => FromHttpApiData (RandomCase a) where+  parseUrlPiece s = RandomCase [] <$> parseUrlPiece s++-- | Check case insensitivity for @parseUrlPiece@.+checkUrlPieceI :: forall a. (Eq a, ToHttpApiData a, FromHttpApiData a, Show a, Arbitrary a) => Proxy a -> String -> Spec+checkUrlPieceI _ = checkUrlPiece (Proxy :: Proxy (RandomCase a))++spec :: Spec+spec = do+  describe "toUrlPiece <=> parseUrlPiece" $ do+    checkUrlPiece  (Proxy :: Proxy ())        "()"+    checkUrlPiece  (Proxy :: Proxy Char)      "Char"+    checkUrlPieceI (Proxy :: Proxy Bool)      "Bool"+    checkUrlPieceI (Proxy :: Proxy Ordering)  "Ordering"+    checkUrlPiece  (Proxy :: Proxy Int)       "Int"+    checkUrlPiece  (Proxy :: Proxy Int8)      "Int8"+    checkUrlPiece  (Proxy :: Proxy Int16)     "Int16"+    checkUrlPiece  (Proxy :: Proxy Int32)     "Int32"+    checkUrlPiece  (Proxy :: Proxy Int64)     "Int64"+    checkUrlPiece  (Proxy :: Proxy Integer)   "Integer"+    checkUrlPiece  (Proxy :: Proxy Word)      "Word"+    checkUrlPiece  (Proxy :: Proxy Word8)     "Word8"+    checkUrlPiece  (Proxy :: Proxy Word16)    "Word16"+    checkUrlPiece  (Proxy :: Proxy Word32)    "Word32"+    checkUrlPiece  (Proxy :: Proxy Word64)    "Word64"+    checkUrlPiece  (Proxy :: Proxy String)    "String"+    checkUrlPiece  (Proxy :: Proxy T.Text)    "Text.Strict"+    checkUrlPiece  (Proxy :: Proxy L.Text)    "Text.Lazy"+    checkUrlPiece  (Proxy :: Proxy Day)       "Day"+    checkUrlPiece  (Proxy :: Proxy Version)   "Version"++    checkUrlPiece  (Proxy :: Proxy (Maybe String))            "Maybe String"+    checkUrlPieceI (Proxy :: Proxy (Maybe Integer))           "Maybe Integer"+    checkUrlPiece  (Proxy :: Proxy (Either Integer T.Text))   "Either Integer Text"+    checkUrlPieceI (Proxy :: Proxy (Either Version Day))      "Either Version Day"++  it "bad integers are rejected" $ do+    parseUrlPieceMaybe (T.pack "123hello") `shouldBe` (Nothing :: Maybe Int)++  it "bounds checking works" $ do+    parseUrlPieceMaybe (T.pack "256") `shouldBe` (Nothing :: Maybe Int8)+    parseUrlPieceMaybe (T.pack "-10") `shouldBe` (Nothing :: Maybe Word)+