相关疑难解决方法(0)

StackOverflow在continuation monad中

使用以下continuation monad:

type ContinuationMonad() =
    member this.Bind (m, f) = fun c -> m (fun a -> f a c)
    member this.Return x = fun k -> k x

let cont = ContinuationMonad()
Run Code Online (Sandbox Code Playgroud)

我不明白为什么以下给我一个堆栈溢出:

let map f xs =
    let rec map xs =
        cont {
            match xs with
            | [] -> return []
            | x :: xs ->
                let! xs = map xs
                return f x :: xs
        }
    map xs id;;

let q = [1..100000] |> map ((+) …
Run Code Online (Sandbox Code Playgroud)

monads f# computation-expression

10
推荐指数
1
解决办法
827
查看次数

标签 统计

computation-expression ×1

f# ×1

monads ×1