Fix some record pattern case involving "pun"

pull/1/head
Lennart Spitzner 2016-08-06 14:05:42 +02:00
parent 705286be0a
commit 7f69ab8b43
1 changed files with 12 additions and 6 deletions

View File

@ -54,17 +54,23 @@ layoutPat lpat@(L _ pat) = docWrapNode lpat $ case pat of
ConPatIn lname (RecCon (HsRecFields fs@(_:_) Nothing)) -> do ConPatIn lname (RecCon (HsRecFields fs@(_:_) Nothing)) -> do
let t = lrdrNameToText lname let t = lrdrNameToText lname
fds <- fs `forM` \(L _ (HsRecField (L _ (FieldOcc lnameF _)) fPat _)) -> do fds <- fs `forM` \(L _ (HsRecField (L _ (FieldOcc lnameF _)) fPat _)) -> do
fExpDoc <- docSharedWrapper layoutPat fPat -- special casing for some record special thingy..
fExpDoc <- case fPat of
(L _ (VarPat (L _ (Unqual x)))) | occNameString x == "pun-right-hand-side" -> return Nothing
_ -> Just <$> docSharedWrapper layoutPat fPat
return $ (lrdrNameToText lnameF, fExpDoc) return $ (lrdrNameToText lnameF, fExpDoc)
docSeq docSeq
[ appSep $ docLit t [ appSep $ docLit t
, appSep $ docLit $ Text.pack "{" , appSep $ docLit $ Text.pack "{"
, docSeq $ List.intersperse docCommaSep , docSeq $ List.intersperse docCommaSep
$ fds <&> \(fieldName, fieldDoc) -> docSeq $ fds <&> \case
[ appSep $ docLit $ fieldName (fieldName, Just fieldDoc) -> docSeq
, appSep $ docLit $ Text.pack "=" [ appSep $ docLit $ fieldName
, fieldDoc , appSep $ docLit $ Text.pack "="
] , fieldDoc
]
(fieldName, Nothing) -> docLit fieldName
, docSeparator
, docLit $ Text.pack "}" , docLit $ Text.pack "}"
] ]
TuplePat args boxity _ -> do TuplePat args boxity _ -> do