wreq-effectful (empty) → 0.1.0.0
raw patch · 5 files changed
+404/−0 lines, 5 filesdep +basedep +bytestringdep +effectful-core
Dependencies added: base, bytestring, effectful-core, http-client, wreq, wreq-effectful
Files
- CHANGELOG.md +5/−0
- LICENSE +20/−0
- src/Effectful/Wreq.hs +241/−0
- test/Main.hs +4/−0
- wreq-effectful.cabal +134/−0
+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Revision history for wreq-effectful++## 0.1.0.0 -- YYYY-mm-dd++* First version. Released on an unsuspecting world.
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2024 Nor Führ++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ src/Effectful/Wreq.hs view
@@ -0,0 +1,241 @@+module Effectful.Wreq (+ -- * Effect+ Wreq+ -- ** Handlers+ , runWreq++ -- * GET+ , get+ , getWith++ -- * POST+ , post+ , postWith++ -- * HEAD+ , head_+ , headWith++ -- * PUT+ , put+ , putWith++ -- * PATCH+ , patch+ , patchWith++ -- * OPTIONS+ , options+ , optionsWith++ -- * DELETE+ , delete+ , deleteWith++ -- * Custom Method+ , customMethod+ , customMethodWith+ , customHistoriedMethod+ , customHistoriedMethodWith++ -- * Custom Payload Method+ , customPayloadMethod+ , customPayloadMethodWith+ , customHistoriedPayloadMethod+ , customHistoriedPayloadMethodWith++ -- * Reexports+ , W.Options+ , W.defaults+ , WL.manager+ , WL.header+ , WL.param+ , WL.redirects+ , WL.headers+ , WL.params+ , WL.cookie+ , WL.cookies+ , WL.checkResponse++ -- ** Authentication+ , W.Auth+ , W.AWSAuthVersion(..)+ , WL.auth+ , W.basicAuth+ , W.oauth1Auth+ , W.oauth2Bearer+ , W.oauth2Token+ , W.awsAuth+ , W.awsFullAuth+ , W.awsSessionTokenAuth+ -- ** Proxy settings+ , W.Proxy(Proxy)+ , WL.proxy+ , W.httpProxy+ -- ** Using a manager with defaults+ , W.withManager++ -- ** Payloads for POST and PUT+ , W.Payload(..)+ -- *** URL-encoded form data+ , W.FormParam(..)+ , W.FormValue+ -- *** Multipart form data+ , HF.Part+ , WL.partName+ , WL.partFileName+ , WL.partContentType+ , WL.partGetBody+ -- **** Smart constructors+ , HF.partBS+ , HF.partLBS+ , W.partText+ , W.partString+ , HF.partFile+ , HF.partFileSource++ -- ** Responses+ , W.Response+ , WL.responseBody+ , WL.responseHeader+ , WL.responseLink+ , WL.responseCookie+ , WL.responseHeaders+ , WL.responseCookieJar+ , WL.responseStatus+ , WL.Status+ , WL.statusCode+ , WL.statusMessage+ , W.HistoriedResponse+ , WL.hrFinalRequest+ , WL.hrFinalResponse+ , WL.hrRedirects+ -- *** Link headers+ , WL.Link+ , WL.linkURL+ , WL.linkParams+ -- *** Decoding responses+ , W.JSONError(..)+ , W.asJSON+ , W.asValue++ -- ** Cookies+ , WL.Cookie+ , WL.cookieName+ , WL.cookieValue+ , WL.cookieExpiryTime+ , WL.cookieDomain+ , WL.cookiePath++ -- ** Parsing responses+ , WL.atto+ , WL.atto_+ ) where++import Effectful+import Effectful.Dispatch.Static+import Data.ByteString qualified as S+import Data.ByteString.Lazy qualified as L+import Network.HTTP.Client.MultipartFormData qualified as HF+import Network.Wreq qualified as W+import Network.Wreq.Lens qualified as WL+import Network.Wreq.Types as WT++data Wreq :: Effect where++type instance DispatchOf Wreq = Static WithSideEffects+data instance StaticRep Wreq = Wreq++-- | Run the 'Wreq' effect.+runWreq :: (HasCallStack, IOE :> es) => Eff (Wreq : es) a -> Eff es a+runWreq = evalStaticRep Wreq++-- | Lifted `W.get`+get :: Wreq :> es => String -> Eff es (W.Response L.ByteString)+get = unsafeEff_ . W.get++-- | Lifted `W.getWith`+getWith :: Wreq :> es => W.Options -> String -> Eff es (W.Response L.ByteString)+getWith opts = unsafeEff_ . W.getWith opts++-- | Lifted `W.post`+post :: Wreq :> es => WT.Postable a => String -> a -> Eff es (W.Response L.ByteString)+post url = unsafeEff_ . W.post url++-- | Lifted `W.postWith`+postWith :: Wreq :> es => WT.Postable a => W.Options -> String -> a -> Eff es (W.Response L.ByteString)+postWith opts url = unsafeEff_ . W.postWith opts url++-- | Lifted `W.head_`+head_ :: Wreq :> es => String -> Eff es (W.Response ())+head_ = unsafeEff_ . W.head_++-- | Lifted `W.headWith`+headWith :: Wreq :> es => W.Options -> String -> Eff es (W.Response ())+headWith opts = unsafeEff_ . W.headWith opts++-- | Lifted `W.put`+put :: Wreq :> es => Putable a => String -> a -> Eff es (W.Response L.ByteString)+put url = unsafeEff_ . W.put url++-- | Lifted `W.putWith`+putWith :: Wreq :> es => Putable a => W.Options -> String -> a -> Eff es (W.Response L.ByteString)+putWith opts url = unsafeEff_ . W.putWith opts url++-- | Lifted `W.patch`+patch :: Wreq :> es => Patchable a => String -> a -> Eff es (W.Response L.ByteString)+patch url = unsafeEff_ . W.patch url++-- | Lifted `W.patchWith`+patchWith :: Wreq :> es => Patchable a => W.Options -> String -> a -> Eff es (W.Response L.ByteString)+patchWith opts url = unsafeEff_ . W.patchWith opts url++-- | Lifted `W.options`+options :: Wreq :> es => String -> Eff es (W.Response ())+options = unsafeEff_ . W.options++-- | Lifted `W.optionsWith`+optionsWith :: Wreq :> es => W.Options -> String -> Eff es (W.Response ())+optionsWith opts = unsafeEff_ . W.optionsWith opts++-- | Lifted `W.delete`+delete :: Wreq :> es => String -> Eff es (W.Response L.ByteString)+delete = unsafeEff_ . W.delete++-- | Lifted `W.deleteWith`+deleteWith :: Wreq :> es => W.Options -> String -> Eff es (W.Response L.ByteString)+deleteWith opts = unsafeEff_ . W.deleteWith opts++-- | Lifted `W.customMethod`+customMethod :: Wreq :> es => String -> String -> Eff es (W.Response L.ByteString)+customMethod method = unsafeEff_ . W.customMethod method++-- | Lifted `W.customMethodWith`+customMethodWith :: Wreq :> es => String -> W.Options -> String -> Eff es (W.Response L.ByteString)+customMethodWith method opts = unsafeEff_ . W.customMethodWith method opts++-- | Lifted `W.customHistoriedMethod`+customHistoriedMethod :: Wreq :> es => String -> String -> Eff es (W.HistoriedResponse L.ByteString)+customHistoriedMethod method = unsafeEff_ . W.customHistoriedMethod method++-- | Lifted `W.customHistoriedMethodWith`+customHistoriedMethodWith :: Wreq :> es => String -> W.Options -> String -> Eff es (W.HistoriedResponse L.ByteString)+customHistoriedMethodWith method opts = unsafeEff_ . W.customHistoriedMethodWith method opts++-- | Lifted `W.customPayloadMethod`+customPayloadMethod :: Wreq :> es => WT.Postable a => String -> String -> a -> Eff es (W.Response L.ByteString)+customPayloadMethod method url = unsafeEff_ . W.customPayloadMethod method url++-- | Lifted `W.customPayloadMethodWith`+customPayloadMethodWith :: Wreq :> es => WT.Postable a => String -> W.Options -> String -> a -> Eff es (W.Response L.ByteString)+customPayloadMethodWith method opts url = unsafeEff_ . W.customPayloadMethodWith method opts url++-- | Lifted `W.customHistoriedPayloadMethod`+customHistoriedPayloadMethod :: Wreq :> es => WT.Postable a => String -> String -> a -> Eff es (W.HistoriedResponse L.ByteString)+customHistoriedPayloadMethod method url = unsafeEff_ . W.customHistoriedPayloadMethod method url++-- | Lifted `W.customHistoriedPayloadMethodWith`+customHistoriedPayloadMethodWith :: Wreq :> es => WT.Postable a => String -> W.Options -> String -> a -> Eff es (W.HistoriedResponse L.ByteString)+customHistoriedPayloadMethodWith method opts url = unsafeEff_ . W.customHistoriedPayloadMethodWith method opts url++-- TODO: FoldGet and FoldGetWith
+ test/Main.hs view
@@ -0,0 +1,4 @@+module Main (main) where++main :: IO ()+main = putStrLn "Test suite not yet implemented."
+ wreq-effectful.cabal view
@@ -0,0 +1,134 @@+cabal-version: 3.4+-- The cabal-version field refers to the version of the .cabal specification,+-- and can be different from the cabal-install (the tool) version and the+-- Cabal (the library) version you are using. As such, the Cabal (the library)+-- version used must be equal or greater than the version stated in this field.+-- Starting from the specification version 2.2, the cabal-version field must be+-- the first thing in the cabal file.++-- Initial package description 'wreq-effectful' generated by+-- 'cabal init'. For further documentation, see:+-- http://haskell.org/cabal/users-guide/+--+-- The name of the package.+name: wreq-effectful++-- The package version.+-- See the Haskell package versioning policy (PVP) for standards+-- guiding when and how versions should be incremented.+-- https://pvp.haskell.org+-- PVP summary: +-+------- breaking API changes+-- | | +----- non-breaking API additions+-- | | | +--- code changes with no API change+version: 0.1.0.0++-- A short (one-line) description of the package.+synopsis: Adaptation of the wreq library for the effectful ecosystem.++-- A longer description of the package.+-- description:++-- The license under which the package is released.+license: MIT++-- The file containing the license text.+license-file: LICENSE++-- The package author(s).+author: Nor Führ++-- An email address to which users can send suggestions, bug reports, and patches.+maintainer: nor@acorneroftheweb.com++-- A copyright notice.+-- copyright:+build-type: Simple++-- Extra doc files to be distributed with the package, such as a CHANGELOG or a README.+extra-doc-files: CHANGELOG.md++-- Extra source files to be distributed with the package, such as examples, or a tutorial module.+-- extra-source-files:++common main+ ghc-options: -Wall+ -Wcompat+ -Wno-unticked-promoted-constructors+ -Wmissing-deriving-strategies+ -Werror=prepositive-qualified-module++ default-extensions: BangPatterns+ ConstraintKinds+ DataKinds+ DeriveFunctor+ DeriveGeneric+ DerivingStrategies+ FlexibleContexts+ FlexibleInstances+ GADTs+ GeneralizedNewtypeDeriving+ ImportQualifiedPost+ LambdaCase+ MultiParamTypeClasses+ NoStarIsType+ PolyKinds+ RankNTypes+ RecordWildCards+ RoleAnnotations+ ScopedTypeVariables+ StandaloneDeriving+ TupleSections+ TypeApplications+ TypeFamilies+ TypeOperators++library+ import: main++ -- Modules exported by the library.+ exposed-modules: Effectful.Wreq++ -- Modules included in this library but not exported.+ -- other-modules:++ -- LANGUAGE extensions used by modules in this package.+ -- other-extensions:++ -- Other library packages from which modules are imported.+ build-depends: base ^>=4.18.2.1+ , bytestring >= 0.11.5 && < 0.13+ , effectful-core >= 2.3.1 && < 3.0+ , http-client >= 0.7.17 && < 0.9+ , wreq >= 0.5.4 && < 0.7++ -- Directories containing source files.+ hs-source-dirs: src++ -- Base language which the package is written in.+ default-language: GHC2021++test-suite wreq-effectful-test+ import: main++ -- Base language which the package is written in.+ default-language: GHC2021++ -- Modules included in this executable, other than Main.+ -- other-modules:++ -- LANGUAGE extensions used by modules in this package.+ -- other-extensions:++ -- The interface type and version of the test suite.+ type: exitcode-stdio-1.0++ -- Directories containing source files.+ hs-source-dirs: test++ -- The entrypoint to the test suite.+ main-is: Main.hs++ -- Test dependencies.+ build-depends:+ base ^>=4.18.2.1,+ wreq-effectful