Wednesday 15 May 2013

F# active pattern as non-static member -


I'm not sure that non-static public members active patterns are allowed, but you can define them without compiler complains Are there. What is the syntax to match against someone if they are allowed? The compiler is giving me a type of mismatch for Foo in FooBar2.doSomething a 'a - & gt; Options & lt; 'B,' c & gt; given 'a - & gt; 'D -> There is no error in this class; stable work great type FooBar () = static member (| foo | times |) (x, y) options and lt; Unit, unit & gt;

  = Match with X = Y | True - & gt; Foo | False - & gt; Bar member x.do some y = match x, with y | Foo - & gt; () | Bar - & gt; () Type FooBar2 () = Member x (| Foo | times |) y = match with x = y | True - & gt; Foo | False - & gt; With the "foo" member on the bar / compiler error x.do some y = match y | Foo - & gt; () | Bar - & gt; ()  

Active patterns should not be used as members. The fact is that all of these compilations are a compiler bug that we will fix (thanks for the report :)). Use local or module-bound "Walk" to define an active paradigm.


No comments:

Post a Comment