title: Access to F# record base properties without using interface
body: <p>F# records cannot be inherited, but they can implement interfaces. For example, I want to create different controllers:</p>
  
  <pre><code>type ControllerType =
      | Basic
      | Advanced1
      | Advanced1RAM
      | Advanced1RAMBattery
      | Advanced2
  
  // base abstract class
  type IController =
      abstract member rom : byte[]
      abstract member ``type`` : ControllerType
  
  type BasicController =
      { rom : byte[]
        ``type`` : ControllerType }
      interface IController with
          member this.rom = this.rom
          member this.``type`` = this.``type``
  
  type AdvancedController1 =
      { ram : byte[]
        rom : byte[]
        ``type`` : ControllerType }
      interface IController with
          member this.rom = this.rom
          member this.``type`` = this.``type``
  
  type AdvancedController2 =
      { romMode : byte
        rom : byte[]
        ``type`` : ControllerType }
      interface IController with
          member this.rom = this.rom
          member this.``type`` = this.``type``
  
  let init ``type`` =
      match ``type`` with
      | Basic -&gt;
          { rom = Array.zeroCreate 0
            ``type`` = Basic } :&gt; IController
      | Advanced1 | Advanced1RAM | Advanced1RAMBattery -&gt;
          { ram = Array.zeroCreate 0
            rom = Array.zeroCreate 0
            ``type`` = ``type`` } :&gt; IController
      | Advanced2 -&gt;
          { romMode = 0xFFuy
            rom = Array.zeroCreate 0
            ``type`` = ``type`` } :&gt; IController
  </code></pre>
  
  <p>I have 2 questions:</p>
  
  <ol>
  <li>When I create a controller record, I need to upcast it to an interface. Is there a better way to write the <code>init</code> function above without <code>:&gt; IController</code> each record?</li>
  <li>I tried discriminated unions but somehow end up writing interfance like this example. But interface is a .NET thing, how can I rewrite the example in a functional way, with composition rather than inheritance?</li>
  </ol>