on master help sign in
Add Default declaration printer

Co-authored-by: Rupert Horlick <ruhatch@me.com>

commit1753c7d647fc6374235b20184f9b89df81912f61 authorBasile Henry <bjm.henry@gmail.com> dateSat 15 Jun 2019, 14:42 (7 years ago) parent4955cdc
5 files changed+37−1
data/examples/declaration/default/default-out.hs+7 data/examples/declaration/default/default.hs+6 ormolu.cabal+1 src/Ormolu/Printer/Meat/Declaration.hs+2−1 src/Ormolu/Printer/Meat/Declaration/Default.hs+21
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
6262 , Ormolu.Printer.Meat.Declaration
6363 , Ormolu.Printer.Meat.Declaration.Class
6464 , Ormolu.Printer.Meat.Declaration.Data
65+ , Ormolu.Printer.Meat.Declaration.Default
6566 , Ormolu.Printer.Meat.Declaration.Instance
6667 , Ormolu.Printer.Meat.Declaration.RoleAnnotation
6768 , Ormolu.Printer.Meat.Declaration.Signature
src/Ormolu/Printer/Meat/Declaration.hs+2−1
@@ -13,6 +13,7 @@ import Ormolu.Printer.Combinators
1313import Ormolu.Printer.Meat.Common
1414import Ormolu.Printer.Meat.Declaration.Class
1515import Ormolu.Printer.Meat.Declaration.Data
16+import Ormolu.Printer.Meat.Declaration.Default
1617import Ormolu.Printer.Meat.Declaration.Instance
1718import Ormolu.Printer.Meat.Declaration.RoleAnnotation
1819import Ormolu.Printer.Meat.Declaration.Signature
@@ -29,7 +30,7 @@ p_hsDecl = \case
2930 SigD NoExt x -> p_sigDecl x
3031 InstD NoExt x -> p_instDecl x
3132 DerivD NoExt x -> p_derivDecl x
32− DefD _ _ -> notImplemented "DefD"
33+ DefD NoExt x -> p_defaultDecl x
3334 ForD _ _ -> notImplemented "ForD"
3435 WarningD _ _ -> notImplemented "WarningD"
3536 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"