<Query Kind="FSharpProgram" />

let unit1 = Async.RunSynchronously

// ---

let unit t = async.Return t  // async { return t }

let w = unit 3
printfn "unit: %A" (unit1 w)

let bind f m = async.Bind (m, f)

let z = bind (fun t -> unit (t+1)) (unit 3)
printfn "bind: %A" (unit1 z)

// ---
printfn ""

let map h m = bind (h >> unit) m  // = async.Bind (m, h >> async.Return)

let flat m2 = bind id m2 // = async.Bind (m2, id)

// ---

let a = async {
    return 7
    }

let h t = t + 1

let b = map h a

printfn "map: %A %A" (unit1 a) (unit1 b)

// ---

let c = async {
    return a
    }

let d = flat c

printfn "flat: %A %A" (unit1 c) (unit1 d)

// ---
printf ""

let c' = async {
    return! a
    }

printfn "!: %A" (unit1 c')

// ---

