Weird warnings when using ViewPatterns
Bas van Dijk
v.dijk.bas at gmail.com
Mon Dec 21 06:03:32 EST 2009
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-safe
[2] http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#view-patterns
[3] http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#record-puns
More information about the Glasgow-haskell-users
mailing list