on master help sign in
Add Default declaration printer
1753c7dBasile Henry
data/examples/declaration/default/default-out.hsnew file+7
@@ -0,0 +1,7 @@
1+default (Int, Foo, Bar)
2+
3+default
4+ ( Int
5+ , Foo
6+ , Bar
7+ )
data/examples/declaration/default/default.hsnew file+6
@@ -0,0 +1,6 @@
1+default ( Int , Foo , Bar )
2+
3+default ( Int
4+ , Foo,
5+ Bar
6+ )
ormolu.cabal+1
@@ -62,6 +62,7 @@ library
62 , Ormolu.Printer.Meat.Declaration
62 , Ormolu.Printer.Meat.Declaration
63 , Ormolu.Printer.Meat.Declaration.Class
63 , Ormolu.Printer.Meat.Declaration.Class
64 , Ormolu.Printer.Meat.Declaration.Data
64 , Ormolu.Printer.Meat.Declaration.Data
65+ , Ormolu.Printer.Meat.Declaration.Default
65 , Ormolu.Printer.Meat.Declaration.Instance
66 , Ormolu.Printer.Meat.Declaration.Instance
66 , Ormolu.Printer.Meat.Declaration.RoleAnnotation
67 , Ormolu.Printer.Meat.Declaration.RoleAnnotation
67 , Ormolu.Printer.Meat.Declaration.Signature
68 , Ormolu.Printer.Meat.Declaration.Signature
src/Ormolu/Printer/Meat/Declaration.hs+2−1
@@ -13,6 +13,7 @@ import Ormolu.Printer.Combinators
13import Ormolu.Printer.Meat.Common
13import Ormolu.Printer.Meat.Common
14import Ormolu.Printer.Meat.Declaration.Class
14import Ormolu.Printer.Meat.Declaration.Class
15import Ormolu.Printer.Meat.Declaration.Data
15import Ormolu.Printer.Meat.Declaration.Data
16+import Ormolu.Printer.Meat.Declaration.Default
16import Ormolu.Printer.Meat.Declaration.Instance
17import Ormolu.Printer.Meat.Declaration.Instance
17import Ormolu.Printer.Meat.Declaration.RoleAnnotation
18import Ormolu.Printer.Meat.Declaration.RoleAnnotation
18import Ormolu.Printer.Meat.Declaration.Signature
19import Ormolu.Printer.Meat.Declaration.Signature
@@ -29,7 +30,7 @@ p_hsDecl = \case
29 SigD NoExt x -> p_sigDecl x
30 SigD NoExt x -> p_sigDecl x
30 InstD NoExt x -> p_instDecl x
31 InstD NoExt x -> p_instDecl x
31 DerivD NoExt x -> p_derivDecl x
32 DerivD NoExt x -> p_derivDecl x
32− DefD _ _ -> notImplemented "DefD"
33+ DefD NoExt x -> p_defaultDecl x
33 ForD _ _ -> notImplemented "ForD"
34 ForD _ _ -> notImplemented "ForD"
34 WarningD _ _ -> notImplemented "WarningD"
35 WarningD _ _ -> notImplemented "WarningD"
35 AnnD _ _ -> notImplemented "AnnD"
36 AnnD _ _ -> notImplemented "AnnD"
src/Ormolu/Printer/Meat/Declaration/Default.hsnew file+21
@@ -0,0 +1,21 @@
1+{-# LANGUAGE LambdaCase #-}
2+{-# LANGUAGE OverloadedStrings #-}
3+
4+module Ormolu.Printer.Meat.Declaration.Default
5+ ( p_defaultDecl
6+ )
7+where
8+
9+import GHC
10+import Ormolu.Printer.Combinators
11+import Ormolu.Printer.Meat.Type
12+import Ormolu.Utils
13+
14+p_defaultDecl :: DefaultDecl GhcPs -> R ()
15+p_defaultDecl = \case
16+ DefaultDecl NoExt ts -> line $ do
17+ txt "default"
18+ breakpoint
19+ inci . parens . velt $
20+ withSep comma (located' p_hsType) ts
21+ XDefaultDecl {} -> notImplemented "XDefaultDecl"