Michael Speer wrote:
> test x y = ( "World" , x , x ++ " " ++ y )
> main = let ( a , b , c ) = test "Hello" a
> in do
> print $ ( a , b , c )
This works, but in your code you actually wrote
let ( ( a, b, c ), ( d, e, f ), ( g, h, i ) ) = ( foo, bar, baz )
with the right side involving the stuff on the left. This won't work;
for Haskell to bind values to a, b, and so on, it has to examine the
value being matched to check whether it is really a tuple (and not _|_).
You can defer the check, and that's called a lazy or irrefutable pattern
binding:
let ( ~( a, b, c ), ~( d, e, f ), ~( g, h, i ) ) = ( foo, bar, baz )
This would work. The reason you didn't run into this earlier (and why I
apprently forgot a tilde) is that let-bindings are always lazy, as if
you had put a tilde there, but this doesn't hold for nested patterns.
This means that not tupling your three functions and instead using a
group of bindings would work, too, and look prettier anyway:
let ( a, b, c ) = foo
( d, e, f ) = bar
( g, h, i ) = baz
Yes, let groups allow mutually recursive bindings, the same is true for
where clauses and mdo blocks.
> Is this a known problem that will one day be resolved, or is it
> considered beyond the scope of the language?
Neither, it's supposed to be this way. Btw, you might consider posting
a _minimal_ code example when illustrating your next problem. I didn't
even try to run your big chunk of code, so the above is only guesswork.
-Udo
--
Always call a spade a spade, except in classes that both dig holes and
play bridge.
-- a guideline for Eiffel programmers
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell/attachments/20070613/b5deb7f8/attachment.bin