I am new to Haskell and facing a \"cannot construct infinite type\" error that I cannot make sense of.
In fact, beyond that, I have not been able to find a good exp
I may be wrong, but it seems you're trying to solve a more difficult problem. Your version of intersperse
doesn't just intersperse the value with the array, but also flattens it one level.
The List
module in Haskell actually provides an intersperse function. It puts in the value given between every element in the list. For example:
intersperse 11 [1, 3, 5, 7, 9] = [1, 11, 3, 11, 5, 11, 7, 11, 9]
intersperse "*" ["foo","bar","baz","quux"] = ["foo", "*", "bar", "*", "baz", "*", "quux"]
I'm assuming this is what you want to do because it's what my professor wanted us to do when I was learning Haskell. I could, of course, be totally out.