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/121/head
parent
18b3cfaf88
commit
019d47bf7e
|
@ -349,11 +349,11 @@ func reallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongvariable
|
|||
func (A a) = a
|
||||
|
||||
#test list constructor
|
||||
func (x:xr) = x
|
||||
func (x : xr) = x
|
||||
|
||||
#test some other constructor symbol
|
||||
#pending
|
||||
func (x:+:xr) = x
|
||||
func (x :+: xr) = x
|
||||
|
||||
#test normal infix constructor
|
||||
func (x `Foo` xr) = x
|
||||
|
|
|
@ -123,7 +123,7 @@ func = do
|
|||
#test list comprehension comment placement
|
||||
func =
|
||||
[ (thing, take 10 alts) --TODO: select best ones
|
||||
| (thing, _got, alts@(_:_)) <- nosuchFooThing
|
||||
| (thing, _got, alts@(_ : _)) <- nosuchFooThing
|
||||
, gast <- award
|
||||
]
|
||||
|
||||
|
|
|
@ -366,11 +366,11 @@ func reallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongvariable
|
|||
func (A a) = a
|
||||
|
||||
#test list constructor
|
||||
func (x:xr) = x
|
||||
func (x : xr) = x
|
||||
|
||||
#test some other constructor symbol
|
||||
#pending
|
||||
func (x:+:xr) = x
|
||||
func (x :+: xr) = x
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
@ -748,7 +748,7 @@ func = do
|
|||
#test list comprehension comment placement
|
||||
func =
|
||||
[ (thing, take 10 alts) --TODO: select best ones
|
||||
| (thing, _got, alts@(_:_)) <- nosuchFooThing
|
||||
| (thing, _got, alts@(_ : _)) <- nosuchFooThing
|
||||
, gast <- award
|
||||
]
|
||||
|
||||
|
|
|
@ -78,12 +78,10 @@ layoutPat lpat@(L _ pat) = docWrapNode lpat $ case pat of
|
|||
return $ x1 Seq.<| xR
|
||||
ConPatIn lname (InfixCon left right) -> do
|
||||
-- a :< b -> expr
|
||||
let nameDoc = lrdrNameToText lname
|
||||
leftDoc <- colsWrapPat =<< layoutPat left
|
||||
let nameDoc = lrdrNameToTextAnn lname
|
||||
leftDoc <- appSep . colsWrapPat =<< layoutPat left
|
||||
rightDoc <- colsWrapPat =<< layoutPat right
|
||||
middle <- docLit $ if Text.any isAlpha nameDoc
|
||||
then Text.pack " `" <> nameDoc <> Text.pack "` "
|
||||
else nameDoc
|
||||
middle <- appSep . docLit =<< nameDoc
|
||||
return $ Seq.empty Seq.|> leftDoc Seq.|> middle Seq.|> rightDoc
|
||||
ConPatIn lname (RecCon (HsRecFields [] Nothing)) -> do
|
||||
-- Abc{} -> expr
|
||||
|
|
Loading…
Reference in New Issue