当我尝试组合这两个转换器时 fsi 阻塞,没有任何警告或错误消息。
open FSharpPlus
open FSharpPlus.Data
type MyError = | Err of string
let f : WriterT<ResultT<Async<Result<_, MyError>>>> = monad {
do! liftAsync <| Async.Sleep 30
do! tell ["abc"]
let! r0 = lift<| ResultT.hoist (Ok 25)
return r0 + 5
}
let g = monad {
let! r1 = f
do! tell ["def"]
do! liftAsync <| Async.Sleep 50
let! r2 = lift<| ResultT.hoist (Ok 2)
return r1 + r2
}
let runStackT stack = stack |> WriterT.run |> ResultT.run |> Async.RunSynchronously
#time "on"
let finalResult = runStackT g
#time "off"
有什么问题以及如何使此代码工作?