on master help sign in
Workaround pattern constructs in expressions
commit4ae8025f9012c77d027401f4a61811c946f493ab authorUtku Demir <me@utdemir.com> dateFri 30 Aug 2019, 12:05 (7 years ago) parenta2af1eb
3 files changed+21−3
data/examples/declaration/value/function/pattern/view-pattern-out.hs+3 data/examples/declaration/value/function/pattern/view-pattern.hs+3 src/Ormolu/Printer/Meat/Declaration/Value.hs+15−3
data/examples/declaration/value/function/pattern/view-pattern-out.hs+3
@@ -13,3 +13,6 @@ multiline
1313 bar
1414 baz
1515 ) = True
16+
17+-- https://github.com/tweag/ormolu/issues/343
18+foo = (f -> 4)
data/examples/declaration/value/function/pattern/view-pattern.hs+3
@@ -10,3 +10,6 @@ g ((f, _), f -> 4) = True
1010multiline (t -> Foo
1111 bar
1212 baz) = True
13+
14+-- https://github.com/tweag/ormolu/issues/343
15+foo = (f -> 4)
src/Ormolu/Printer/Meat/Declaration/Value.hs+15−3
@@ -705,10 +705,22 @@ p_hsExpr = \case
705705 HsTick {} -> notImplemented "HsTick"
706706 HsBinTick {} -> notImplemented "HsBinTick"
707707 HsTickPragma {} -> notImplemented "HsTickPragma"
708+ -- These four constructs should never appear in correct programs.
709+ -- See: https://github.com/tweag/ormolu/issues/343
708710 EWildPat NoExt -> txt "_"
709− EAsPat {} -> notImplemented "EAsPat"
710− EViewPat {} -> notImplemented "EViewPat"
711− ELazyPat {} -> notImplemented "ELazyPat"
711+ EAsPat NoExt n p -> do
712+ p_rdrName n
713+ txt "@"
714+ located p p_hsExpr
715+ EViewPat NoExt p e -> do
716+ located p p_hsExpr
717+ space
718+ txt "->"
719+ breakpoint
720+ inci (located e p_hsExpr)
721+ ELazyPat NoExt p -> do
722+ txt "~"
723+ located p p_hsExpr
712724 HsWrap {} -> notImplemented "HsWrap"
713725 XExpr {} -> notImplemented "XExpr"
714726