packages feed

uri-bytestring 0.2.3.0 → 0.2.3.1

raw patch · 5 files changed

+53/−8 lines, 5 files

Files

changelog.md view
@@ -1,3 +1,6 @@+0.2.3.1+* Add `relativeRef` quasi-quoter.+ 0.2.3.0 * Add `URI.ByteString.QQ` and the `uri` quasiquoter to be able to express statically known to be valid URIs, e.g. `example = [uri|http://www.example.com|]`. Thanks to [reactormonk](https://github.com/reactormonk). 
src/URI/ByteString/QQ.hs view
@@ -3,7 +3,10 @@ {-# LANGUAGE GADTs              #-} {-# LANGUAGE CPP                #-} -module URI.ByteString.QQ where+module URI.ByteString.QQ+    ( uri+    , relativeRef+    ) where  import Language.Haskell.TH.Quote import URI.ByteString@@ -19,6 +22,24 @@ uri = QuasiQuoter { quoteExp = \s ->                       let                         parsedURI = either (\err -> error $ show err) id (parseURI laxURIParserOptions (pack s))+                      in+                        [| parsedURI |],+                   quotePat = error "Not implemented.",+                   quoteType = error "Not implemented.",+                   quoteDec = error "Not implemented."+                  }+++-------------------------------------------------------------------------------+-- | Allows relative ref literals via QuasiQuotes language extension.+--+-- >>> {-# LANGUAGE QuasiQuotes #-}+-- >>> ref :: RelativeRef+-- >>> ref = [relativeRef|/foo?bar=baz#quux|]+relativeRef :: QuasiQuoter+relativeRef = QuasiQuoter { quoteExp = \s ->+                      let+                        parsedURI = either (\err -> error $ show err) id (parseRelativeRef laxURIParserOptions (pack s))                       in                         [| parsedURI |],                    quotePat = error "Not implemented.",
test/Main.hs view
@@ -1,9 +1,10 @@ module Main (main) where  --------------------------------------------------------------------------------import Test.Tasty+import           Test.Tasty --------------------------------------------------------------------------------import URI.ByteStringTests+import qualified URI.ByteStringTests+import qualified URI.ByteStringQQTests -------------------------------------------------------------------------------  @@ -14,4 +15,5 @@ testSuite = testGroup "uri-bytestring"   [     URI.ByteStringTests.tests+  , URI.ByteStringQQTests.tests   ]
test/URI/ByteStringQQTests.hs view
@@ -1,9 +1,28 @@-{-# LANGUAGE QuasiQuotes         #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE QuasiQuotes       #-}+module URI.ByteStringQQTests (tests) where -module URI.ByteStringQQTests (quasiTest) where -import           URI.ByteString.QQ+-------------------------------------------------------------------------------+import           Test.Tasty+import           Test.Tasty.HUnit+------------------------------------------------------------------------------- import           URI.ByteString+import           URI.ByteString.QQ+------------------------------------------------------------------------------- + quasiTest :: URI-quasiTest = [uri|https://stackage.org|]+quasiTest = [uri|https://stackage.org/foo?bar=baz#quux|]+++quasiRelTest :: RelativeRef+quasiRelTest = [relativeRef|/foo?bar=baz#quux|]++tests :: TestTree+tests = testGroup "URI.ByteString.QQ"+  [ testCase "uri quasi quoter produces expected RelativeRef" $ do+      quasiTest @?= URI (Scheme "https") (Just (Authority Nothing (Host "stackage.org") Nothing)) "/foo" (Query [("bar", "baz")]) (Just "quux")+  , testCase "relativeRef quasi quoter produces expected RelativeRef" $ do+      quasiRelTest @?= RelativeRef Nothing "/foo" (Query [("bar", "baz")]) (Just "quux")+  ]
uri-bytestring.cabal view
@@ -1,5 +1,5 @@ name:                uri-bytestring-version:             0.2.3.0+version:             0.2.3.1 synopsis:            Haskell URI parsing as ByteStrings description: uri-bytestring aims to be an RFC3986 compliant URI parser that uses efficient ByteStrings for parsing and representing the URI data. license:             BSD3