
On Mon, Dec 21, 2009 at 6:03 AM, Bas van Dijk
Hello,
In my usb-safe[1] library I make extensive use of the ViewPatterns[2] language extension. However I get strange warnings when using them.
See for example the following function:
resetDevice ∷ (pr `ParentOf` cr, MonadIO cr) ⇒ RegionalDeviceHandle pr → cr () resetDevice (internalHandle → DeviceHandle { internalDevHndl , configAlreadySetMVar }) = ...
where:
type RegionalDeviceHandle r = RegionalHandle USB.Device r
internalHandle ∷ RegionalHandle resource r → Handle resource
and: 'Handle' is an associated data type with the following definition:
data Handle USB.Device = DeviceHandle { internalDevHndl ∷ USB.DeviceHandle , configAlreadySetMVar ∷ MVar Bool }
Note that I also use the NamedFieldPuns[3] language extension.
When compiling the module I get lots of warnings like this:
System/USB/Safe.hs:372:0: Warning: Pattern match(es) are overlapped In the definition of `resetDevice': resetDevice ((internalHandle -> (DeviceHandle {internalDevHndl,
configAlreadySetMVar}))) = ...
System/USB/Safe.hs:372:0: Warning: Pattern match(es) are non-exhaustive In the definition of `resetDevice': Patterns not matched:
I don't understand which patterns are overlapped or which patterns are not matched. Is this a GHC bug? Note that I'm using ghc-6.10.4 so it's possible that it's fixed in 6.12.1.
regards,
Bas
[1] usb-safe: http://hackage.haskell.org/package/usb-safe-0.4 or darcs get http://code.haskell.org/~basvandijk/code/usb-safehttp://code.haskell.org/%7Ebasvandijk/code/usb-safe
[2] http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#vi...
[3] http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#re...
There's been some improvement at least in 6.12.1, see: http://hackage.haskell.org/trac/ghc/ticket/2395