module Helpers.Transactions whereimport Hasql.Transactionimport Helpers.Statements qualified as Statementsimport PreludecreateSchema :: Transaction ()createSchema = statement () Statements.createAccountTabledropSchema :: Transaction ()dropSchema = statement () Statements.dropAccountTabletransfer :: Int64 -> Int64 -> Scientific -> Transaction Booltransfer id1 id2 amount = do success <- statement (id1, amount) Statements.modifyBalance if success then statement (id2, negate amount) Statements.modifyBalance else return FalsetransferTimes :: Int -> Int64 -> Int64 -> Scientific -> Transaction ()transferTimes times id1 id2 amount = replicateM_ times (transfer id1 id2 amount)