Created
May 28, 2024 16:34
-
-
Save yodiz/f1e77d6e1bbc7a19c4e45c9e1f9b2b5b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "nuget:FSharpPlus" | |
open FSharpPlus | |
type Transaction<'T> = |Transaction of (unit -> 'T) | |
with | |
static member Return (x: 'T) : Transaction<'T> = Transaction.Transaction (fun () -> x) | |
static member (>>=) (x: Transaction<'T>, f: 'T -> Transaction<'U>) : Transaction<'U> = | |
match x with Transaction.Transaction fn -> fn () |> f | |
//For delayed | |
static member TryWith (computation: unit -> Transaction<'T>, catchHandler: exn -> Transaction<'T>) : Transaction<'T> = | |
failwithf "" | |
static member TryFinally (source: Transaction<'T>, f: unit -> unit) : Transaction<'T> = | |
failwithf "" | |
//Works | |
let c arg : Transaction<string> = monad.strict { | |
return arg | |
} | |
//Works | |
let d = monad.strict { | |
let! a = c "A" | |
let! b = c "B" | |
return a+b | |
} | |
//unknown(1,1): error FS0073: internal error: Undefined or unsolved type variable: ^_?124161 | |
let e = monad { | |
let! a = c "A" | |
let! b = c "B" | |
return a+b | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment