HackerRank - Candies
You might consider using the trick of extending your array by one on both ends, ie. to include indices 0 and n+1, and assign:

ratings[0] = ratings[n+1] = 0
candies[0] = candies[n+1] = 0


and then go 1 and go n will be handled by the other clauses.

Also, you can eliminate the boundary assignments in go with:

candies = listArray (0,n+1) $ [0] ++ [go i | i &lt;- [1..n] ] ++ [0]


Finally you can use these definitions to make the guards more succinct:

go i | incL &amp;&amp; incR  = 1 + max cL cR
     | incL          = 1 + cL
     | incR          = 1 + cR
     | otherwise     = 1
  where incL = (ratings!(i-1)) &lt; (ratings!i)
        incR = (ratings!i) &gt; (ratings(i+1))
        cL   = candies!(i-1)
        cR   = candies!(i+1)