fantasyland / static-land

Specification for common algebraic structures in JavaScript based on Fantasy Land
MIT License
772 stars 41 forks source link

Remove angle brackets from type signatures #48

Closed gabejohnson closed 6 years ago

gabejohnson commented 6 years ago

My understanding is that the current signature format exist to match that of Flow and TypeScript, which makes sense. But those signatures exist as they do to match those of C# and Java if I'm not mistaken.

My contention is that the angle brackets, while familiar to users of Flow and TypeScript, are noisy and unnecessary.

ChainRec<T> {
  chainRec: <a, b>((a => Next<a>, b => Done<b>, a) => T<Next<a> | Done<b>>, a) => T<b>
}

This is full of visual noise and makes it difficult for me, the consumer of the spec, to parse.

ChainRec T {
  chainRec: a, b ((a => Next a, b => Done b, a) => T (Next a | Done b), a) => T b
}

This format provides all of the same information with far fewer distracting characters.

rpominov commented 6 years ago

I think it's better to keep Flow/TypeScript syntax. It should be familiar to many JavaScript developers. Also, although it's probably matter of preference, the first snippet actually seems easier to read for me, maybe because angle brackets help to understand meaning of each identifier.

gabejohnson commented 6 years ago

I could even get behind

ChainRec<T> {
  chainRec: <a, b>((a => Next a, b => Done b, a) => T (Next a | Done b), a) => T b
}

to mark T, a, and b as type/type constructor arguments. But the rest of the brackets are entirely unnecessary.

rpominov commented 6 years ago

I've just noticed b => Done b, a would be ambiguous, might mean b => Done<b>, a or b => Done<b, a>.

rpominov commented 6 years ago

Although if we would remove brackets, we would translate Done<b, a> to Done b a (without comma), and it would be unambiguous.

Anyway, I still think that a syntax familiar to JavaScript developers is better because we should attract more JavaScript developers who're just discovering FP than Haskellers who want to write JavaScript. The second group would probably don't care so much about brackets, but the first group might be scared off by unfamiliar syntax.

gabejohnson commented 6 years ago

I understand your position and disagree. I would contend that most JavaScript developers don't use Flow or TypeScript and wouldn't be familiar with any particular type signature format. But I won't belabor the point.