
On Wed, Feb 25, 2009 at 6:18 PM, Philip Scott
Well, either that or I being an idiot.
Here's a little example. Let us say you had a datatype 'Month'*
data Month = Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec deriving(Show, Eq, Ord, Ix) <SNIP> months = concat (range (Jan, Dec) : months)
Which should work, right**
But the type checker is not pleased at all and complains:
Couldn't match expected type `[Month]' against inferred type `Month' Expected type: [[Month]] Inferred type: [Month] In the expression: concat (range (Jan, Dec) : months) In the definition of `months': months = concat (range (Jan, Dec) : months)
However, if you use the first definition and make a second function:
months = range (Jan, Dec) : months realmonths = concat(months)
It is happy and does what one might expect. I thought perhaps I was just confusing the inference engine so I tried a liberal sprinkling of :: operators to make my intentions clear, but it still wasn't having any of it.
Can you post your version of the problem function which includes type signatures? Can you also write-out a top-level type signature for the entire expression? Antoine