Skip to content

Commit

Permalink
Added AsyncDb.Bind and minimal vscode config
Browse files Browse the repository at this point in the history
  • Loading branch information
SabineWren committed Oct 24, 2023
1 parent 6c9bc25 commit 736047d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"[fsharp]": {
"editor.insertSpaces": true,
"editor.tabSize": 4
},
"files.trimTrailingWhitespace": false
}
13 changes: 13 additions & 0 deletions SqlFun/DbBuilder.fs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ module ComputationBuilder =
return f x
}

/// <summary>
/// Function transforming value inside a monad, and flattening the result.
/// </summary>
/// <param name="f">Function transforming a value, returning a monad.</param>
/// <param name="v">Value wrapped in a monad.</param>
/// <param name="ctx">The database context.</param>
let bind (f: 't1 -> AsyncDb<'t2>) (x: AsyncDb<'t1>): AsyncDb<'t2> =
fun ctx -> async {
let! v = x ctx
return! (f v) ctx
}


/// <summary>
/// Wraps a database operation in a transaction asynchronously.
/// </summary>
Expand Down

0 comments on commit 736047d

Please sign in to comment.