title: How do you declare the values of a dictionary entry as mutable?
body: <p>The Google yields plenty of example of adding and deleting entries in an F# dictionary (or other collection). But I don't see examples to the equivalent of</p>
  
  <pre><code>myDict["Key"] = MyValue;
  </code></pre>
  
  <p>I've tried</p>
  
  <pre><code>myDict.["Key"] &lt;- MyValue
  </code></pre>
  
  <p>I have also attempted to declare the Dictionary as</p>
  
  <pre><code>Dictionary&lt;string, mutable string&gt;
  </code></pre>
  
  <p>as well several variants on this. However, I haven't hit on the correct combination yet... if it <em>is</em> actually possible in F#.</p>
  
  <p>Edit: The offending code is:</p>
  
  <pre><code>type Config(?fileName : string) =
      let fileName = defaultArg fileName @"C:\path\myConfigs.ini"
  
      static let settings =
          dict[ "Setting1", "1";
                "Setting2", "2";
                "Debug",    "0";
                "State",    "Disarray";]
  
      let settingRegex = new Regex(@"\s*(?&lt;key&gt;([^;#=]*[^;#= ]))\s*=\s*(?&lt;value&gt;([^;#]*[^;# ]))")
  
      do  File.ReadAllLines(fileName)
          |&gt; Seq.map(fun line -&gt; settingRegex.Match(line))
          |&gt; Seq.filter(fun mtch -&gt; mtch.Success)
          |&gt; Seq.iter(fun mtch -&gt; settings.[mtch.Groups.Item("key").Value] &lt;- mtch.Groups.Item("value").Value)
  </code></pre>
  
  <p>The error I'm getting is:</p>
  
  <pre><code>System.NotSupportedException: This value may not be mutated
     at Microsoft.FSharp.Core.ExtraTopLevelOperators.dict@37-2.set_Item(K key, V value)
     at &lt;StartupCode$FSI_0036&gt;.$FSI_0036_Config.$ctor@25-6.Invoke(Match mtch)
     at Microsoft.FSharp.Collections.SeqModule.iter[T](FastFunc`2 action, IEnumerable`1 sequence)
     at FSI_0036.Utilities.Config..ctor(Option`1 fileName)
     at &lt;StartupCode$FSI_0041&gt;.$FSI_0041.main@()
  stopped due to error
  </code></pre>