Skip to content

Feedback on a Hasql Effect #185

Answered by arybczak
shinzui asked this question in Q&A
Sep 14, 2023 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Looks good to me 👍 You might want to include HasCallStack constraint in the signature of runSession to be able to get accurate stack traces in case of errors.

Given the setup above, I'd like to ask if it's advisable to encapsulate the Reader Pool and Error UsageError within an internal effect stack

I'd not include Reader at all and just pass pool as a parameter to runHasqlIO:

runHasqlIO ::
  forall es a.
  ( IOE :> es,
    Error UsageError :> es
  ) =>
  Eff (Hasql : es) a ->
  Eff es a
runHasqlIO pool = interpret $ \_ -> \case
  RunSession session -> do
    r <- liftIO $ use pool session
    either throwError pure r

since I don't think you'll use local from outside to modify the pool?

A…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@shinzui
Comment options

@arybczak
Comment options

Answer selected by shinzui
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants