It’s hard to explain, here is what I want:
let internal (=%=) (W : int, thriller : Dev -> unit -> bool) =
let id = get W
if id <> -1 then
workbase.[id] |> thriller
It doesn’t allow my thriller to return any type.
So I can do W =%= fun w -> foo() where foo() is unit
But how can I do W =%= fun w -> foo() where foo() is unit -> T' (some type) ?
thank you
just added final usage (because like it):
let CanRead W dev v = W =%= fun w -> w.GetCanRead dev v
|> fun opt -> if opt.IsSome then opt.Value
else false
after comment:
let CanRead W dev v = match W =%= fun w -> w.GetCanRead dev v with
| Some(t) -> t
| None -> false
An
elsebranch is missing.When you return
unitin if/else expression,if... then...is a shortcut toif... then... else (). So you can always return some type T in a complete if/else expression, for example, an option type as follows: