hedis-effectful (empty) → 1.0.0.0
raw patch · 5 files changed
+128/−0 lines, 5 filesdep +basedep +effectful-coredep +hedis
Dependencies added: base, effectful-core, hedis
Files
- CHANGELOG.md +2/−0
- LICENSE +30/−0
- README.md +10/−0
- hedis-effectful.cabal +53/−0
- src/Effectful/Redis.hs +33/−0
+ CHANGELOG.md view
@@ -0,0 +1,2 @@+# hedis-effectful-1.0.0.0 (2024-06-07)+* Initial release.
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2021-2022, Andrzej Rybczak++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.++ * Neither the name of Andrzej Rybczak nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"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+OWNER OR CONTRIBUTORS 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,10 @@+# hedis-effectful++[](https://github.com/scrive/hedis-effectful/actions?query=branch%3Amaster)+[](https://hackage.haskell.org/package/hedis-effectful)+[](https://packdeps.haskellers.com/feed?needle=andrzej@rybczak.net)+[](https://www.stackage.org/lts/package/hedis-effectful)+[](https://www.stackage.org/nightly/package/hedis-effectful)+++Adaptation of the [hedis](https://hackage.haskell.org/package/hedis) library for the [effectful](https://hackage.haskell.org/package/effectful) ecosystem.
+ hedis-effectful.cabal view
@@ -0,0 +1,53 @@+cabal-version: 3.0+build-type: Simple+name: hedis-effectful+version: 1.0.0.0+license: BSD-3-Clause+license-file: LICENSE+category: Control+maintainer: andrzej@rybczak.net+author: Andrzej Rybczak+synopsis:+ Adaptation of the hedis library for the effectful ecosystem.++description:+ Adaptation of the @<https://hackage.haskell.org/package/hedis hedis>@ library for the @<https://hackage.haskell.org/package/effectful effectful>@ ecosystem.++extra-source-files:+ CHANGELOG.md+ README.md++tested-with: GHC == { 8.10.7, 9.0.2, 9.2.8, 9.4.8, 9.6.5, 9.8.2 }++bug-reports: https://github.com/scrive/hedis-effectful/issues++source-repository head+ type: git+ location: https://github.com/scrive/hedis-effectful.git++common language+ ghc-options: -Wall -Wcompat -Wno-unticked-promoted-constructors+ -Wprepositive-qualified-module++ default-language: Haskell2010+ default-extensions:+ NoStarIsType+ BangPatterns+ ConstraintKinds+ DataKinds+ FlexibleContexts+ ImportQualifiedPost+ GADTs+ LambdaCase+ TypeFamilies+ TypeOperators++library+ import: language+ build-depends:+ , base <5+ , effectful-core >=1.0.0.0 && <3.0.0.0+ , hedis >=0.15++ hs-source-dirs: src+ exposed-modules: Effectful.Redis
+ src/Effectful/Redis.hs view
@@ -0,0 +1,33 @@+{-# LANGUAGE UndecidableInstances #-}+{-# OPTIONS_GHC -Wno-orphans #-}++-- | Access to a Redis database via 'MonadRedis'.+module Effectful.Redis+ ( -- * Effect+ Redis (..)++ -- * Handler+ , runRedis+ )+where++import Database.Redis qualified as R+import Effectful+import Effectful.Dispatch.Dynamic++-- | Provide the ability to use the 'R.MonadRedis' instance of 'Eff'.+data Redis :: Effect where+ LiftRedis :: R.Redis a -> Redis m a++type instance DispatchOf Redis = Dynamic++-- | Run the 'Redis' effect.+runRedis :: IOE :> es => R.Connection -> Eff (Redis : es) a -> Eff es a+runRedis conn = interpret $ \_ -> \case+ LiftRedis action -> liftIO $ R.runRedis conn action++----------------------------------------+-- Orphan instance++instance Redis :> es => R.MonadRedis (Eff es) where+ liftRedis = send . LiftRedis