Fix infix constructor pattern matching for normal constructors #107

Closed
eborden wants to merge 6 commits from infix-constructor-pattern-match into dev
5 changed files with 30 additions and 14 deletions

View File

@ -52,7 +52,7 @@ log the size of the input, but _not_ the full requests.)
# Other usage notes
- Supports GHC versions `8.0.*` and `8.2.*`.
- as of November'17, `brittany` is available on stackage nightly.
- included in stackage with lts>=10.0 (or nightlies dating to >=2017-11-15)
- config (file) documentation is lacking.
- some config values can not be configured via commandline yet.
- uses/creates user config file in `~/.config/brittany/config.yaml`;
@ -84,11 +84,11 @@ log the size of the input, but _not_ the full requests.)
- via `stack` using a sufficiently recent stackage snapshot (dated to >= 2017-11-15)
~~~~.sh
stack install brittany # --resolver=nightly-2017-11-15
stack install brittany # --resolver lts-10.0
~~~~
(alternatively, should nightlies be unreliable, or you want to use ghc-8.0 or something, then
cloning the repo and doing `stack install` will use an lts resolver.)
(earlier ltss did not include `brittany` yet, but the repo should contain a
`stack.yaml` that works with ghc-8.0.)
- on ArchLinux via [the britanny AUR package](https://aur.archlinux.org/packages/brittany/)
using `aura`:
@ -96,6 +96,19 @@ log the size of the input, but _not_ the full requests.)
aura -A brittany
~~~~
# Editor Integration
#### Sublime text
[In this gist](https://gist.github.com/lspitzner/097c33177248a65e7657f0c6d0d12075)
I have described a haskell setup that includes a shortcut to run brittany formatting.
#### VSCode
[This extension](https://marketplace.visualstudio.com/items?itemName=MaxGabriel.brittany)
connects commandline `brittany` to VSCode formatting API. Thanks to @MaxGarbriel.
#### Via HIE
[haskell-ide-engine](https://github.com/haskell/haskell-ide-engine)
includes a `brittany` plugin that directly uses the brittany library.
Relevant for any editors that properly support the language-server-protocol.
# Usage
- Default mode of operation: Transform a single module, from `stdin` to `stdout`.

View File

@ -349,11 +349,14 @@ 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
###############################################################################

View File

@ -123,8 +123,8 @@ func = do
#test list comprehension comment placement
func =
[ (thing, take 10 alts) --TODO: select best ones
| (thing, _got, alts@(_:_)) <- nosuchFooThing
, gast <- award
| (thing, _got, alts@(_ : _)) <- nosuchFooThing
, gast <- award
]
#test if-then-else comment placement

View File

@ -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
]

View File

@ -77,10 +77,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 nameDoc
middle <- appSep . docLit =<< nameDoc
return $ Seq.empty Seq.|> leftDoc Seq.|> middle Seq.|> rightDoc
ConPatIn lname (RecCon (HsRecFields [] Nothing)) -> do
-- Abc{} -> expr