haskell-effectful / hpqtypes-effectful Goto Github PK
View Code? Open in Web Editor NEWEffectful bindings for hpqtypes
License: BSD 3-Clause "New" or "Revised" License
Effectful bindings for hpqtypes
License: BSD 3-Clause "New" or "Revised" License
runWithNewConnection action = do
dbState :: PQ.DBState (Eff es) <- get
result <- PQ.withConnection (PQ.unConnectionSource connectionSource) $ \newConn -> do
put $ mkDBState newConn (PQ.dbTransactionSettings dbState)
action
put dbState
pure result
If action
throws and you catch the exception outside of withNewConnection
, you'll be left with closed connection inside the DBState.
This needs bracket
.
๐
See this thread for details on what can be improved.
If you look at runDBT
, you'll see that it uses withTransaction
if tsAutoTransaction
is set. runEffectDB
doesn't do that.
Same thing for withNewConnection
.
You might need to copy/reimplement withTransaction
๐ค
This is confusing since most of the functions from hpqtypes
will throw HPQTypesError, but as a regular exception, which is different to the error handled by the Error
effect (see https://hackage.haskell.org/package/effectful-core-1.1.0.0/docs/Effectful-Error-Static.html for more info).
I see that you've made GetConnectionStats use it, but it should just do what the original getConnectionStats implementation of DBT does.
hpqtypes-effectful/src/Effectful/HPQTypes.hs
Lines 84 to 90 in 36d2a3e
This is similar to #21. You'll only restore the original value of dbRecordLastQuery
if action
doesn't throw.
Hey,
Thanks for writing the adapter ๐ I see it's rewriting methods of the typeclass instead of implementing them via the effect though.
For how it should be done please see haskell-effectful/crypto-rng-effectful#3.
If you provide the MonadDB instance and delegate to the effect, then all functions requiring the constraint will "just work" with the Eff monad. You will also not need qualified imports because there will be no name clashes.
Current CI job is too basic. The most important missing thing is lack of any caching.
I'd prefer to not maintain this by hand. The easiest approach is to use haskell-ci like the vast majority of the libraries we maintain do.
Example configuration can be found e.g. here.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.