Change infix patterns to include spaces

This commit changes infix patterns to utilize `lrdrNameToTextAnn`. This
function allows the logic to avoid introspecting on the constructor
name.

Additionally this adds spaces to all infix operator pattern matches.
Previously infix symbols did not include spaces:

```
foo (x:xs) = _
```

Now they include a space

```
foo (x : xs) = _
```
pull/107/head
Evan Rutledge Borden 2018-01-15 19:11:25 -05:00
parent 778381bbb8
commit 3b0b5d3c4f
4 changed files with 10 additions and 12 deletions

View File

@ -78,12 +78,10 @@ layoutPat lpat@(L _ pat) = docWrapNode lpat $ case pat of
return $ x1 Seq.<| xR return $ x1 Seq.<| xR
ConPatIn lname (InfixCon left right) -> do ConPatIn lname (InfixCon left right) -> do
-- a :< b -> expr -- a :< b -> expr
let nameDoc = lrdrNameToText lname let nameDoc = lrdrNameToTextAnn lname
leftDoc <- colsWrapPat =<< layoutPat left leftDoc <- appSep . colsWrapPat =<< layoutPat left
rightDoc <- colsWrapPat =<< layoutPat right rightDoc <- colsWrapPat =<< layoutPat right
middle <- docLit $ if Text.any isAlpha nameDoc middle <- appSep . docLit =<< nameDoc
then Text.pack " `" <> nameDoc <> Text.pack "` "
else nameDoc
return $ Seq.empty Seq.|> leftDoc Seq.|> middle Seq.|> rightDoc return $ Seq.empty Seq.|> leftDoc Seq.|> middle Seq.|> rightDoc
ConPatIn lname (RecCon (HsRecFields [] Nothing)) -> do ConPatIn lname (RecCon (HsRecFields [] Nothing)) -> do
-- Abc{} -> expr -- Abc{} -> expr