Fix infix constructor pattern matching for normal constructors #107
21
README.md
21
README.md
|
@ -52,7 +52,7 @@ log the size of the input, but _not_ the full requests.)
|
||||||
# Other usage notes
|
# Other usage notes
|
||||||
|
|
||||||
- Supports GHC versions `8.0.*` and `8.2.*`.
|
- 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.
|
- config (file) documentation is lacking.
|
||||||
- some config values can not be configured via commandline yet.
|
- some config values can not be configured via commandline yet.
|
||||||
- uses/creates user config file in `~/.config/brittany/config.yaml`;
|
- 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)
|
- via `stack` using a sufficiently recent stackage snapshot (dated to >= 2017-11-15)
|
||||||
|
|
||||||
~~~~.sh
|
~~~~.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
|
(earlier ltss did not include `brittany` yet, but the repo should contain a
|
||||||
cloning the repo and doing `stack install` will use an lts resolver.)
|
`stack.yaml` that works with ghc-8.0.)
|
||||||
|
|
||||||
- on ArchLinux via [the britanny AUR package](https://aur.archlinux.org/packages/brittany/)
|
- on ArchLinux via [the britanny AUR package](https://aur.archlinux.org/packages/brittany/)
|
||||||
using `aura`:
|
using `aura`:
|
||||||
|
@ -96,6 +96,19 @@ log the size of the input, but _not_ the full requests.)
|
||||||
aura -A brittany
|
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
|
# Usage
|
||||||
|
|
||||||
- Default mode of operation: Transform a single module, from `stdin` to `stdout`.
|
- Default mode of operation: Transform a single module, from `stdin` to `stdout`.
|
||||||
|
|
|
@ -349,11 +349,14 @@ func reallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongvariable
|
||||||
func (A a) = a
|
func (A a) = a
|
||||||
|
|
||||||
#test list constructor
|
#test list constructor
|
||||||
func (x:xr) = x
|
func (x : xr) = x
|
||||||
|
|
||||||
#test some other constructor symbol
|
#test some other constructor symbol
|
||||||
#pending
|
#pending
|
||||||
func (x:+:xr) = x
|
func (x :+: xr) = x
|
||||||
|
|
||||||
|
#test normal infix constructor
|
||||||
|
func (x `Foo` xr) = x
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
|
@ -123,8 +123,8 @@ func = do
|
||||||
#test list comprehension comment placement
|
#test list comprehension comment placement
|
||||||
func =
|
func =
|
||||||
[ (thing, take 10 alts) --TODO: select best ones
|
[ (thing, take 10 alts) --TODO: select best ones
|
||||||
| (thing, _got, alts@(_:_)) <- nosuchFooThing
|
| (thing, _got, alts@(_ : _)) <- nosuchFooThing
|
||||||
, gast <- award
|
, gast <- award
|
||||||
]
|
]
|
||||||
|
|
||||||
#test if-then-else comment placement
|
#test if-then-else comment placement
|
||||||
|
|
|
@ -366,11 +366,11 @@ func reallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongvariable
|
||||||
func (A a) = a
|
func (A a) = a
|
||||||
|
|
||||||
#test list constructor
|
#test list constructor
|
||||||
func (x:xr) = x
|
func (x : xr) = x
|
||||||
|
|
||||||
#test some other constructor symbol
|
#test some other constructor symbol
|
||||||
#pending
|
#pending
|
||||||
func (x:+:xr) = x
|
func (x :+: xr) = x
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -748,7 +748,7 @@ func = do
|
||||||
#test list comprehension comment placement
|
#test list comprehension comment placement
|
||||||
func =
|
func =
|
||||||
[ (thing, take 10 alts) --TODO: select best ones
|
[ (thing, take 10 alts) --TODO: select best ones
|
||||||
| (thing, _got, alts@(_:_)) <- nosuchFooThing
|
| (thing, _got, alts@(_ : _)) <- nosuchFooThing
|
||||||
, gast <- award
|
, gast <- award
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -77,10 +77,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 nameDoc
|
middle <- appSep . docLit =<< 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
|
||||||
|
|
Loading…
Reference in New Issue