title: What is the Haskell reverse function expected in this code?
body: <p>I'm writing a small Haskell exercise, it is should shift some elements within a list, similar to a Caesar cipher, the code is already working, the code is below.</p>
  
  <pre><code>module Lib (shift, cipherEncode, cipherDecode ) where
  import Data.Char
  import Data.List
  import Data.Maybe
  
  abcdata :: [Char]
  abcdata = ['a','b','c','d','e','f','g']
  
  iabcdata :: [Char]
  iabcdata = ['g','f','e','d','c','b','a']
  
  shift :: Char -&gt; Int -&gt; Char
  shift l n = if (n &gt;= 0)
              then normalShift l n
              else inverseShift l (abs n)
  
  normalShift :: Char -&gt; Int -&gt; Char
  normalShift l n = shifter l n abcdata
  
  inverseShift :: Char -&gt; Int -&gt; Char
  inverseShift l n = shifter l n reverse(abcdata) -- This is the line
  
  charIdx :: Char -&gt; [Char] -&gt; Int
  charIdx target xs = fromJust $ elemIndex target xs
  
  shifter :: Char -&gt; Int -&gt; [Char] -&gt; Char
  shifter l n xs = if (n &lt; length (xs))
              then
                  picker ((charIdx l xs) + n) xs
              else
                  picker ((charIdx l xs) + (n `mod` length (xs))) xs
  
  picker :: Int -&gt; [Char] -&gt; Char
  picker n xs = if n &lt; length xs
                then
                  xs!!n
                else
                  xs!!(n `mod` length (xs))
  </code></pre>
  
  <p>The question I have is regarding the line</p>
  
  <p><code>inverseShift l n = shifter l n reverse(abcdata)</code></p>
  
  <p>If I change it by </p>
  
  <p><code>inverseShift l n = shifter l n iabcdata</code></p>
  
  <p>it works fine</p>
  
  <p>also, when I do <code>reverse(abcdata) == iabcdata</code> it is <code>True</code>
  but when I leave the <code>reverse</code> in the code I get the following error</p>
  
  <pre><code>    * Couldn't match expected type `[Char] -&gt; Char'
                    with actual type `Char'
      * The function `shifter' is applied to four arguments,
        but its type `Char -&gt; Int -&gt; [Char] -&gt; Char' has only three
        In the expression: shifter l n reverse (abcdata)
        In an equation for `inverseShift':
            inverseShift l n = shifter l n reverse (abcdata)
     |
  21 | inverseShift l n = shifter l n reverse(abcdata)
     |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  
      * Couldn't match expected type `[Char]'
                    with actual type `[a0] -&gt; [a0]'
      * Probable cause: `reverse' is applied to too few arguments
  </code></pre>
  
  <p>What am I doing wrong by calling <code>shifter</code> with <code>reverse(abcdata)</code> ?</p>