on master help sign in
Implement rendering of ‘SigPat’s
commit4b1d31e4ea596bd8833dff74ea0f06e480ebde8e authorMitchell Rosen <mitchellwrosen@gmail.com> dateMon 10 Jun 2019, 01:08 (7 years ago) parentfab9f15
4 files changed+26−3
data/examples/declaration/value/function/sig-pattern-out.hs+7 data/examples/declaration/value/function/sig-pattern.hs+7 src/Ormolu/Printer/Meat/Declaration/Signature.hs+9−2 src/Ormolu/Printer/Meat/Declaration/Value.hs+3−1
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 @@
77module Ormolu.Printer.Meat.Declaration.Signature
88 ( p_sigDecl
99 , p_sigDecl'
10+ , p_typeAscription
1011 )
1112where
1213
@@ -34,13 +35,19 @@ p_typeSig
3435 :: [Located RdrName] -- ^ Names (before @::@)
3536 -> LHsSigWcType GhcPs -- ^ Type
3637 -> R ()
37−p_typeSig names HsWC {..} = do
38+p_typeSig names hswc = do
3839 spaceSep p_rdrName names
40+ p_typeAscription hswc
41+
42+p_typeAscription
43+ :: LHsSigWcType GhcPs
44+ -> R ()
45+p_typeAscription HsWC {..} = do
3946 breakpoint
4047 inci $ do
4148 txt ":: "
4249 located (hsib_body hswc_body) p_hsType
43−p_typeSig _ (XHsWildCardBndrs NoExt) = notImplemented "XHsWildCardBndrs"
50+p_typeAscription (XHsWildCardBndrs NoExt) = notImplemented "XHsWildCardBndrs"
4451
4552p_classOpSig
4653 :: Bool -- ^ Whether this is a \"default\" signature
src/Ormolu/Printer/Meat/Declaration/Value.hs+3−1
@@ -487,7 +487,9 @@ p_pat = \case
487487 LitPat NoExt p -> atom p
488488 NPat NoExt v _ _ -> located v (atom . ol_val)
489489 NPlusKPat {} -> notImplemented "NPlusKPat"
490− SigPat {} -> notImplemented "SigPat"
490+ SigPat hswc pat -> do
491+ located pat p_pat
492+ p_typeAscription hswc
491493 CoPat {} -> notImplemented "CoPat"
492494 XPat NoExt -> notImplemented "XPat"
493495