Reputation: 41
i have simple struct
[<Struct>]
type Phone = private Phone of string
and i need cast to Phone voption
let toVOption (phone: string) : Phone voption = phone |> ValueOption.toObj
end i see error
Type mismatch. Expecting a 'string -> Phone voption' but given a ''a voption -> 'a' The type 'string' does not match the type ''a voption'
how correct cast string to Phone voption?
Upvotes: 0
Views: 64
Reputation: 40613
You need to wrap the string
in a Phone
, and then wrap the Phone
in a ValueOption
:
let toVOption (phone: string) : Phone voption = phone |> Phone |> ValueSome
Upvotes: 1