packages feed

uri-bytestring 0.2.2.1 → 0.2.3.0

raw patch · 7 files changed

+122/−16 lines, 7 filesdep +template-haskelldep +th-liftdep +th-lift-instancesPVP ok

version bump matches the API change (PVP)

Dependencies added: template-haskell, th-lift, th-lift-instances

API changes (from Hackage documentation)

+ URI.ByteString.QQ: uri :: QuasiQuoter

Files

README.md view
@@ -14,3 +14,4 @@ * [Brendan Hay](http://github.com/brendanhay) * [k0ral](https://github.com/k0ral) * [Michael Hatfield](https://github.com/mikehat)+* [reactormonk](https://github.com/reactormonk)
changelog.md view
@@ -1,3 +1,6 @@+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).+ 0.2.2.1 * Drop dependency on derive in tests. 
+ src/URI/ByteString/QQ.hs view
@@ -0,0 +1,27 @@+{-# LANGUAGE TemplateHaskell    #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE GADTs              #-}+{-# LANGUAGE CPP                #-}++module URI.ByteString.QQ where++import Language.Haskell.TH.Quote+import URI.ByteString+import Data.ByteString.Char8+import Instances.TH.Lift()++-- | Allows uri literals via QuasiQuotes language extension.+--+-- >>> {-# LANGUAGE QuasiQuotes #-}+-- >>> stackage :: URI+-- >>> stackage = [uri|http://stackage.org|]+uri :: QuasiQuoter+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."+                  }
src/URI/ByteString/Types.hs view
@@ -4,6 +4,11 @@ {-# LANGUAGE GADTs                      #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE StandaloneDeriving         #-}+#ifdef LIFT_COMPAT+{-# LANGUAGE TemplateHaskell            #-}+#else+{-# LANGUAGE DeriveLift                 #-}+#endif module URI.ByteString.Types where  -------------------------------------------------------------------------------@@ -13,21 +18,37 @@ import           Data.Typeable import           Data.Word import           GHC.Generics+import           Instances.TH.Lift() ------------------------------------------------------------------------------- import           Prelude --------------------------------------------------------------------------------+#ifdef LIFT_COMPAT+import           Language.Haskell.TH.Syntax()+import           Language.Haskell.TH.Lift+#else+import           Language.Haskell.TH.Syntax+#endif  -- | Required first component to referring to a specification for the -- remainder of the URI's components, e.g. "http" or "https" newtype Scheme = Scheme { schemeBS :: ByteString }   deriving (Show, Eq, Generic, Typeable, Ord) +#ifdef LIFT_COMPAT+deriveLift ''Scheme+#else+deriving instance Lift Scheme+#endif  ------------------------------------------------------------------------------- newtype Host = Host { hostBS :: ByteString }   deriving (Show, Eq, Generic, Typeable, Ord) +#ifdef LIFT_COMPAT+deriveLift ''Host+#else+deriving instance Lift Host+#endif  ------------------------------------------------------------------------------- -- | While some libraries have chosen to limit this to a Word16, the@@ -35,28 +56,66 @@ newtype Port = Port { portNumber :: Int }   deriving (Show, Eq, Generic, Typeable, Ord) +#ifdef LIFT_COMPAT+deriveLift ''Port+#else+deriving instance Lift Port+#endif  -------------------------------------------------------------------------------+data UserInfo = UserInfo {+      uiUsername :: ByteString+    , uiPassword :: ByteString+    } deriving (Show, Eq, Generic, Typeable, Ord)++#ifdef LIFT_COMPAT+deriveLift ''UserInfo+#else+deriving instance Lift UserInfo+#endif++------------------------------------------------------------------------------- data Authority = Authority {       authorityUserInfo :: Maybe UserInfo     , authorityHost     :: Host     , authorityPort     :: Maybe Port     } deriving (Show, Eq, Generic, Typeable, Ord) +#ifdef LIFT_COMPAT+deriveLift ''Authority+#else+deriving instance Lift Authority+#endif  --------------------------------------------------------------------------------data UserInfo = UserInfo {-      uiUsername :: ByteString-    , uiPassword :: ByteString-    } deriving (Show, Eq, Generic, Typeable, Ord)+newtype Query = Query { queryPairs :: [(ByteString, ByteString)] }+              deriving (Show, Eq, Monoid, Generic, Typeable, Ord) +#ifdef LIFT_COMPAT+deriveLift ''Query+#else+deriving instance Lift Query+#endif  --------------------------------------------------------------------------------newtype Query = Query { queryPairs :: [(ByteString, ByteString)] }-              deriving (Show, Eq, Monoid, Generic, Typeable, Ord)+data Absolute deriving(Typeable) +#ifdef LIFT_COMPAT+deriveLift ''Absolute+#else+deriving instance Lift Absolute+#endif  -------------------------------------------------------------------------------+data Relative deriving(Typeable)++#ifdef LIFT_COMPAT+deriveLift ''Relative+#else+deriving instance Lift Relative+#endif++------------------------------------------------------------------------------- -- | Note: URI fragment does not include the # data URIRef a where   URI :: { uriScheme :: Scheme@@ -75,18 +134,15 @@ deriving instance Eq (URIRef a) -- deriving instance Generic (URIRef a) deriving instance Ord (URIRef a)+#ifdef LIFT_COMPAT+deriveLift ''URIRef+#else+deriving instance Lift (URIRef a)+#endif  #ifdef WITH_TYPEABLE deriving instance Typeable URIRef #endif----------------------------------------------------------------------------------data Absolute deriving(Typeable)-----------------------------------------------------------------------------------data Relative deriving(Typeable)-  ------------------------------------------------------------------------------- type URI = URIRef Absolute
+ test/URI/ByteStringQQTests.hs view
@@ -0,0 +1,9 @@+{-# LANGUAGE QuasiQuotes         #-}++module URI.ByteStringQQTests (quasiTest) where++import           URI.ByteString.QQ+import           URI.ByteString++quasiTest :: URI+quasiTest = [uri|https://stackage.org|]
test/URI/ByteStringTests.hs view
@@ -20,6 +20,7 @@ import           URI.ByteString import           URI.ByteString.Arbitrary () -------------------------------------------------------------------------------+import           URI.ByteStringQQTests    ()  tests :: TestTree tests = testGroup "URI.Bytestring"
uri-bytestring.cabal view
@@ -1,5 +1,5 @@ name:                uri-bytestring-version:             0.2.2.1+version:             0.2.3.0 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@@ -29,6 +29,7 @@ library   exposed-modules:     URI.ByteString+    URI.ByteString.QQ   other-modules:     URI.ByteString.Lens     URI.ByteString.Types@@ -40,6 +41,8 @@     , base             >= 4.6     && < 4.10     , bytestring       >= 0.9.1   && < 0.11     , blaze-builder    >= 0.3.0.0 && < 0.5+    , template-haskell >= 2.9     && < 2.12+    , th-lift-instances >= 0.1.8  && < 0.2     , containers    hs-source-dirs:      src@@ -48,6 +51,11 @@   if impl(ghc >= 7.8)     cpp-options: -DWITH_TYPEABLE +  if impl(ghc < 8)+    cpp-options: -DLIFT_COMPAT+    build-depends:+      th-lift >= 0.7.5 && < 0.8+   if flag(lib-Werror)     ghc-options: -Werror @@ -59,6 +67,7 @@   other-modules:     URI.ByteString.Arbitrary     URI.ByteStringTests+    URI.ByteStringQQTests   hs-source-dirs: test   build-depends:       uri-bytestring