[GHC] #15224: Add -fwan-sum-type-partial-field-accessor

GHC ghc-devs at haskell.org
Mon Jun 4 07:21:48 UTC 2018


#15224: Add -fwan-sum-type-partial-field-accessor
-------------------------------------+-------------------------------------
           Reporter:  erikd          |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:  8.6.1
          Component:  Compiler       |           Version:  8.4.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:
-------------------------------------+-------------------------------------
 This a a new warning flag that would be off by default and warns when a
 sum type is defined with field accessors that are partial. For an example
 of something that would trigger the warning:

 {{{#!hs
 data Option a
   = Some { getSome :: a }
   | None
 }}}

 In production quality Haskell code it usually desirable to outright ban
 partial functions like `head`, `fromJust` etc by use of a custom prelude.
 Unfortunately partial functions can still sneak into a code base via field
 accessors in sum types.

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


More information about the ghc-tickets mailing list