title: Problems to make a function that rollsNDice in Haskell
body: <p>I'm experimenting with randomness in Haskell and I wanted to do a function that given an Int n returns a list of states of random numbers between 1 and 6:</p>
  
  <pre><code>-- auxiliar function
  rollDie :: State StdGen Int
  rollDie = do generator &lt;- get
                  let (value, newGenerator) = randomR (1,6) generator
                  put newGenerator
                  return value
  
  rollNDice :: Int -&gt; State StdGen [Int]
  rollNDice n | n == 0    = [] :: State StdGen [Int]
    | otherwise = (:) &lt;$&gt; rollDie &lt;*&gt; rollNDice (n-1)
  </code></pre>
  
  <p>but when I try to run it in ghci I get:</p>
  
  <pre><code>Couldn't match type ‘[a0]’
                       with ‘StateT StdGen Data.Functor.Identity.Identity [Int]’
        Expected type: State StdGen [Int]
          Actual type: [a0]
      • In the expression: [] :: State StdGen [Int]
        In an equation for ‘rollNDice’:
            rollNDice n
              | n == 0 = [] :: State StdGen [Int]
              | otherwise = (:) &lt;$&gt; rollDie &lt;*&gt; rollNDice (n - 1)
  </code></pre>
  
  <p>I don't understand the error. Any ideas?</p>