@@ -49,10 +49,20 @@ p_hsType' multilineArgs = \case
4949 _ -> return ()
5050 NotPromoted -> return ()
5151 p_rdrName n
52− HsAppTy NoExtField f x -> sitcc $ do
53− located f p_hsType
54− breakpoint
55− inci (located x p_hsType)
52+ HsAppTy NoExtField f x -> do
53+ let -- In order to format type applications with multiple parameters
54+ -- nicer, traverse the AST to gather the function and all the
55+ -- parameters together.
56+ gatherArgs f' knownArgs =
57+ case f' of
58+ L _ (HsAppTy _ l r) -> gatherArgs l (r : knownArgs)
59+ _ -> (f', knownArgs)
60+ (func, args) = gatherArgs f [x]
61+ switchLayout (getLoc f : fmap getLoc args) $ sitcc $ do
62+ located func p_hsType
63+ breakpoint
64+ inci $
65+ sep breakpoint (located' p_hsType) args
5666 HsAppKindTy _ ty kd -> sitcc $ do
5767 -- The first argument is the location of the "@..." part. Not 100% sure,
5868 -- but I think we can ignore it as long as we use 'located' on both the