on master help sign in
[#70] Format Pattern Synonym Signatures

This is a simple addition, adding `pattern ` in front of normal type signature formatting

commitcd8302a6c30aee429461c77355715eb1cbd93f8a authorRupert Horlick <rupert.horlick@iohk.io> dateFri 14 Jun 2019, 15:52 (7 years ago) parent8f44d98
5 files changed+22
data/examples/declaration/signature/pattern/multiline-out.hs+5 data/examples/declaration/signature/pattern/multiline.hs+3 data/examples/declaration/signature/pattern/single-line-out.hs+2 data/examples/declaration/signature/pattern/single-line.hs+3 src/Ormolu/Printer/Meat/Declaration/Signature.hs+9
data/examples/declaration/signature/pattern/multiline-out.hsnew file+5
@@ -0,0 +1,5 @@
1+{-# LANGUAGE PatternSynonyms #-}
2+pattern Arrow
3+ :: Type
4+ -> Type
5+ -> Type
data/examples/declaration/signature/pattern/multiline.hsnew file+3
@@ -0,0 +1,3 @@
1+{-# LANGUAGE PatternSynonyms #-}
2+pattern Arrow :: Type
3+ -> Type -> Type
data/examples/declaration/signature/pattern/single-line-out.hsnew file+2
@@ -0,0 +1,2 @@
1+{-# LANGUAGE PatternSynonyms #-}
2+pattern Arrow :: Type -> Type -> Type
data/examples/declaration/signature/pattern/single-line.hsnew file+3
@@ -0,0 +1,3 @@
1+{-# LANGUAGE PatternSynonyms #-}
2+
3+pattern Arrow :: Type -> Type -> Type
src/Ormolu/Printer/Meat/Declaration/Signature.hs+9
@@ -25,6 +25,7 @@ p_sigDecl = line . p_sigDecl'
2525p_sigDecl' :: Sig GhcPs -> R ()
2626p_sigDecl' = \case
2727 TypeSig NoExt names hswc -> p_typeSig names hswc
28+ PatSynSig NoExt names hsib -> p_patSynSig names hsib
2829 ClassOpSig NoExt def names hsib -> p_classOpSig def names hsib
2930 FixSig NoExt sig -> p_fixSig sig
3031 InlineSig NoExt name inlinePragma -> p_inlineSig name inlinePragma
@@ -56,6 +57,14 @@ p_typeAscription HsWC {..} = do
5657 located (hsib_body hswc_body) p_hsType
5758p_typeAscription (XHsWildCardBndrs NoExt) = notImplemented "XHsWildCardBndrs"
5859
60+p_patSynSig
61+ :: [Located RdrName]
62+ -> HsImplicitBndrs GhcPs (LHsType GhcPs)
63+ -> R ()
64+p_patSynSig names hsib = do
65+ txt "pattern "
66+ p_typeSig names HsWC {hswc_ext = NoExt, hswc_body = hsib}
67+
5968p_classOpSig
6069 :: Bool -- ^ Whether this is a \"default\" signature
6170 -> [Located RdrName] -- ^ Names (before @::@)