我正在尝试用F#写一个Monad但是我无法编译代码而且我收到错误FS0001错误:这个表达式预计会有类型'Result'但是这里有类型'(Result <'a> - > Result << b>) - >结果<'b>'
open System
type Result<'TSuccess> =
| Success of 'TSuccess
| Failure
let bind x f =
match x with
| Success x -> f (Success x)
| Failure -> Failure
let stringToInt (s:string) =
try
let result = s |> int
Success result
with
|_-> Failure
let isPositive (i:int) =
if ( i > 0) then Success i : Result<int>
else Failure
let toString (i:int) =
try
let result = i …
Run Code Online (Sandbox Code Playgroud)