[GHC] #10756: Allow users to indicate inaccessible patterns

GHC ghc-devs at haskell.org
Mon Aug 24 12:52:13 UTC 2015


#10756: Allow users to indicate inaccessible patterns
-------------------------------------+-------------------------------------
        Reporter:  edsko             |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.10.2
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by goldfire):

 The syntactic construct that assigns values to variables looks like

     ''pattern'' = ''expression''

 What you are proposing is that this becomes

     ''top_level_pattern'' = ''expression''

 where ''top_level_pattern'' is just like ''pattern'', but also admits the
 word `impossible`. That is, the thing to the left of an `=` is ''always''
 a pattern in Haskell, even if it's a trivially simple one like a bare
 identifier.

 But I see another way forward here. The problem is that something like
 `foo = bar` can be seen in two different lights: `foo` can be a trivial
 pattern, or `foo` can be a 0-argument function. Seen as the former, we
 have the annoying ''top_level_pattern'' stuff above. Seen as the latter,
 this makes more sense. So your proposal would also allow

 {{{
 impossible x = x + 1
 }}}

 In that declaration, `impossible` clearly is not in a pattern position, so
 it's OK.

 Changing the treatment of `foo = bar` from a pattern binding to a function
 binding would also fix <<recent bug I can't find that complains about `foo
 | guard1 = xxx; foo | guard2 = yyy` not being acceptable>>. I think I'm
 coming around to your point of view here.

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


More information about the ghc-tickets mailing list