I am playing with concatenating lists so I start with this:testconcat :: [[a]] -> [a]testconcat [[]] = []testconcat [(x:xs)] = x : xsNow, testconcat [[]] and testconcat [[1,2]] worksSo now I want to try with a 2nd inner list so I do this:testconcat :: [[a]] -> [a]testconcat [[]] = []testconcat [(x:xs)] = x : xstestconcat [(x:xs), (y:ys)] = x : xs : y : ysand I get load error:Couldn't match expected type `a' with actual type `[a]'`a' is a rigid type variable bound bythe type signature for testconcat :: [[a]] -> [a]at prog_haskell.hs:218:15In the first argument of `(:)', namely `xs'In the second argument of `(:)', namely `xs : y : ys'In the expression: x : xs : y : ysBut this loads ok:testconcat :: [[a]] -> [a]testconcat [[]] = []testconcat [(x:xs)] = x : xstestconcat [(x:xs), (y:ys)] = x : xsEven this line cannot be loaded:testconcat [(x:xs), (y:ys)] = x : xs : []Couldn't match expected type `a' with actual type `[a]'`a' is a rigid type variable bound bythe type signature for testconcat :: [[a]] -> [a]at prog_haskell.hs:218:15In the first argument of `(:)', namely `xs'In the second argument of `(:)', namely `xs : []'In the expression: x : xs : []Failed, modules loaded: none.if x : xs works why not x : xs : <something else> ???Can someone please explain?
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners