Skip to content

Parse error in multiline case expression inside let inside do block

main = do
    let x = case 1 of
        0 -> False
        _ -> True
    print x

The above program produces the following error: $ runghc bug.hs bug.hs:3:11: parse error on input ‘->’

Slightly rewritten versions print True as indended:

main = do
    let x = case 1 of { 0 -> False; _ -> True }
    print x

main = do
    print $ case 1 of
        0 -> False
        _ -> True

I have double-checked that the offending program does not contain mixed tabs and spaces.

The same error occurs on my own system (Linux Mint x64, Haskell Platform 2014.2 with GHC 7.83) and in FPComplete's online IDE.

I first encountered the error in a program copied verbatim from a Haskell book, so i assume that the syntax is allowed.

Trac metadata
Trac field Value
Version 7.8.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information