title: How to create an Haskell array from a function
body: <p>For caching purposes, I want to create an array, which maps input values of the function to output values.  I know, that my function will be used only in this specific range, I think about something like this:</p>
  
  <pre><code>MyType = ... deriving (Ix)
  
  myFunction :: MyType -&gt; foo
  
  myCache = createArrayFromFunction (start,end) myFunction
  </code></pre>
  
  <p>Is this possible or do I just think "not functional" and there is another solution. I need arrays, because I need O(1) access to the members and know the length from the beginning.</p>