Code Monkey home page Code Monkey logo

hpqtypes-effectful's Introduction

hpqtypes-effectful

Build Status Hackage Dependencies Stackage LTS Stackage Nightly

Adaptation of the hpqtypes library for the effectful ecosystem.

Examples can be found in the examples directory.

hpqtypes-effectful's People

Contributors

3kyro avatar arybczak avatar kawu avatar kubek2k avatar matsumonkie avatar skykanin avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

hpqtypes-effectful's Issues

runWithNewConnection is not exception safe

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.

WithFrozenLastQuery is not exception safe

WithFrozenLastQuery (action :: Eff localEs b) -> do
st :: PQ.DBState (Eff es) <- get
put st {PQ.dbRecordLastQuery = False}
result <- localSeqUnlift env $ \unlift -> unlift action
modify $ \(st' :: PQ.DBState (Eff es)) ->
st' {PQ.dbRecordLastQuery = PQ.dbRecordLastQuery st}
pure result

This is similar to #21. You'll only restore the original value of dbRecordLastQuery if action doesn't throw.

Add an instance of MonadDB for Eff

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.

Transaction settings are not used

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 ๐Ÿค”

Improve CI

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.