logo       

RE: Warnings on record updates: msg#00032

lang.haskell.glasgow.bugs

Subject: RE: Warnings on record updates

You're right. GHC's pattern-match warnings are sometimes bogus --
fixing it is a long-standing wish-list item.

However, here it looks as if the record pattern match is the cause of
the problem, and I don't think I knew about that. So I've added your
example to the current SourceForge bug report, which will mean that
whoever fixes the problem will see your report too.

Thanks for reporting it.

Simon

| -----Original Message-----
| From: glasgow-haskell-bugs-bounces@xxxxxxxxxxx
[mailto:glasgow-haskell-bugs-
| bounces@xxxxxxxxxxx] On Behalf Of Peter White
| Sent: 10 December 2004 19:14
| To: glasgow-haskell-bugs@xxxxxxxxxxx
| Subject: Warnings on record updates
|
| When I compile the following module with the -Wall option on ghc
v6.2.1
| I get warnings:
| Warning: Pattern match(es) are non-exhaustive
| In a record-update construct: Patterns not matched D2.
| The warnings occur at both of the indicated places in the module.
| Since the functions both handle all the cases of the data type D, it
| seems the warning should not be given.
|
|
------------------------------------------------------------------------
| ---------
|
| module Try where
|
| data D = D1 { f1 :: Int } | D2
|
| -- Use pattern matching in the argument
| f :: D -> D
| f d1@(D1 {f1 = n}) = d1 { f1 = f1 d1 + 1 } -- Warning here
| f d = d
|
| -- Use case pattern matching
| g :: D -> D
| g d1 = case d1 of
| D1 { f1 = n } -> d1 { f1 = n + 1 } -- Warning here also
| D2 -> d1
|
| Cheers
|
| Peter White
| 503 466 0687 (Home)
| 503 380 8024 (Cell)
|
| _______________________________________________
| Glasgow-haskell-bugs mailing list
| Glasgow-haskell-bugs@xxxxxxxxxxx
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise