Hi all,

I'm writing an API for a little database library which has -- until now
-- used io-streams, and I was wondering how one would design the query API.

In particular, I have a function similar to:

   query' :: Text -> [SqlValue] -> (Maybe Int -> InputStream [SqlValue]
-> IO a) -> IO a
   query' sql params callback = do
     ...

(I'm actually really using MonadIO, etc., but that shouldn't matter much
for the question -- I'll have to use SafeT from pipes-safe to ensure
proper transaction/connection handling, but I don't think that'll change
things too much.)

The idea is that the user-provided callback receives a "row count"
(Maybe Int) and an InputStream where it can read as much as it wants
(until EOS, obviously). Once the callback terminates, the transaction
commits and the returned value is returned from query'

My question is: How would this API look in the pipes world? The obvious
candidate would be something like

   query' :: Text -> [SqlValue] -> Producer' [SqlValue] m r

but that precludes the "row count". Another option might be

   query' :: Text -> [SqlValue] -> (Maybe Int -> Consumer' [SqlValue] m
r) -> X

... but I'm unsure whether that even makes sense and what I'd want X to
be. Any opinions?

-- 
You received this message because you are subscribed to the Google Groups 
"Haskell Pipes" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to haskell-pipes+unsubscr...@googlegroups.com.
To post to this group, send email to haskell-pipes@googlegroups.com.

Reply via email to