- (_, ls@(ALRLayout _ col : _), _)
- | newLine && thisCol <= col ->
- do let f ls'@(ALRLayout _ col' : ls'')
- | thisCol < col' = case f ls'' of
- (ts, ls''') ->
- (L thisLoc ITccurly : ts, ls''')
- | thisCol == col' = ([L thisLoc ITsemi], ls')
- | otherwise = ([], ls')
- f ls' = ([], ls')
- case f ls of
- (t' : ts, ls') ->
- do setPendingImplicitTokens ts
- setNextToken t
- return t'
- _ -> panic "Layout rule: [] when considering newline"
- (u, _, _)
- | isALRopen u ->
- do setALRContext (ALRNoLayout (containsCommas u) : context)
- return t
+ -- This next case is to handle a transitional issue:
+ (ITwhere, ALRLayout _ col : ls, _)
+ | newLine && thisCol == col && transitional ->
+ do addWarning Opt_WarnAlternativeLayoutRuleTransitional
+ thisLoc
+ (transitionalAlternativeLayoutWarning
+ "`where' clause at the same depth as implicit layout block")
+ setALRContext ls
+ setNextToken t
+ -- Note that we use lastLoc, as we may need to close
+ -- more layouts, or give a semicolon
+ return (L lastLoc ITccurly)
+ -- This next case is to handle a transitional issue:
+ (ITvbar, ALRLayout _ col : ls, _)
+ | newLine && thisCol == col && transitional ->
+ do addWarning Opt_WarnAlternativeLayoutRuleTransitional
+ thisLoc
+ (transitionalAlternativeLayoutWarning
+ "`|' at the same depth as implicit layout block")
+ setALRContext ls
+ setNextToken t
+ -- Note that we use lastLoc, as we may need to close
+ -- more layouts, or give a semicolon
+ return (L lastLoc ITccurly)
+ (_, ALRLayout _ col : ls, _)
+ | newLine && thisCol == col ->
+ do setNextToken t
+ return (L thisLoc ITsemi)
+ | newLine && thisCol < col ->
+ do setALRContext ls
+ setNextToken t
+ -- Note that we use lastLoc, as we may need to close
+ -- more layouts, or give a semicolon
+ return (L lastLoc ITccurly)
+ -- We need to handle close before open, as 'then' is both
+ -- an open and a close