Discussion:
[GHC] #13087: AlternativeLayoutRule breaks LambdaCase
GHC
2017-01-08 09:06:11 UTC
Permalink
#13087: AlternativeLayoutRule breaks LambdaCase
-------------------------------------+-------------------------------------
Reporter: ohhellojoe | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
(Parser) |
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
{{{#!hs
{-# LANGUAGE AlternativeLayoutRule #-}
{-# LANGUAGE LambdaCase #-}

isOne :: Int -> Bool
isOne = \case 1 -> True
_ -> False

main = return ()
}}}

{{{
$ ghc test-case
[1 of 1] Compiling Main ( test-case.hs, test-case.o )

test-case.hs:5:15: error: parse error on input ‘1’
}}}

It compiles fine without the AlternativeLayoutRule extension.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13087>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
GHC
2017-01-08 10:41:20 UTC
Permalink
#13087: AlternativeLayoutRule breaks LambdaCase
-------------------------------------+-------------------------------------
Reporter: ohhellojoe | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
(Parser) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------

Comment (by osa1):

I'm wondering how you found that flag. I did some digging, it seems like
that
feature was added with https://github.com/ghc/ghc/commit/16c7844d and
later
used in https://github.com/ghc/ghc/commit/4edbeb14e to as a part of GHCi's
`:m`
(which is probably the same thing with `:set +m`). It was never
documented, and
currently it's not even listed in GHC's man page or user manual.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13087#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
GHC
2017-01-09 11:58:51 UTC
Permalink
#13087: AlternativeLayoutRule breaks LambdaCase
-------------------------------------+-------------------------------------
Reporter: ohhellojoe | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
(Parser) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------

Comment (by ohhellojoe):

I found the flag via --supported-extensions. I was looking for a layout-
related extension that would allow me to forgo indentation of a do block
that is the last statement of another do block. It did the trick. Maybe
there was a better, more commonly used extension that would have served.

{{{#!hs
foobar :: IO (Maybe ())
foobar = do putStrLn "doing stuff in IO monad"
return $ do
Just () -- not indented.
}}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13087#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
GHC
2017-01-09 12:28:31 UTC
Permalink
#13087: AlternativeLayoutRule breaks LambdaCase
-------------------------------------+-------------------------------------
Reporter: ohhellojoe | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
(Parser) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------

Comment (by osa1):

You're looking for `-XNondecreasingIndentation`:

{{{
t13087 cat test.hs
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NondecreasingIndentation #-}

isOne :: Int -> Bool
isOne = \case 1 -> True
_ -> False

foobar :: IO (Maybe ())
foobar = do putStrLn ""
return $ do
Just ()

main = return ()
t13087 ghc test.hs
[1 of 1] Compiling Main ( test.hs, test.o )
Linking test ...
}}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13087#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
GHC
2018-10-17 19:55:51 UTC
Permalink
#13087: AlternativeLayoutRule breaks LambdaCase
-------------------------------------+-------------------------------------
Reporter: ohhellojoe | Owner: (none)
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
(Parser) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D5236
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by harpocrates):

* status: new => patch
* differential: => Phab:D5236
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13087#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
GHC
2018-10-24 12:19:40 UTC
Permalink
#13087: AlternativeLayoutRule breaks LambdaCase
-------------------------------------+-------------------------------------
Reporter: ohhellojoe | Owner: (none)
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
(Parser) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D5236
Wiki Page: |
-------------------------------------+-------------------------------------

Comment (by Ryan Scott <ryan.gl.scott@
>):

In [changeset:"eaf159340cfa948c16fa212ff1bf5aec6134a694/ghc" eaf1593/ghc]:
{{{
#!CommitTicketReference repository="ghc"
revision="eaf159340cfa948c16fa212ff1bf5aec6134a694"
Trigger multiline mode in GHCi on '\case' (#13087)

Summary:
In ALR, 'ITlcase' should expect an opening curly. This is probably a
forgotten
edge case in ALR, since `maybe_layout` (which handles the non-ALR layout)
already deals with the 'ITlcase' token properly.

Test Plan: make TEST=T10453 && make TEST=T13087

Reviewers: bgamari, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: RyanGlScott, rwbarton, carter

GHC Trac Issues: #10453, #13087

Differential Revision: https://phabricator.haskell.org/D5236
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13087#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
GHC
2018-10-24 12:25:59 UTC
Permalink
#13087: AlternativeLayoutRule breaks LambdaCase
-------------------------------------+-------------------------------------
Reporter: ohhellojoe | Owner: (none)
Type: bug | Status: closed
Priority: normal | Milestone: 8.8.1
Component: Compiler | Version: 8.0.1
(Parser) |
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
| parser/should_compile/T13087
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D5236
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):

* status: patch => closed
* testcase: => parser/should_compile/T13087
* resolution: => fixed
* milestone: => 8.8.1
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13087#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
GHC
2018-10-24 12:47:35 UTC
Permalink
#13087: AlternativeLayoutRule breaks LambdaCase
-------------------------------------+-------------------------------------
Reporter: ohhellojoe | Owner: (none)
Type: bug | Status: closed
Priority: normal | Milestone: 8.8.1
Component: Compiler | Version: 8.0.1
(Parser) |
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
| parser/should_compile/T13087
Blocked By: | Blocking:
Related Tickets: #10453 | Differential Rev(s): Phab:D5236
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):

* related: => #10453
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13087#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
Loading...