hasql-effectful 0.1.0.0 → 0.2.0.0
raw patch · 4 files changed
+67/−28 lines, 4 filesdep ~basedep ~bytestringdep ~effectful
Dependency ranges changed: base, bytestring, effectful, hasql, hasql-pool, hasql-transaction, text
Files
- CHANGELOG.md +14/−1
- examples/Main.hs +14/−7
- hasql-effectful.cabal +37/−17
- src/Effectful/Hasql.hs +2/−3
CHANGELOG.md view
@@ -1,5 +1,18 @@ # Revision history for hasql-effectful +## 0.2.0.0 -- 2026-05-02++* **Breaking:** drop support for any GHC older than 9.12. The library+ is now tested only with `GHC == 9.12.*`.+* Modernize toolchain: devShell uses `ghcWithPackages`, with+ `treefmt-nix` and `git-hooks.nix` integration.+* Bump bounds: `base >= 4.21`, `effectful >= 2.5`, `hasql >= 1.10`,+ `hasql-pool >= 1.4`, `hasql-transaction >= 1.2`.+* Move the example to a cabal flag (`-fexamples`) so the library+ builds without pulling in `hasql-transaction` by default.+* Update the example to use the new `Hasql.Pool.Config`-based+ `Hasql.Pool.acquire` introduced in `hasql-pool` 1.0.+ ## 0.1.0.0 -- 2023-12-27 -* Initial release +* Initial release
examples/Main.hs view
@@ -1,19 +1,21 @@ {-# LANGUAGE OverloadedStrings #-} -module Main where+module Main (main) where -import Data.ByteString.Char8 (pack) import Data.Functor.Contravariant ((>$<)) import Data.Int (Int32) import Data.Text (Text)+import Data.Text qualified as Text import Effectful import Effectful.Error.Static import Effectful.Hasql+import Hasql.Connection.Settings qualified as Conn import Hasql.Decoders qualified as D import Hasql.Encoders qualified as E import Hasql.Pool (Pool, UsageError, acquire)+import Hasql.Pool.Config qualified as Cfg import Hasql.Session (Session, statement)-import Hasql.Statement (Statement (..))+import Hasql.Statement (Statement, preparable, unpreparable) import Hasql.Transaction qualified as T import Hasql.Transaction.Sessions import System.Environment (lookupEnv)@@ -39,7 +41,7 @@ insertUser_ :: Statement User Int32 insertUser_ =- Statement sql encoder decoder True+ preparable sql encoder decoder where sql = "INSERT INTO users (first_name, last_name) VALUES ($1, $2) RETURNING id" encoder = userEncoder@@ -47,7 +49,7 @@ findUserById_ :: Statement Int32 (Maybe User) findUserById_ =- Statement sql encoder decoder True+ preparable sql encoder decoder where sql = "SELECT first_name, last_name, id FROM users WHERE id = $1" encoder = E.param $ E.nonNullable E.int4@@ -72,11 +74,16 @@ mkPool = do pgHost <- lookupEnv "PG_CONNECTION_STRING" case pgHost of- Just h -> acquire 3 10 1_800 1_800 (pack h)+ Just h ->+ acquire $+ Cfg.settings+ [ Cfg.staticConnectionSettings (Conn.connectionString (Text.pack h)),+ Cfg.size 3+ ] Nothing -> error "PG_CONNECTION_STRING env is not defined or is invalid" createTableStatement :: Statement () ()-createTableStatement = Statement sql mempty D.noResult False+createTableStatement = unpreparable sql mempty D.noResult where sql = "CREATE TABLE IF NOT EXISTS users (id SERIAL PRIMARY KEY, first_name TEXT, last_name TEXT)"
hasql-effectful.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.4 name: hasql-effectful-version: 0.1.0.0+version: 0.2.0.0 synopsis: Effectful bindings for hasql description: @<https://hackage.haskell.org/package/effectful Effectful>@ bindings for @<https://hackage.haskell.org/package/hasql hasql>@@@ -12,10 +12,27 @@ author: Nadeem Bitar maintainer: nadeem@gmail.com build-type: Simple+tested-with: GHC >=9.12 extra-doc-files: CHANGELOG.md +source-repository head+ type: git+ location: https://github.com/shinzui/hasql-effectful.git++flag examples+ description: Build example executables+ manual: True+ default: False++common warnings+ ghc-options:+ -Wall -Wcompat -Widentities -Wincomplete-uni-patterns+ -Wincomplete-record-updates -Wredundant-constraints+ -fhide-source-paths -Wmissing-export-lists -Wpartial-fields+ -Wmissing-deriving-strategies+ common common- ghc-options: -Wall+ import: warnings default-extensions: DataKinds DerivingStrategies@@ -26,10 +43,10 @@ import: common exposed-modules: Effectful.Hasql build-depends:- , base ^>=4.17 && <5- , effectful >=1.3.0.0 && <3.0.0.0- , hasql ^>=1.6 && <2- , hasql-pool ^>=0.10+ , base >=4.21 && <5+ , effectful >=2.5 && <3+ , hasql >=1.10 && <1.11+ , hasql-pool >=1.4 && <1.5 hs-source-dirs: src default-language: GHC2021@@ -38,19 +55,22 @@ import: common ghc-options: -threaded -rtsopts -with-rtsopts=-N main-is: Main.hs- build-depends:- , base ^>=4.17- , bytestring ^>=0.11.5- , effectful ^>=2.3.0- , hasql ^>=1.6- , hasql-effectful- , hasql-pool ^>=0.10.0- , hasql-transaction ^>=1.0.1- , text ^>=2.0- hs-source-dirs: examples default-language: GHC2021 + if !flag(examples)+ buildable: False++ build-depends:+ , base >=4.21 && <5+ , bytestring >=0.11 && <0.13+ , effectful >=2.5 && <3+ , hasql >=1.10 && <1.11+ , hasql-effectful+ , hasql-pool >=1.4 && <1.5+ , hasql-transaction >=1.2 && <1.3+ , text >=2.0 && <2.2+ test-suite hasql-effectful-test import: common default-language: GHC2021@@ -58,5 +78,5 @@ hs-source-dirs: test main-is: Main.hs build-depends:- , base ^>=4.17+ , base >=4.21 && <5 , hasql-effectful
src/Effectful/Hasql.hs view
@@ -17,7 +17,7 @@ -- | Provides the ability to execute actions against a postgresql database data Hasql :: Effect where- RunSession :: Error UsageError :> es => Session a -> Hasql (Eff es) a+ RunSession :: (Error UsageError :> es) => Session a -> Hasql (Eff es) a type instance DispatchOf Hasql = Dynamic @@ -26,8 +26,7 @@ runHasqlIO :: forall es a.- ( IOE :> es- ) =>+ (IOE :> es) => Pool -> Eff (Hasql : es) a -> Eff es a