Functions in Haskell (specifically swap function) : <p>Alright I know that this question has been asked before, but no answers have compiled. I've researched Haskell function tutorials to no avail. Basically I just want to know how to declare a function in Haskell and how to call it. Most of the tutorials I've found are answering how to do this with ghci, which I understand should be basically the same thing, but I need to write this in a .hs file and compile with ghc for a school assignment. Basically I'd like something like this:</p>

<pre><code>main = do

let list = [1,2,3,4]
-- declare swap
swap (list !! 0) (list !!2)
-- Or
swap 1 2 list
</code></pre>

<p>I'm using ghc version 7.4.1 which I understand isn't the latest version, but it's not a terribly old version either, so it shouldn't make a difference here, should it? Any and all help would be greatly appreciated. Thank you.</p>
