From 4b1d31e4ea596bd8833dff74ea0f06e480ebde8e Mon Sep 17 00:00:00 2001 From: Mitchell Rosen Date: Mon, 10 Jun 2019 01:08:26 -0400 Subject: [PATCH] =?UTF-8?q?Implement=20rendering=20of=20=E2=80=98SigPat?= =?UTF-8?q?=E2=80=99s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../declaration/value/function/sig-pattern-out.hs | 7 +++++++ .../declaration/value/function/sig-pattern.hs | 7 +++++++ src/Ormolu/Printer/Meat/Declaration/Signature.hs | 11 +++++++++-- src/Ormolu/Printer/Meat/Declaration/Value.hs | 4 +++- 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 data/examples/declaration/value/function/sig-pattern-out.hs create mode 100644 data/examples/declaration/value/function/sig-pattern.hs diff --git a/data/examples/declaration/value/function/sig-pattern-out.hs b/data/examples/declaration/value/function/sig-pattern-out.hs new file mode 100644 index 0000000..2cab9d3 --- /dev/null +++ b/data/examples/declaration/value/function/sig-pattern-out.hs @@ -0,0 +1,7 @@ +f = do + x :: a <- g + +f = do + (x, y) + :: (a, b) <- + g diff --git a/data/examples/declaration/value/function/sig-pattern.hs b/data/examples/declaration/value/function/sig-pattern.hs new file mode 100644 index 0000000..55f87eb --- /dev/null +++ b/data/examples/declaration/value/function/sig-pattern.hs @@ -0,0 +1,7 @@ +f = do + x :: a <- g + +f = do + (x, y) + :: (a, b) + <- g diff --git a/src/Ormolu/Printer/Meat/Declaration/Signature.hs b/src/Ormolu/Printer/Meat/Declaration/Signature.hs index 20acd52..de7e115 100644 --- a/src/Ormolu/Printer/Meat/Declaration/Signature.hs +++ b/src/Ormolu/Printer/Meat/Declaration/Signature.hs @@ -7,6 +7,7 @@ module Ormolu.Printer.Meat.Declaration.Signature ( p_sigDecl , p_sigDecl' + , p_typeAscription ) where @@ -34,13 +35,19 @@ p_typeSig :: [Located RdrName] -- ^ Names (before @::@) -> LHsSigWcType GhcPs -- ^ Type -> R () -p_typeSig names HsWC {..} = do +p_typeSig names hswc = do spaceSep p_rdrName names + p_typeAscription hswc + +p_typeAscription + :: LHsSigWcType GhcPs + -> R () +p_typeAscription HsWC {..} = do breakpoint inci $ do txt ":: " located (hsib_body hswc_body) p_hsType -p_typeSig _ (XHsWildCardBndrs NoExt) = notImplemented "XHsWildCardBndrs" +p_typeAscription (XHsWildCardBndrs NoExt) = notImplemented "XHsWildCardBndrs" p_classOpSig :: Bool -- ^ Whether this is a \"default\" signature diff --git a/src/Ormolu/Printer/Meat/Declaration/Value.hs b/src/Ormolu/Printer/Meat/Declaration/Value.hs index ab9390a..a3a8e29 100644 --- a/src/Ormolu/Printer/Meat/Declaration/Value.hs +++ b/src/Ormolu/Printer/Meat/Declaration/Value.hs @@ -487,7 +487,9 @@ p_pat = \case LitPat NoExt p -> atom p NPat NoExt v _ _ -> located v (atom . ol_val) NPlusKPat {} -> notImplemented "NPlusKPat" - SigPat {} -> notImplemented "SigPat" + SigPat hswc pat -> do + located pat p_pat + p_typeAscription hswc CoPat {} -> notImplemented "CoPat" XPat NoExt -> notImplemented "XPat"