[GHC] #12188: Pattern variables bound by PatternGuards are not accessible in where clause
GHC
ghc-devs at haskell.org
Mon Jun 13 21:57:17 UTC 2016
#12188: Pattern variables bound by PatternGuards are not accessible in where clause
-------------------------------------+-------------------------------------
Reporter: heisenbug | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.3
Resolution: invalid | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
Richard is right. In Haskell
* The patterns of the function definition scope over guards, where clause,
and body
* The where clause scopes over the guards, and body.
* The guards scope over the body only
Once could define the language differently, but that's the way it is in
Haskell.
You can include let-binding in the guards, if you want:
{{{
foo :: Int -> Bool
foo a | Just b <- return a
, let c = a == b
= c
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12188#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list