Skip to content

Instantly share code, notes, and snippets.

@CodeMan99
Last active February 11, 2023 06:24
Show Gist options
  • Save CodeMan99/eff36a843776047c77db25526a48223b to your computer and use it in GitHub Desktop.
Save CodeMan99/eff36a843776047c77db25526a48223b to your computer and use it in GitHub Desktop.
F# bound context
let a b c =
b + c
let d a =
let m = a + 1 // pretend this is opening something stateful, like a db connection
let x y =
m + y
x
// f is a bound function, a has not been executed yet
let f = a 2
// g is a reference to the inner function, d has been executed
let g = d 3
// execute a with static bound context
do f 4 |> ignore
// execute x with stateful bound context
do g 5 |> ignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment