title: F#, char seq -> strings
body: <p>A quick question that may be more of a rant (but I hope to be enlightened instead).</p>
  
  <p>In F# a string is compatible with Seq such that "abcd" |> Seq.map f will work on a string.</p>
  
  <p>This is a brilliant facility for working with strings, for example to take the first 5 chars from a string:</p>
  
  <pre><code>"abcdef01234567" |&gt; Seq.take 5
  </code></pre>
  
  <p>Or removing duplicate characters:</p>
  
  <pre><code>"abcdeeeeeee" |&gt; Seq.distinct
  </code></pre>
  
  <p>The problem being that once you have the char seq result, it becomes extremely awkward to convert this back to a string again, String.concat "" requires that the members are strings, so I end up doing this a lot:</p>
  
  <pre><code>"abcdef01234567" 
  |&gt; Seq.take 5
  |&gt; Seq.map string
  |&gt; String.concat ""
  </code></pre>
  
  <p>So much so that I have a function I use in 90% of my projects: </p>
  
  <pre><code>let toString : char seq -&gt; string = Seq.map string &gt;&gt; String.concat ""
  </code></pre>
  
  <p>I feel this is over the top, but everywhere I look to find an alternative I am met with heinous things like StringBuilder or inlining a lambda and using new:</p>
  
  <pre><code>"abcdef01234567" 
  |&gt; Seq.take 5
  |&gt; Seq.toArray 
  |&gt; fun cs -&gt; new string (cs) (* note you cannot just |&gt; string *)
  </code></pre>
  
  <p>My (perhaps crazy) expectation that I would like to see in the language is that when Seq is used on string, the type signature from the resulting expression should be string -> string. Meaning, what goes in is what comes out. "abcd" |> Seq.take 3 = "abc". </p>
  
  <p>Is there a reason my expectations of high level string manipulation is mistaken in this case?</p>
  
  <p>Does anyone have a recommendation for approaching this in a nice manner, I feel like I must be missing something. </p>