C # project does not function F # type `[<NoEquality>]`

I have a simple F # type as follows:

(* Num.fsi *)
namespace FsLib

module Num =
  [<NoEquality>]
  type t

  val of_int : int -> t
  val to_int : t -> int

The implementation is trivial, as you can imagine, this is just one case of a discriminatory union with the base int. Now in a C # project in the same solution I have the following code:

// CsTool.cs
using System;
using FsLib;

namespace CsTool {
  class MainClass {
    public static void Main(string[] args) {
      Num.t n1 = Num.of_int(1);
      Num.t n2 = Num.of_int(1);

      Console.WriteLine(n1.Equals(n2));
    }
  }
}

The problem is that this prints Falseinstead of not compiling or throwing errors at runtime. Any idea why this C # calling code is ignoring an attribute [<NoEquality>]?

By the way, I run this in the Xamarin Studio Community on Mac, version 6.1.2, focusing on the .NET Framework version 4.5.1.

+4
source share
1 answer

, # F #. F #, F #, . , F # ( ) null, # null, # F #. , , .., # ( CLR).

, F # F # BCL # F # ( ) " API".

+6

Source: https://habr.com/ru/post/1671736/


All Articles