[GHC] #12188: Pattern variables bound by PatternGuards are not accessible in where clause
GHC
ghc-devs at haskell.org
Tue Jun 14 07:22:43 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 heisenbug):
Replying to [comment:4 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.
Oh, pity. Surely those rules were set in stone when pattern guards weren't
a thing yet. Thanks for the `let` tip, I'll look into it and see how it
helps in my case.
>
> 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:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list