[Haskell-cafe] Pattern matching with where free variables can be used more than once

wren ng thornton wren at freegeek.org
Thu Jul 23 20:54:29 EDT 2009


Richard O'Keefe wrote:
> On Jul 18, 2009, at 6:35 AM, Christopher Done wrote:
> [non-linear patterns]
> 
> This kind of matching is provided in Prolog and Erlang.
> Neither of them lets the user define equality.
> 
> We find the same issue with
>    n+k     patterns        (e.g., n+1 as a pattern)
>    l++r  patterns        (e.g., "prefix"++tail)
>    (x,x) patterns (hidden ==)
> 
> In each case, the question is "what if the Prelude's version
> of the explicit or implied function is not in scope?"  (For
> n+k patterns, is the relevant function "+" or is it ">=" and "-"?
> For l++r patterns, is it "++", or "null", "head", and "tail"?)
> 
> My preferred answer would be to say "the only functions in
> scope in a pattern are constructors; these aren't functions,
> they're syntax, and they always relate to the Prelude."
> 
> The Haskell' community's preferred answer seems to be
> "avoid the question, ban the lot of them."
> 
> It's fair to say that any such pattern _can_ be rewritten to
> something Haskell can handle; it's also fair to say that the
> result is often less readable, but that a rewrite may reduce
> the pain.


Also, there was a big long thread about non-linear patterns a couple 
months back. The conclusion of which was "yes we could, but it would 
cause civil war". Some like that kind of sugar, some strongly dislike 
it, some wonder where it will all end, and some say just go use Curry 
already :3

-- 
Live well,
~wren


More information about the Haskell-Cafe mailing list