Q:

Create custom list data structure with "toList" function

I want to create my own list data structure called Nodes. Then I will use my ListConverter class, which contains the 'toList' function, and create an instance of it.
data Nodes a = Empty
             | Node a (Nodes a)

class ListConverter a where
    toList :: a -> [Integer]

instance (Integral a) => ListConverter (Nodes a) where
    toList Empty = []
    toList (Node x Empty) = [x]
    toList (Node x y) = x : toList y

GHCi tells me, that the expected type is 'Integer' but is currently 'a'. Im very confused, because in the instance I give a type for a (Integral). Here's the error message:
error:
    * Couldn't match expected type `Integer' with actual type `a'
      `a' is a rigid type variable bound by
        the instance declaration
        at main.hs:7:10-48
    * In the expression: x
      In the expression: [x]
      In an equation for `toList': toList (Node x Empty) = [x]
    * Relevant bindings include
        x :: a (bound at main.hs:9:18)
        toList :: Nodes a -> [Integer] (bound at main.hs:8:5)
  |
9 |     toList (Node x Empty) = [x]
  |                              ^

A:

Your instance of ListConverter is expected to accept any value of class Integral for "a", but Integer is a specific type, not a class; you'd have to do this:
instance ListConverter (Nodes Integer) where

That or, conversely, make your ListConverter class capable of producing a list of whatever type your Nodes value contains:
class ListConverter f where
    toList :: f a -> [a]

instance ListConverter Nodes where
    toList Empty = []
    toList (Node x y) = x : toList y

(The second equation for toList - (Node x Empty) - is unnecessary)

