packages feed

giphy-api 0.2.5.0 → 0.3.0.0

raw patch · 4 files changed

+66/−52 lines, 4 filesdep +http-api-datadep +http-clientdep +http-client-tlsdep −eitherdep ~basedep ~servantdep ~servant-clientPVP ok

version bump matches the API change (PVP)

Dependencies added: http-api-data, http-client, http-client-tls

Dependencies removed: either

Dependency ranges changed: base, servant, servant-client

API changes (from Hackage documentation)

- Web.Giphy: instance Servant.Common.Text.FromText Web.Giphy.GifId
- Web.Giphy: instance Servant.Common.Text.FromText Web.Giphy.Key
- Web.Giphy: instance Servant.Common.Text.FromText Web.Giphy.PaginationOffset
- Web.Giphy: instance Servant.Common.Text.FromText Web.Giphy.Phrase
- Web.Giphy: instance Servant.Common.Text.FromText Web.Giphy.Query
- Web.Giphy: instance Servant.Common.Text.FromText Web.Giphy.Tag
- Web.Giphy: instance Servant.Common.Text.ToText Web.Giphy.GifId
- Web.Giphy: instance Servant.Common.Text.ToText Web.Giphy.Key
- Web.Giphy: instance Servant.Common.Text.ToText Web.Giphy.PaginationOffset
- Web.Giphy: instance Servant.Common.Text.ToText Web.Giphy.Phrase
- Web.Giphy: instance Servant.Common.Text.ToText Web.Giphy.Query
- Web.Giphy: instance Servant.Common.Text.ToText Web.Giphy.Tag
+ Web.Giphy: instance Web.HttpApiData.Internal.FromHttpApiData Web.Giphy.GifId
+ Web.Giphy: instance Web.HttpApiData.Internal.FromHttpApiData Web.Giphy.Key
+ Web.Giphy: instance Web.HttpApiData.Internal.FromHttpApiData Web.Giphy.PaginationOffset
+ Web.Giphy: instance Web.HttpApiData.Internal.FromHttpApiData Web.Giphy.Phrase
+ Web.Giphy: instance Web.HttpApiData.Internal.FromHttpApiData Web.Giphy.Query
+ Web.Giphy: instance Web.HttpApiData.Internal.FromHttpApiData Web.Giphy.Tag
+ Web.Giphy: instance Web.HttpApiData.Internal.ToHttpApiData Web.Giphy.GifId
+ Web.Giphy: instance Web.HttpApiData.Internal.ToHttpApiData Web.Giphy.Key
+ Web.Giphy: instance Web.HttpApiData.Internal.ToHttpApiData Web.Giphy.PaginationOffset
+ Web.Giphy: instance Web.HttpApiData.Internal.ToHttpApiData Web.Giphy.Phrase
+ Web.Giphy: instance Web.HttpApiData.Internal.ToHttpApiData Web.Giphy.Query
+ Web.Giphy: instance Web.HttpApiData.Internal.ToHttpApiData Web.Giphy.Tag
- Web.Giphy: type Giphy = ReaderT GiphyConfig (EitherT ServantError IO)
+ Web.Giphy: type Giphy = ReaderT GiphyConfig (ExceptT ServantError IO)

Files

changelog.md view
@@ -1,16 +1,21 @@ # Changelog +## v0.3.0.0++- Upgrade to Servant 0.5. No changes in the API, but it's not in Stackage yet+  (as of 2016-03-30).+ ## v0.2.5.0 -- Clarify servant bounds+- Clarify servant bounds.  ## v0.2.4.0 -- Include extra source files for stackage test suite+- Include extra source files for stackage test suite.  ## v0.2.3.0 -- Losen upper bounds for Stackage inclusion (aeson 0.11 compat)+- Losen upper bounds for Stackage inclusion (aeson 0.11 compat).  ## v0.2.2.0 @@ -28,4 +33,4 @@  ## v0.1.0.0 -- Initial release+- Initial release.
giphy-api.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack  name:           giphy-api-version:        0.2.5.0+version:        0.3.0.0 synopsis:       Giphy HTTP API wrapper and CLI search tool. description:    Please see README.md category:       Web@@ -38,12 +38,14 @@     , network-uri     , aeson     , containers-    , either     , microlens     , microlens-th     , mtl-    , servant >= 0.4 && < 0.5-    , servant-client >= 0.4 && < 0.5+    , servant >= 0.5+    , servant-client >= 0.5+    , http-api-data+    , http-client+    , http-client-tls   exposed-modules:       Web.Giphy   other-modules:
src/Web/Giphy.hs view
@@ -84,23 +84,27 @@   , random   ) where -import           Control.Monad              (MonadPlus (), forM, join, mzero)-import qualified Control.Monad.Reader       as Reader-import           Control.Monad.Trans        (MonadIO (), lift, liftIO)-import           Control.Monad.Trans.Either (EitherT, runEitherT)-import           Data.Aeson                 ((.:), (.:?))-import qualified Data.Aeson.Types           as Aeson-import qualified Data.Map.Strict            as Map-import           Data.Monoid                ((<>))-import qualified Data.Proxy                 as Proxy-import qualified Data.Text                  as T-import           GHC.Generics               (Generic ())-import qualified Lens.Micro.TH              as Lens-import qualified Network.URI                as URI-import           Servant.API                ((:<|>) (..), (:>))-import qualified Servant.API                as Servant-import qualified Servant.Client             as Servant-import qualified Text.Read                  as Read+import           Control.Monad           (MonadPlus (), forM, join, mzero)+import           Control.Monad.Except    (ExceptT, runExceptT)+import qualified Control.Monad.Reader    as Reader+import           Control.Monad.Trans     (MonadIO (), lift, liftIO)+import           Data.Aeson              ((.:), (.:?))+import qualified Data.Aeson.Types        as Aeson+import qualified Data.Map.Strict         as Map+import           Data.Monoid             ((<>))+import qualified Data.Proxy              as Proxy+import qualified Data.Text               as T+import           GHC.Generics            (Generic ())+import qualified Lens.Micro.TH           as Lens+import qualified Network.HTTP.Client     as HTTP+import           Network.HTTP.Client.TLS (tlsManagerSettings)+import qualified Network.URI             as URI+import           Servant.API             ((:<|>) (..), (:>))+import qualified Servant.API             as Servant+import qualified Servant.Client          as Servant+import qualified System.IO.Unsafe        as Unsafe+import qualified Text.Read               as Read+import qualified Web.HttpApiData         as Data  maybeParse :: (Monad m, MonadPlus m) => (a -> Maybe b) -> m a -> m b maybeParse f = (maybe mzero return . f =<<)@@ -118,27 +122,27 @@  -- | The API Key. See https://github.com/Giphy/GiphyAPI newtype Key = Key T.Text-  deriving (Servant.ToText, Servant.FromText, Show, Eq)+  deriving (Data.ToHttpApiData, Data.FromHttpApiData, Show, Eq)  -- | A search query. newtype Query = Query T.Text-  deriving (Servant.ToText, Servant.FromText, Show, Eq)+  deriving (Data.ToHttpApiData, Data.FromHttpApiData, Show, Eq)  -- | A phrase or term used for translation. newtype Phrase = Phrase T.Text-  deriving (Servant.ToText, Servant.FromText, Show, Eq)+  deriving (Data.ToHttpApiData, Data.FromHttpApiData, Show, Eq)  -- | A tag to retrieve a random GIF for. newtype Tag = Tag T.Text-  deriving (Servant.ToText, Servant.FromText, Show, Eq)+  deriving (Data.ToHttpApiData, Data.FromHttpApiData, Show, Eq)  -- | A unique gif identifier. newtype GifId = GifId T.Text-  deriving (Servant.ToText, Servant.FromText, Show, Eq)+  deriving (Data.ToHttpApiData, Data.FromHttpApiData, Show, Eq)  -- | Offset for paginated requests. newtype PaginationOffset = PaginationOffset Int-  deriving (Servant.ToText, Servant.FromText, Show, Eq)+  deriving (Data.ToHttpApiData, Data.FromHttpApiData, Show, Eq)  -- $response --@@ -288,27 +292,19 @@   parseJSON _ = error "Invalid GIF response."  -- | The Giphy API-type GiphyAPI = "v1"-    :> "gifs"-    :> "search"+type GiphyAPI = "search"     :> Servant.QueryParam "api_key" Key     :> Servant.QueryParam "offset" PaginationOffset     :> Servant.QueryParam "q" Query     :> Servant.Get '[Servant.JSON] SearchResponse-  :<|> "v1"-    :> "gifs"-    :> "translate"+  :<|> "translate"     :> Servant.QueryParam "api_key" Key     :> Servant.QueryParam "s" Phrase     :> Servant.Get '[Servant.JSON] TranslateResponse-  :<|> "v1"-    :> "gifs"-    :> Servant.Capture "gif_id" GifId+  :<|> Servant.Capture "gif_id" GifId     :> Servant.QueryParam "api_key" Key     :> Servant.Get '[Servant.JSON] SingleGifResponse-  :<|> "v1"-    :> "gifs"-    :> "random"+  :<|> "random"     :> Servant.QueryParam "api_key" Key     :> Servant.QueryParam "tag" Tag     :> Servant.Get '[Servant.JSON] RandomResponse@@ -316,29 +312,37 @@ api :: Proxy.Proxy GiphyAPI api = Proxy.Proxy +-- From the servant docs:+-- (Yes, the usage of unsafePerformIO is very ugly, we know.+--  Hopefully soon it’ll be possible to do without.)+{-# NOINLINE __manager #-}+__manager :: HTTP.Manager+__manager = Unsafe.unsafePerformIO $ HTTP.newManager tlsManagerSettings+ search'   :: Maybe Key   -> Maybe PaginationOffset   -> Maybe Query-  -> EitherT Servant.ServantError IO SearchResponse+  -> ExceptT Servant.ServantError IO SearchResponse  translate'   :: Maybe Key   -> Maybe Phrase-  -> EitherT Servant.ServantError IO TranslateResponse+  -> ExceptT Servant.ServantError IO TranslateResponse  gif'   :: GifId   -> Maybe Key-  -> EitherT Servant.ServantError IO SingleGifResponse+  -> ExceptT Servant.ServantError IO SingleGifResponse  random'   :: Maybe Key   -> Maybe Tag-  -> EitherT Servant.ServantError IO RandomResponse+  -> ExceptT Servant.ServantError IO RandomResponse -search' :<|> translate' :<|> gif' :<|> random' = Servant.client api host-  where host = Servant.BaseUrl Servant.Https "api.giphy.com" 443+search' :<|> translate' :<|> gif' :<|> random' = Servant.client api host __manager+  where+    host = Servant.BaseUrl Servant.Https "api.giphy.com" 443 "v1/gifs/"  -- $api --@@ -403,12 +407,12 @@   deriving (Show, Eq)  -- | The Giphy monad contains the execution context.-type Giphy = Reader.ReaderT GiphyConfig (EitherT Servant.ServantError IO)+type Giphy = Reader.ReaderT GiphyConfig (ExceptT Servant.ServantError IO)  -- | You need to provide a 'GiphyConfig' to lift a 'Giphy' computation -- into 'MonadIO'. runGiphy :: MonadIO m => Giphy a -> GiphyConfig -> m (Either Servant.ServantError a)-runGiphy = ((liftIO . runEitherT) .) . Reader.runReaderT+runGiphy = ((liftIO . runExceptT) .) . Reader.runReaderT  -- $lenses --
stack.yaml view
@@ -8,7 +8,10 @@ packages: - '.' # Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)-extra-deps: []+extra-deps:+- servant-0.5+- servant-client-0.5+- http-api-data-0.2.2  # Override default flag values for local packages and extra-deps flags: {}