I used to write
data A = A {
a :: Double
}
deriving(Eq, Show)
but now i prefer
data A = A {
a :: Double
} deriving(Eq, Show)
I think the answer will be no, but i ask anyway: is there a code formatter for Haskell?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
New answer
I have now written hindent, which is written in terms of haskell-src-exts. It has Emacs and Vim support.
Old answer
There is haskell-src-exts which will parse your code and it has a pretty printing module for printing the AST to a string. E.g.
Example:
Alternatively you can write a pretty printer yourself (even based on the above if you just want to specialise), and then you can have whatever style you want. Replace
prettyPrintwith your own. The AST is very straight-forward.Then you can hook it up with Emacs to reformat every time you hit save or something.