Quantcast
Viewing all articles
Browse latest Browse all 38

Answer by Tarmil for Can't get bind operator to work with discriminated union

When you use an operator, F# looks for it in order:

  • as a let-defined operator;
  • as a static member-defined operator on one of the two arguments' types. Here, the arguments you are passing to the operator are string list and TestDI -> string, so it won't look at the one you defined on TestDI.

So here the solution would be to let-define it instead:

type TestDI =    private    | A of string list    | B of int listlet (>>=) (x: string list) (f: TestDI -> 'a) =    f <| A x

Viewing all articles
Browse latest Browse all 38

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>