On Jul 15, 2009, at 2:30 PM, Hans Aberg wrote:
If ++ could be pattern matched, what should have been the result of
"let (x++y)=[1,2,3] in (x,y)"?
It will branch. In terms of unification, you get a list of
substitutions.
f :: [a] -> ([a],[a])
f (x ++ y) = (x,y)
For an argument s, any pair (x, y) satisfying s = x ++ y will match.
That is, if s = [s_1, ..., s_k], the solutions j = 0, ..., k, x =
[s_1, ..., s_j], y = [s_(j+1), ..., s_k]. And for each one, a
potentially different value could given. That is, s could produce
multiple values.
Curry (a Haskell extension with non-determinism) supports exactly that.
Sergio Antoy and Michael Hanus: Declarative Programming with Function
Patterns
available at: <http://www.informatik.uni-kiel.de/~mh/papers/
LOPSTR05.pdf>
--
Underestimating the novelty of the future is a time-honored tradition.
(D.G.)
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe