module Hasql.Streamly (
streamlyQuery,
) where
import Control.Monad.Trans.Class
import qualified Streamly.Prelude as Streamly
import qualified Streamly.Internal.Data.Stream.Serial as Serial
import Hasql.Statement
import Hasql.CursorTransactionIO
import Hasql.Streams
streamlyQuery ::
(Streamly.IsStream t) =>
Statement params [a] -> params -> t (CursorTransactionIO s) a
streamlyQuery :: Statement params [a] -> params -> t (CursorTransactionIO s) a
streamlyQuery Statement params [a]
stmt params
params = Statement params [a]
-> params
-> CursorStreamFold s a (t (CursorTransactionIO s) a)
-> t (CursorTransactionIO s) a
forall params s a r.
Statement params [a] -> params -> CursorStreamFold s a r -> r
cursorStreamQuery Statement params [a]
stmt params
params CursorStreamFold s a (t (CursorTransactionIO s) a)
forall (t :: (* -> *) -> * -> *) s a.
IsStream t =>
CursorStreamFold s a (t (CursorTransactionIO s) a)
foldStreamlyStream
foldStreamlyStream ::
(Streamly.IsStream t) =>
CursorStreamFold s a (t (CursorTransactionIO s) a)
foldStreamlyStream :: CursorStreamFold s a (t (CursorTransactionIO s) a)
foldStreamlyStream x -> CursorTransactionIO s (Maybe (a, x))
step CursorTransactionIO s x
init = SerialT (CursorTransactionIO s) a -> t (CursorTransactionIO s) a
forall (t1 :: (* -> *) -> * -> *) (t2 :: (* -> *) -> * -> *)
(m :: * -> *) a.
(IsStream t1, IsStream t2) =>
t1 m a -> t2 m a
Streamly.adapt (CursorTransactionIO s x -> SerialT (CursorTransactionIO s) x
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift CursorTransactionIO s x
init SerialT (CursorTransactionIO s) x
-> (x -> SerialT (CursorTransactionIO s) a)
-> SerialT (CursorTransactionIO s) a
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (x -> CursorTransactionIO s (Maybe (a, x)))
-> x -> SerialT (CursorTransactionIO s) a
forall (m :: * -> *) b a.
Monad m =>
(b -> m (Maybe (a, b))) -> b -> SerialT m a
Serial.unfoldrM x -> CursorTransactionIO s (Maybe (a, x))
step)