From the playground example
module Button = {
@react.component
let make = (~count: int) => {
let times = switch count {
| 1 => "once"
| 2 => "twice"
| n => Belt.Int.toString(n) ++ " times"
}
let msg = "Click me " ++ times
<button> {msg->React.string} </button>
}
}
Looks good, now put a block at 2
module Button = {
@react.component
let make = (~count: int) => {
let times = switch count {
| 1 => "once"
| 2 => {
Js.log("picked 2")
"twice"
}
| n => Belt.Int.toString(n) ++ " times"
}
let msg = "Click me " ++ times
<button> {msg->React.string} </button>
}
}
Why does the block at 2 need an seemingly arbitrary blank line after it? All it does for me is hurt readability because the choices are less mentally scanable.
Here’s an example from my own code. There’s no reason for anything here to have blank lines, but look who shows up.
describe("mydesc", () => {
testPromise("something", ctx => {
let sql = `insert into users (id, email, password) values (1,'me@example.com', 'asdf')`
ctx
->getDb
->DalLoad.go(sql)
->Promise.then(
_a => {
DalUser.get(ctx->getDb, "1")
},
)
->thenResolve(
maybeUser => {
switch maybeUser {
| Some(user) => {
Js.log(user)
chai->equal(user.id, "1")
chai->equal(user.email, "me@example.com")
chai->equal(user.password, "asdf")
}
| None => chai->fail("missing user")
}
},
)
})
})
p.s. The Promise.then is also putting in newlines for no reason, but at least there aren’t two in a row.