[GHC] #15944: Wrong warning given ViewPatterns and -Wmonomorphism-restriction

GHC ghc-devs at haskell.org
Fri Nov 23 23:25:02 UTC 2018


#15944: Wrong warning given ViewPatterns and -Wmonomorphism-restriction
-------------------------------------+-------------------------------------
           Reporter:  pacak          |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.6.3
          Component:  Compiler       |           Version:  8.6.2
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Poor/confusing
  Unknown/Multiple                   |  error message
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 I understand ghc complaining about `b`, but not about `a`.

 No warnings when view patterns are not used.

 {{{#!hs
 {-# LANGUAGE ViewPatterns #-}
 {-# OPTIONS -Wmonomorphism-restriction #-}

 module Foo where

 {-

 demo.hs:11:9: warning: [-Wmonomorphism-restriction]
     • The Monomorphism Restriction applies to the bindings for ‘a’, ‘b’
         Consider giving them a type signature
     • In the expression: let Foo a (round -> b) = f in a + b
       In an equation for ‘bar’:
           bar f = let Foo a (round -> b) = f in a + b
    |
 11 |     let Foo a (round -> b) = f
    |         ^^^^^^^^^^^^^^^^^^^^^^
 -}

 data Foo = Foo Int Double

 bar :: Foo -> Int
 bar f =
     let Foo a (round -> b) = f
      in a + b
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15944>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list