Weird warnings when using ViewPatterns

Bas van Dijk v.dijk.bas at
Mon Dec 21 06:03:32 EST 2009


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
                                           }) = ...


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:

    Warning: Pattern match(es) are overlapped
             In the definition of `resetDevice':
                 resetDevice ((internalHandle -> (DeviceHandle {internalDevHndl,


    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.



[1] usb-safe:
or darcs get



More information about the Glasgow-haskell-users mailing list