on master help sign in
Implement TypeApplications and StaticPointers support
commit06e4f1d5ad93849f65c9a6564c6554ec6c117244 authorUtku Demir <me@utdemir.com> dateTue 28 May 2019, 13:22 (7 years ago) parent5f746ee
5 files changed+59−2
data/examples/declaration/value/function/static-pointers-out.hs+18 data/examples/declaration/value/function/static-pointers.hs+13 data/examples/declaration/value/function/type-applications-out.hs+9 data/examples/declaration/value/function/type-applications.hs+8 src/Ormolu/Printer/Meat/Declaration/Value.hs+11−2
data/examples/declaration/value/function/static-pointers-out.hsnew file+18
@@ -0,0 +1,18 @@
1+{-# LANGUAGE StaticPointers #-}
2+foo :: StaticPtr Int
3+foo = static 5
4+
5+bar :: StaticPtr [Int]
6+bar =
7+ static
8+ [ 1
9+ , 2
10+ , 3
11+ ]
12+
13+baz :: StaticPtr Bool
14+baz =
15+ static
16+ ( fun 1
17+ 2
18+ )
data/examples/declaration/value/function/static-pointers.hsnew file+13
@@ -0,0 +1,13 @@
1+{-# LANGUAGE StaticPointers #-}
2+
3+foo :: StaticPtr Int
4+foo = static 5
5+
6+bar :: StaticPtr [Int]
7+bar = static [ 1
8+ , 2, 3
9+ ]
10+
11+baz :: StaticPtr Bool
12+baz = static (fun 1
13+ 2)
data/examples/declaration/value/function/type-applications-out.hsnew file+9
@@ -0,0 +1,9 @@
1+{-# LANGUAGE TypeApplications #-}
2+foo = f @String a b c
3+
4+bar = f @(Maybe Int) a b
5+
6+baz =
7+ f @Int @String
8+ a
9+ b
data/examples/declaration/value/function/type-applications.hsnew file+8
@@ -0,0 +1,8 @@
1+{-# LANGUAGE TypeApplications #-}
2+
3+foo = f @String a b c
4+
5+bar = f @(Maybe Int) a b
6+
7+baz = f @Int @String
8+ a b
src/Ormolu/Printer/Meat/Declaration/Value.hs+11−2
@@ -13,6 +13,7 @@ import Data.List (sortOn)
1313import GHC
1414import Ormolu.Printer.Combinators
1515import Ormolu.Printer.Meat.Common
16+import Ormolu.Printer.Meat.Type
1617import Ormolu.Printer.Meat.Declaration.Pat
1718import Ormolu.Printer.Meat.Declaration.Signature
1819import Ormolu.Utils
@@ -163,7 +164,12 @@ p_hsExpr = \case
163164 located f p_hsExpr
164165 breakpoint
165166 inci (located x p_hsExpr)
166− HsAppType {} -> notImplemented "HsAppType"
167+ HsAppType a e -> do
168+ located a p_hsExpr
169+ breakpoint
170+ inci $ do
171+ txt "@"
172+ located (hswc_body e) p_hsType
167173 HsAppTypeOut {} -> notImplemented "HsAppTypeOut"
168174 OpApp x op _ y -> do
169175 located x p_hsExpr
@@ -223,7 +229,10 @@ p_hsExpr = \case
223229 HsTcBracketOut {} -> notImplemented "HsTcBracketOut"
224230 HsSpliceE {} -> notImplemented "HsSpliceE"
225231 HsProc {} -> notImplemented "HsProc"
226− HsStatic {} -> notImplemented "HsStatic"
232+ HsStatic _ e -> do
233+ txt "static"
234+ breakpoint
235+ inci $ located e p_hsExpr
227236 HsArrApp {} -> notImplemented "HsArrApp"
228237 HsArrForm {} -> notImplemented "HsArrForm"
229238 HsTick {} -> notImplemented "HsTick"