title: Defining a High Order function that acesses data records
body: <p>I pretend to create a high order function that uses as one of its parameters a function which belongs to the record of a certain Data Type. </p>
  
  <p>For Example:</p>
  
  <pre><code>type Debt = Float
  type Power = Int
  
  Data State = S String Debt 
  Data City = C String Power Debt
  Data Country = Country
     { states :: [State]
     , cities :: [City] }
  
  upDetail :: (Country -&gt; [a]) 
           -&gt; ([a] -&gt; b -&gt; [a])
           -&gt; b -&gt; Country -&gt; Country
  upDetail f g b country = country { f = new }
           where old = f country
                 new = g old b
  </code></pre>
  
  <p>What the function above is supposed to do is pick an element of the record of the Country (with the function type <code>Country -&gt; [a]</code>) and alter it according to a certain function type <code>[a] -&gt; b -&gt; [a]</code> and a certain <code>b</code></p>
  
  <p>However, when i try to compile this i get an error saying :</p>
  
  <blockquote>
    <p>‘f’ is not a (visible) constructor field name</p>
  </blockquote>
  
  <p>Is there any way i can overcome this problem? I thought of using <strong>Maybe Country</strong> as my result but i don't know how to do this.</p>