Well, as I said previously, in reply to Wolfgang, forget the (==) and/or Eq
instance; just use the constructors. You don't need an Eq instance for them.
You have the expression:
foo (a,b)
and the definition:
foo (X,X) = ..
Let's say the predicate for checking that the value of `a' matches X
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
Wouldn't it be great if pattern variables could be used more than once
in a pattern? Like so:
foo [x,x,_,x] = The values are the same!
foo _ = They're not the same!
where this could be rewritten to:
foo [x,y,_,z] | x == y x == z = The values are the same!
foo _ =
Christopher,
Wouldn't it be great if pattern variables could be used more than once
in a pattern? Like so:
foo [x,x,_,x] = The values are the same!
foo _ = They're not the same!
These are called nonlinear patterns. I think Miranda (a precursor of
Haskell, sort of) used to have
Am Freitag, 17. Juli 2009 20:38 schrieb Stefan Holdermans:
Christopher,
Wouldn't it be great if pattern variables could be used more than once
in a pattern? Like so:
foo [x,x,_,x] = The values are the same!
foo _ = They're not the same!
These are called nonlinear
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