Weird warnings when using ViewPatterns

Robert Greayer robgreayer at gmail.com
Mon Dec 21 15:03:55 EST 2009


On Mon, Dec 21, 2009 at 6:03 AM, Bas van Dijk <v.dijk.bas at gmail.com> wrote:

> 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<http://code.haskell.org/%7Ebasvandijk/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
>

There's been some improvement at least in 6.12.1, see:

http://hackage.haskell.org/trac/ghc/ticket/2395
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20091221/5a8e83a8/attachment.html


More information about the Glasgow-haskell-users mailing list