on master help sign in
Add CompleteMatchSig printer
commit2c6a9829ab14b403d06a2bdcd239153a0ee87ad1 authorBasile Henry <bjm.henry@gmail.com> dateSat 15 Jun 2019, 15:38 (7 years ago) parent1753c7d
3 files changed+38
data/examples/declaration/signature/complete/complete-out.hs+10 data/examples/declaration/signature/complete/complete.hs+13 src/Ormolu/Printer/Meat/Declaration/Signature.hs+15
data/examples/declaration/signature/complete/complete-out.hsnew file+10
@@ -0,0 +1,10 @@
1+{-# COMPLETE A, B, C :: Foo #-}
2+
3+{-# COMPLETE A, B #-}
4+
5+{-# COMPLETE
6+ A
7+ , B
8+ , C
9+ :: Foo
10+ #-}
data/examples/declaration/signature/complete/complete.hsnew file+13
@@ -0,0 +1,13 @@
1+{-# ComPlETe A , B, C:: Foo
2+
3+ #-}
4+
5+{-# COMPLETE A , B
6+ #-}
7+
8+{-# ComPlETE
9+ A ,
10+ B, C
11+
12+
13+ :: Foo#-}
src/Ormolu/Printer/Meat/Declaration/Signature.hs+15
@@ -32,6 +32,7 @@ p_sigDecl' = \case
3232 InlineSig NoExt name inlinePragma -> p_inlineSig name inlinePragma
3333 SpecSig NoExt name ts inlinePragma -> p_specSig name ts inlinePragma
3434 MinimalSig NoExt _ booleanFormula -> p_minimalSig booleanFormula
35+ CompleteMatchSig NoExt _sourceText cs ty -> p_completeSig cs ty
3536 _ -> notImplemented "certain types of signature declarations"
3637
3738p_typeSig
@@ -157,3 +158,17 @@ p_booleanFormula = \case
157158 (located' p_booleanFormula)
158159 xs
159160 Parens l -> located l (parens . p_booleanFormula)
161+
162+p_completeSig
163+ :: Located [Located RdrName] -- ^ Constructors\/patterns
164+ -> Maybe (Located RdrName) -- ^ Type
165+ -> R ()
166+p_completeSig cs' mty =
167+ located cs' $ \cs ->
168+ pragma "COMPLETE" $ do
169+ velt (withSep comma p_rdrName cs)
170+ forM_ mty $ \ty -> do
171+ breakpoint
172+ inci $ do
173+ txt ":: "
174+ p_rdrName ty