on master help sign in
Implement implicit parameter bindings
commit625f23959cfb3a9e0a20b0bd5ea1cb285101e0b6 authorUtku Demir <me@utdemir.com> dateWed 14 Aug 2019, 19:08 (7 years ago) parent16f2c64
5 files changed+23−2
data/examples/declaration/value/function/let-multi-line-out.hs+5 data/examples/declaration/value/function/let-multi-line.hs+5 data/examples/declaration/value/function/let-single-line-out.hs+2 data/examples/declaration/value/function/let-single-line.hs+1−1 src/Ormolu/Printer/Meat/Declaration/Value.hs+10−1
data/examples/declaration/value/function/let-multi-line-out.hs+5
@@ -16,3 +16,8 @@ inlineComment =
1616 let {- join -} go = case () of
1717 () -> undefined
1818 in go
19+
20+implicitParams :: HasCallStack => Int
21+implicitParams =
22+ let ?cs = ?callstack
23+ in foo cs
data/examples/declaration/value/function/let-multi-line.hs+5
@@ -16,3 +16,8 @@ inlineComment =
1616 let {- join -} go = case () of
1717 () -> undefined
1818 in go
19+
20+implicitParams :: HasCallStack => Int
21+implicitParams =
22+ let ?cs = ?callstack
23+ in foo cs
data/examples/declaration/value/function/let-single-line-out.hs+2
@@ -7,3 +7,5 @@ foo x = let g :: Int -> Int; g = id in ()
77let a = b; c = do { foo; bar }; d = baz in b
88
99let a = case True of { True -> foo; False -> bar }; b = foo a in b
10+
11+foo x = let ?g = id; ?f = g in x
data/examples/declaration/value/function/let-single-line.hs+1−1
@@ -5,4 +5,4 @@ foo x = let x = z where { z = 2; }; a = 3 in x
55foo x = let {g :: Int -> Int; g = id} in ()
66let a = b; c = do { foo; bar }; d = baz in b
77let a = case True of { True -> foo; False -> bar }; b = foo a in b
8−
8+foo x = let {?g = id; ?f = g} in x
src/Ormolu/Printer/Meat/Declaration/Value.hs+10−1
@@ -414,7 +414,16 @@ p_hsLocalBinds = \case
414414 p_item (Right x) = located x p_sigDecl
415415 sitcc $ sepSemi (useBraces . p_item) (sortOn ssStart items)
416416 HsValBinds NoExt _ -> notImplemented "HsValBinds"
417− HsIPBinds NoExt _ -> notImplemented "HsIPBinds"
417+ HsIPBinds NoExt (IPBinds NoExt xs) ->
418+ -- Second argument of IPBind is always Left before type-checking.
419+ let p_ipBind (IPBind NoExt (Left name) expr) = do
420+ atom name
421+ txt " ="
422+ breakpoint
423+ dontUseBraces $ inci $ located expr p_hsExpr
424+ p_ipBind _ = notImplemented "XHsIPBinds"
425+ in sepSemi (located' p_ipBind) xs
426+ HsIPBinds NoExt _ -> notImplemented "HsIpBinds"
418427 EmptyLocalBinds NoExt -> return ()
419428 XHsLocalBindsLR _ -> notImplemented "XHsLocalBindsLR"
420429