Note that there are some explanatory texts on larger screens.

plurals
  1. POF# How to use an interface in a separate module
    text
    copied!<p>So I have been doing research on interfaces on F#. I have found these 2 articles on it. The <a href="http://msdn.microsoft.com/en-us/library/vstudio/dd233207.aspx" rel="nofollow">MSDN</a> and <a href="http://fsharpforfunandprofit.com/posts/interfaces/" rel="nofollow">F# for fun and profit</a> But unfortunately they are only skin deep. </p> <p><strong>UPDATED</strong></p> <p>here is my module with my interfaces</p> <pre><code>//open statements omitted for brevity module DrawingInterfaces = ///gets a string representation of the SVG code representation of the object type IRepresentable_SVG = abstract member getSVGRepresenation : unit -&gt; string //other interfaces omitted for brevity </code></pre> <p>Now within the same namespace and physical folder also I have this:</p> <pre><code> type lineSet (x1off,x2off,y1off,y2off,x1,x2,y1,y2,rot,rotOff,count) = //tons of member vals omitted for brevity member val x1Start = x1 with get, set interface DrawingInterfaces.IRepresentable_SVG with member __.getSVGRepresenation() = let mutable svg = "" let mutable currentx1 = x1Start svg </code></pre> <p>This used to give me 2 errors, before I was using the __. notation for the member. The first error was on the interface line. And a second on the member line. The errors were respectively:</p> <pre><code>The type 'IRepresentable_SVG' is not defined This instance member needs a parameter to represent the object being invoked. </code></pre> <p>I was able to fix the first one by changing the file order. Thanks to John Palmer. The second one is nearly fixed./</p> <p>After using the __ . notation I was able to get rid of the second error. However, now a new error pops up when I try to use type members in my interface implementation.</p> <pre><code> let mutable currentx1 = x1Start </code></pre> <p>x1Start shows as not being defined. I need to be able to use values stored in my other members within my implementation.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload