简体   繁体   中英

Haskell indentation style

I find that I'm often inconsistent about how much I indent things, where I put in new lines, etc.. Are there official or widely followed guidelines for how one ought to layout whitespace in Haskell? Note that I'm not asking what's legal; I'm asking what's good practice, along the lines of Good Haskell coding style of if/else control block? , but much more generally. I'm particularly keen on knowing what people do with do-blocks, let-blocks, where-blocks and case statements, especially when such things are nested in each other or inside several function definitions.

A small nitpick if I may.

I mostly like hammar's linked guideline. But, I really dislike this style:

send :: Socket
     -> ByteString
     -> IO Int

I much prefer

send ::
  Socket ->
  ByteString ->
  IO Int

In the latter style, the arguments and the result look different (the arguments have -> s after them).

I like this better. People may disagree and it's mostly just matters of personal taste. Sadly afaik haddock seems to only support the former style :(

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM