
Congrats! I look forward to seeing how this develops.
On Sun, Sep 4, 2016 at 11:27 AM, lennart spitzner
Greetings,
I am happy to announce a first alpha release of brittany (0.7.0.0), a haskell source code formatting tool based on ghc-exactprint [2] (and thus ghc's parser).
https://github.com/lspitzner/brittany
Two small feature cases that brittany would produce/leave unmodified:
-- Newlines are used sparingly: Only after "do" and when the -- `liftBaseOpDiscard` application would lead to overflowing 80 columns. main :: IO () main = do pool <- createPostgresqlPool (toS databaseConnectionString) 10 initiate $ \chan -> forever $ do flip runDbConn pool $ do makeSureQueueIsFull chan void $ liftBaseOpDiscard (consumeMsgs chan responseQueue Ack) (uncurry processMsg) threadDelay 1000000
-- Alignment of patterns go [] "" = True go [WildCard ] "" = True go (WildCard :rest) (c:cs) = go rest (c : cs) || go (WildCard : rest) cs go (Union globs:rest) cs = any (\glob -> go (glob ++ rest) cs) globs go [] (_:_) = False go (_:_) "" = False
Yet this is an alpha release, for the following reasons:
- Brittany currently only transforms top-level type signatures and (function) bindings. - Not all syntactical constructs (even of plain 2010 haskell) are understood. All common constructs should work, but "common" is purely subjective. - Not all (syntactic) extensions are supported, either. - Needs more testing. (And less than a hundred automated testcases is not very much to explore every syntactic corner of haskell.)
On the other hand
- I have started using the tool successfully, albeit selectively. - There are checks in place that detect 1) if output is not valid haskell or 2) if source comments are not transcribed to the output. That is, running into non-handled cases should lead to error messages that are harmless, not into any silent it-overwrote-my-code-with-garbage.
*How to build?*
Brittany requires ghc-8. See https://github.com/lspitzner/brittany#building
A hackage release is not planned yet.
*Brittany's formatting style*
Currently brittany does _not_ give the user many choices. A few flags exist, most prominently to change the indentation (default 2) or the columns (default 80). I am open to suggestions of how to improve the style, but trying to make everyone happy is not a fulfilling goal for me.
*Implementation/documentation/performance*
The implementation and its core ideas are not documented. The core algorithm in theory has linear complexity in input size; the implementation probably is quadratic dues to some misuses of plain lists or other such implementation details. Providing at least a high-level overview is on my to-do list.
[1] https://github.com/lspitzner/brittany [2] https://hackage.haskell.org/package/ghc-exactprint
-- lennart _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.