[GHC] #11306: Do not generate warning in `do` when result is of type `Void`.

GHC ghc-devs at haskell.org
Mon Dec 28 18:47:25 UTC 2015


#11306: Do not generate warning in `do` when result is of type `Void`.
-------------------------------------+-------------------------------------
           Reporter:  diatchki       |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  7.10.3
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 GHC generates warnings when `do` notation statements discard their
 result, without an explicit `_ <- `, unless the discarded result
 is of type `()`.

 Another type which is used to indicate "no result", is `Void` from
 `Data.Void`.  There are no meaningful values of this type, so we should
 also skip the warnings for such situations.

 Here is an example:
 {{{#!hs
 import Data.Void

 f :: IO Void
 f = undefined

 main :: IO ()
 main = do f
           return ()

 }}}

 GHC output:
 {{{
 test.hs:7:11: Warning:
     A do-notation statement discarded a result of type ‘Void’
     Suppress this warning by saying ‘_ <- f’
     or by using the flag -fno-warn-unused-do-bind
 }}}

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


More information about the ghc-tickets mailing list