title: How can I parameterise my Haskell functions?
body: <p>I hope my terminology is correct here - if not, feel free to edit anything.</p>
  
  <p>I'm using Haskell as a helper-language whilst writing a paper on combinatorial game theory - i.e., all of my functions just juggle numbers and help me to come to a solution for the game I'm studying.</p>
  
  <p>I wrote all of the functions for a concrete, integral 'board size' (think chequerboard, 5x5 etc). I wanted to expand to study boards of any size, so modified all the relevant functions by including an Integer parameter. <em>e.g.</em>,</p>
  
  <pre><code>type Size = Int
  
  squares :: Size -&gt; [Square]
  squares size = [ (x,y) | x &lt;- [1..size],  
                           y &lt;- [1..size]]
  </code></pre>
  
  <p>This, however, has started to get messy. Functions which normally I would consider size-independent have to be supplied with a Size whenever they access a function which requires a Size.</p>
  
  <p>This very quickly leads to lines like this:</p>
  
  <pre><code>reaching size = (losing size) \\\ (setA size)
  
  takeUDmir _  []       = []
  takeUDmir size (x:xs) = [x] ++ takeUDmir size (xs \\\ mirUD size x)
  
  rotate size s = concatMap (mirUD size) (mirLR size s)
  </code></pre>
  
  <p>(Note that the content of the functions really doesn't matter, I'm just trying to show how out-of-hand it has become.)</p>
  
  <p>I'm pretty confident using Haskell, and with functional programming in general, but I've got no idea how I could go about removing all of these <code>size</code> references, and simply relying on something else which sets the size for each function which requires its use.</p>
  
  <p>I think I'm probably looking for a monad, but I've got no idea.</p>