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"