title: On an accessibility compilation error when a public type implements an internal interface in F#
body: <p>I wrote some code like</p>
  
  <pre><code>type internal IMyInterface =
      abstract member Method1 : unit -&gt; unit
  
  type Class1() = 
  
      member this.Y() =
          (this :&gt; IMyInterface).Method1()
  
      interface IMyInterface with
          member this.Method1() = ()
  </code></pre>
  
  <p>Note that the public type Class1 implements an internal interface IMyInterface, it compiles fine. In the generated MSIL, "Method1" was shown as private. This is similar to explicit interfaces in C#.</p>
  
  <p>However, when I change the code a bit to</p>
  
  <pre><code>type internal Foo() =
      member x.Value = "Foo"
  
  type internal IMyInterface =
      abstract member Method1 : Foo -&gt; unit
  
  type Class1() = 
  
      member this.Y() =
          let v = Foo()
          (this :&gt; IMyInterface).Method1(v)
  
      interface IMyInterface with
          member this.Method1(v : Foo) = ()
  </code></pre>
  
  <p>This type the interface method "Method1" takes an internal type "Foo" as parameter. This time, it does not compile with an error</p>
  
  <pre><code>The type 'Foo' is less accessible than the value, member or type 'override Class1.Method1 : v:Foo -&gt; unit' it is used in
  </code></pre>
  
  <p>I have trouble to decipher this error message and find a fix for it. In C#, I can write the following code that compiles fine</p>
  
  <pre><code>internal class Foo
  {
      string Value { get; set; }
  }
  
  internal interface IMyInterface
  {
      void Method1(Foo v);
  }
  
  public class Class1 : IMyInterface
  {
      public void Y()
      {
          var v = new Foo();
          (this as IMyInterface).Method1(v);
      }
  
      void IMyInterface.Method1(Foo v)
      {
          throw new NotImplementedException();
      }
  }
  </code></pre>
  
  <p>Any idea about the F# compiler error and how to work around it?</p>
  
  <p>BTW: this may not be the right way/pattern to use interface anyway, I'm just curious on the language syntax</p>