on master help sign in
Implement TypeApplications and StaticPointers support
06e4f1dUtku Demir
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)
13import GHC
13import GHC
14import Ormolu.Printer.Combinators
14import Ormolu.Printer.Combinators
15import Ormolu.Printer.Meat.Common
15import Ormolu.Printer.Meat.Common
16+import Ormolu.Printer.Meat.Type
16import Ormolu.Printer.Meat.Declaration.Pat
17import Ormolu.Printer.Meat.Declaration.Pat
17import Ormolu.Printer.Meat.Declaration.Signature
18import Ormolu.Printer.Meat.Declaration.Signature
18import Ormolu.Utils
19import Ormolu.Utils
@@ -163,7 +164,12 @@ p_hsExpr = \case
163 located f p_hsExpr
164 located f p_hsExpr
164 breakpoint
165 breakpoint
165 inci (located x p_hsExpr)
166 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
167 HsAppTypeOut {} -> notImplemented "HsAppTypeOut"
173 HsAppTypeOut {} -> notImplemented "HsAppTypeOut"
168 OpApp x op _ y -> do
174 OpApp x op _ y -> do
169 located x p_hsExpr
175 located x p_hsExpr
@@ -223,7 +229,10 @@ p_hsExpr = \case
223 HsTcBracketOut {} -> notImplemented "HsTcBracketOut"
229 HsTcBracketOut {} -> notImplemented "HsTcBracketOut"
224 HsSpliceE {} -> notImplemented "HsSpliceE"
230 HsSpliceE {} -> notImplemented "HsSpliceE"
225 HsProc {} -> notImplemented "HsProc"
231 HsProc {} -> notImplemented "HsProc"
226− HsStatic {} -> notImplemented "HsStatic"
232+ HsStatic _ e -> do
233+ txt "static"
234+ breakpoint
235+ inci $ located e p_hsExpr
227 HsArrApp {} -> notImplemented "HsArrApp"
236 HsArrApp {} -> notImplemented "HsArrApp"
228 HsArrForm {} -> notImplemented "HsArrForm"
237 HsArrForm {} -> notImplemented "HsArrForm"
229 HsTick {} -> notImplemented "HsTick"
238 HsTick {} -> notImplemented "HsTick"