[Haskell-cafe] non-exhaustive pattern match(es)?
Semen Trygubenko / Семен Тригубенко
semen at trygub.com
Wed Jun 11 09:44:56 UTC 2014
Niklas and Chris:
On Wed, Jun 11, 2014 at 11:26:57AM +1200, Chris Wong wrote:
> The problem is in these lines:
>
> > | i < i' = []
> > | i == i' = []
> > | i > i' = []
Thank you for your replies — it all makes sense now!
I arrived at the solution (addition of otherwise) by trial and error;
the pattern in the last definition, namely,
i (c :cs) ((i',t) :os)
looks pretty exhaustive, so when the compiler issued a warning, proposing
the addition of
_ (_ : _) ((_, _) : _)
, I scratched my head a bit before realizing the problem was not with the
pattern, but with the comparisons further down, in the guards. And, of course,
"patterns not matched" included many patterns that _were_ matched (in this case,
everything :)). Wouldn't it be great if it was something like
Patterns not matched: _ (_ : _) ((_, _) : _) | otherwise =
instead?
On Wed, Jun 11, 2014 at 12:17:49AM +0100, Semen Trygubenko / Семен Тригубенко wrote:
> > example.hs:2:1: Warning:
> > Pattern match(es) are non-exhaustive
> > In an equation for `f':
> > Patterns not matched: _ (_ : _) ((_, _) : _)
--
Семен Тригубенко http://trygub.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140611/a44458f7/attachment.sig>
More information about the Haskell-Cafe
mailing list