title: How does one resolve F# Type Reference Errors?
body: <p>I've been through my books, and I've googled until I've ran out of search terms, yet I still can't find an example or answer to this problem:</p>
  
  <p>The following code does not compile because the type Effect and the type Affect have not been declared at the time Entity is declared. So what I don't understand is how do to work around this. </p>
  
  <p>In C++, this problem is solved via a prototype declaration in h files and then including the h file. In C# it is never an issue. So how is it resolved in F#?</p>
  
  <pre><code>#light
  type Entity = 
      { 
          Name:string; 
          Affects:List&lt;Affect&gt;; //Compile error: The type Affect is not defined
          Effects:List&lt;Effect&gt;; //Compile error: the type Effect is not defined
      }
  
  type Effect = 
      { 
          Name:string; 
          //A function pointer for a method that takes an Entity and returns an Entity
          ApplyEffect:Entity -&gt; Entity;
      }
  
  type Affect = 
      { 
          Name:string; 
          //A List of Effects that are applied by this Affect Object
          EffectList:List&lt;Effect&gt;; 
          //A function pointer to return an Entity modified by the listed Effects
          ApplyAffect:Entity-&gt;Entity;
      }
  </code></pre>
  
  <p>The underlying goal here is that an object of type Entity should be able to list the Affects it can apply to objects of Type Entity. Entity can also list the Effects that have been applied to it. This way the "current" state of an entity is found by folding all of the Effects against the original entity state.</p>
  
  <p>Thank you for your time,</p>
  
  <p>--Adam Lenda</p>