From dad0f81e2d3bc40e5e4ae22901090ce49a7d000e Mon Sep 17 00:00:00 2001 From: Nikita Volkov Date: Sun, 3 Aug 2014 20:57:45 +0400 Subject: [PATCH] Results Stream sketch --- library/HighSQL.hs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/library/HighSQL.hs b/library/HighSQL.hs index de848f1..c22a700 100644 --- a/library/HighSQL.hs +++ b/library/HighSQL.hs @@ -24,7 +24,10 @@ session b s = -- | -- A transaction with a level @l@ and a result @r@. -data T l r +data T l s r + +transaction :: MonadIO m => (forall s. T l s r) -> S m r +transaction = $notImplemented -- ** Privileges @@ -32,17 +35,18 @@ data T l r class SelectPrivilege l -select :: SelectPrivilege l => Select r -> T l r +select :: SelectPrivilege l => Select r -> ResultsStream s (T l s) r select = $notImplemented class UpdatePrivilege l -update :: UpdatePrivilege l => Update -> T l () +update :: UpdatePrivilege l => Update -> T l s () update = $notImplemented + -- class AlterPrivilege p where -- alter :: Alter -> T p () @@ -72,3 +76,16 @@ newtype Select r = newtype Update = Update (Backend.Connection -> IO ()) + +-- * Results Stream +------------------------- + +-- | +-- A stream of results, +-- which fetches only those that you reach. +-- +-- Uses the same trick as 'ST' to become impossible to run outside of +-- its transaction. +-- Hence you can only access it while remaining in transaction, +-- and when the transaction finishes it safely gets automatically released. +data ResultsStream s (m :: * -> *) r