on master help sign in
Implement rendering of ‘SigPat’s
4b1d31eMitchell Rosen
data/examples/declaration/value/function/sig-pattern-out.hsnew file+7
@@ -0,0 +1,7 @@
1+f = do
2+ x :: a <- g
3+
4+f = do
5+ (x, y)
6+ :: (a, b) <-
7+ g
data/examples/declaration/value/function/sig-pattern.hsnew file+7
@@ -0,0 +1,7 @@
1+f = do
2+ x :: a <- g
3+
4+f = do
5+ (x, y)
6+ :: (a, b)
7+ <- g
src/Ormolu/Printer/Meat/Declaration/Signature.hs+9−2
@@ -7,6 +7,7 @@
7module Ormolu.Printer.Meat.Declaration.Signature
7module Ormolu.Printer.Meat.Declaration.Signature
8 ( p_sigDecl
8 ( p_sigDecl
9 , p_sigDecl'
9 , p_sigDecl'
10+ , p_typeAscription
10 )
11 )
11where
12where
12
13
@@ -34,13 +35,19 @@ p_typeSig
34 :: [Located RdrName] -- ^ Names (before @::@)
35 :: [Located RdrName] -- ^ Names (before @::@)
35 -> LHsSigWcType GhcPs -- ^ Type
36 -> LHsSigWcType GhcPs -- ^ Type
36 -> R ()
37 -> R ()
37−p_typeSig names HsWC {..} = do
38+p_typeSig names hswc = do
38 spaceSep p_rdrName names
39 spaceSep p_rdrName names
40+ p_typeAscription hswc
41+
42+p_typeAscription
43+ :: LHsSigWcType GhcPs
44+ -> R ()
45+p_typeAscription HsWC {..} = do
39 breakpoint
46 breakpoint
40 inci $ do
47 inci $ do
41 txt ":: "
48 txt ":: "
42 located (hsib_body hswc_body) p_hsType
49 located (hsib_body hswc_body) p_hsType
43−p_typeSig _ (XHsWildCardBndrs NoExt) = notImplemented "XHsWildCardBndrs"
50+p_typeAscription (XHsWildCardBndrs NoExt) = notImplemented "XHsWildCardBndrs"
44
51
45p_classOpSig
52p_classOpSig
46 :: Bool -- ^ Whether this is a \"default\" signature
53 :: Bool -- ^ Whether this is a \"default\" signature
src/Ormolu/Printer/Meat/Declaration/Value.hs+3−1
@@ -487,7 +487,9 @@ p_pat = \case
487 LitPat NoExt p -> atom p
487 LitPat NoExt p -> atom p
488 NPat NoExt v _ _ -> located v (atom . ol_val)
488 NPat NoExt v _ _ -> located v (atom . ol_val)
489 NPlusKPat {} -> notImplemented "NPlusKPat"
489 NPlusKPat {} -> notImplemented "NPlusKPat"
490− SigPat {} -> notImplemented "SigPat"
490+ SigPat hswc pat -> do
491+ located pat p_pat
492+ p_typeAscription hswc
491 CoPat {} -> notImplemented "CoPat"
493 CoPat {} -> notImplemented "CoPat"
492 XPat NoExt -> notImplemented "XPat"
494 XPat NoExt -> notImplemented "XPat"
493
495