title: fscheck generating string with size between min & max
body: <p>I try to write a FsCheck generator that generates strings with length in a given interval.</p>
  
  <p>My attempt is the following:</p>
  
  <pre><code>let genString minLength maxLength = 
      let isValidLength (s : string) = 
          s.Length &gt;= minLength &amp;&amp; s.Length &lt;= maxLength
  
      Arb.generate
      |&gt; Gen.suchThat isValidLength
      |&gt; Arb.fromGen
  </code></pre>
  
  <p>...and I get the error: </p>
  
  <pre><code>"System.Exception : No instances of class FsCheck.Arbitrary`1[a] for type System.String with arguments set []"
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>thanks!</p>
  
  <p>UPDATE 1:</p>
  
  <p>I managed to write the generator like this:</p>
  
  <pre><code>let genStrings minLength maxLength = 
      gen {
          let! length = Gen.choose (minLength, maxLength)
          let! chars = Gen.arrayOfLength length Arb.generate&lt;char&gt;
          return new String(chars)
      }
  </code></pre>
  
  <p>Is there a better way?</p>
  
  <p>UPDATE 2: I wanted to add this as a separate question but it's pretty much the same issue as my original one. </p>
  
  <p>So I refactored the above code to the following structure in order to reuse the sequence generator:</p>
  
  <pre><code>let seqOfLength lengthInterval generator =
      gen {
          let! length = Gen.choose lengthInterval
          let! items = Gen.arrayOfLength length generator
          return items |&gt; Seq.ofArray
      }
  
  let sizedString lengthInterval =
      seqOfLength lengthInterval Arb.generate&lt;char&gt;
      |&gt; Gen.map Strings.ofCharSeq
  </code></pre>
  
  <p>Now I'm getting the runtime error: </p>
  
  <pre><code>System.Exception : No instances of class FsCheck.Arbitrary`1[a] for type System.Char with arguments set []
  </code></pre>
  
  <p>...which brings me back to my original issue: Why do can't it find any instance of Arbitrary for System.Char? I thought the arbitrary for the basic types are registered by default. What am I doing wrong?</p>
  
  <p>Thanks!</p>