Return signatures in case expressions

Volodimir Rudenko wld at interpravo.kiev.ua
Wed Aug 4 11:49:33 EDT 2004


Hello,

I have read 'Lexically-scoped type variables' by Simon Peyton Jones and
Mark Shields. When discussing result signatures, authors mensioned in
Section 4.1.2. 'Result signatures':

        "Result signatures can be used on lambda abstractions and
        case expressions, as well as function definitions." ,

but they did not give syntax definitions for those additional cases.

The syntax for lambdas is not hard to guess, but not so for cases.
So, I browsed GHC documentation and found one example of using a result
signature in a case expression (Section 7.4. 'Type system extensions',
Subsection 7.4.10.3 'Where a pattern type signature can occur'):

        "Pattern type signatures, including the result part, can be
        used in case expressions:
                case e of { (x::a, y) :: a -> x } ".

On the other hand, Subsection 7.4.10.4. 'Result type signatures' does not
mention 'the case of case expressions' (sorry for pun).

I have tried the above example with GHC 6.2.1 and CVS GHC. Both rejected it:

        Prelude> :set -fglasgow-exts
        Prelude> case e of { (x::a, y) :: a -> x }
        <interactive>:1: parse error on input `}'
        Prelude>

Is this a bug or an abandoned feature?


Thanks for the Glorious GHC!
V.Rudenko


PS. I reported a buglet in CVS GHCi to the cvs-ghc list. The message did not
appear in archives. I am repeating it here:

GHC, built from recent CVS HEAD, complains:

        Prelude> :info :
        Can't find interface-file declaration for GHC.Base.:
          Probable cause: bug in .hi-boot file, or inconsistent .hi file
          Use -ddump-if-trace to get an idea of which file caused the error







More information about the Glasgow-haskell-bugs mailing list