-- genrep
genrep :: a -> Int -> [a]
genrep a n
| n == 0 = []
|otherwise = a ++ genrep (a (n-1))
So I'm trying to make a simple replication function in haskell - one that would take a generic type a and replicate it n times. However, the above does not seem to work. I keep getting this error code:
*** Expression : a ++ genrep (a (n - 1))
*** Term : genrep (a (n - 1))
*** Type : Int -> [b]
*** Does not match : [a]
Can anyone tell me what's going on? The function looks correct to me, but Haskell doesn't seem to like this.