<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Dec 23, 2013 at 8:55 AM, Angus Comber <span dir="ltr"><<a href="mailto:anguscomber@gmail.com" target="_blank">anguscomber@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>    Couldn't match expected type `a' with actual type `[a]'<br></div><div>      `a' is a rigid type variable bound by</div>
<div>          the type signature for testconcat :: [[a]] -> [a]</div>
<div>          at prog_haskell.hs:218:15</div><div>    In the first argument of `(:)', namely `xs'</div><div>    In the second argument of `(:)', namely `xs : []'</div><div>    In the expression: x : xs : []</div>

<div>Failed, modules loaded: none.</div><div><br></div><div>if x : xs works why not x : xs : <something else> ???</div></div></blockquote><div><br></div><div>x is an element.</div><div>xs is a list of those elements.</div>
<div>x : xs prepends a single element to a list.</div><div>x : xs : y would attempt to prepend a single element *and* a list to something else --- but if you deconstructed a list to get x and xs, then x and xs are not the same type (since xs's type is that of a list of x).</div>
</div><div class="gmail_extra"><br></div>Perhaps the thing to understand is that in Haskell, a list is built up of elements all of the same type using (:):</div><div class="gmail_extra"><br></div><div class="gmail_extra">
[x,y,z]   is the same as   x : y : z : []</div><div class="gmail_extra"><br></div><div class="gmail_extra">(If you're familiar with Lisp, (:) is exactly cons and [] is nil.)</div><div class="gmail_extra"><br></div><div class="gmail_extra">
But because Haskell is strictly typed, a list must contain elements all the same type. So you can't have y in that be a list of the same type as x, it must be a value the same type as x.</div><div class="gmail_extra">
<br></div><div class="gmail_extra">Maybe you are looking for (++) instead? But note that that takes lists, not items, so it would have to be ([x] ++ xs ++ ...).<br clear="all"><div><br></div>-- <br><div dir="ltr"><div>brandon s allbery kf8nh                               sine nomine associates</div>
<div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>                                  <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad        <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div>
</div>
</div></div>