#2259: can not make `if` look nice in a `do`
-----------------------+----------------------------------------------------
Reporter: jsnx | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler (Parser)
Version: 6.8.2 | Severity: minor
Keywords: | Testcase:
Architecture: x86 | Os: MacOS X
-----------------------+----------------------------------------------------
The handling of {{{if}}} within a {{{do}}} block is not consistent with
it's handling outside of it.
{{{
import Text.ParserCombinators.Parsec
date AesthErr
= LineTooLong SourcePos Int
-- works fine
shorty0 len = do
s <- manyTill anyChar newLine
case length s > len of
True -> do
pos <- getPosition
return $ Left $ LineTooLong pos len
_ -> return $ Right s
-- epic fail
shorty1 len = do
s <- manyTill anyChar newLine
if length s > len then
do
pos <- getPosition
return $ Left $ LineTooLong pos len
else
return $ Right s
-- epic fail
shorty2 len = do
s <- manyTill anyChar newLine
if length s > len then
fmap (Left . flip LineTooLong len) getPosition
else
return $ Right s
}}}
Whereas this is fine:
{{{
f n =
if n > 7 then
"Great!"
else
"Less!"
}}}
Is this something I can fix?
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2259>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs