3 ms·
Why use :: for type annotations instead of the more standard single colon?
by whateveracct 11y ago
Why use :: for type annotations instead of the more standard single colon?
- bryanlarsen 11y ago:: is what Haskell uses, and this is a Haskell derivative.
- nikolay 11y agoWhy not call it Goskell then? If it's a different language, it should improve on some legacy stuff.
- owickstrom 11y agoAuthor here :) It's inspired by Haskell, yes, but not a dialect. Syntax is very much open for change still and that's really not the most important bit. Semantics are not like Haskell, more Go + polymorphism.
- nikolay 11y agoI think those using Haskell can learn to use a single colon plus they will appreciate it better as the double colon steals too much visual attention.
- ApplaudPumice 11y agoWhat I don't like about Haskell is repeating the function name. yeah :: Num yeah = 3 repeating yeah two times is ugly.
- nikolay 11y agoUgliness is not the biggest issue - not being DRY is!
- thinkpad20 11y agoI'm a bit disappointed by the double colon; it's my least favorite part of Haskell syntax (I probably shouldn't care, but there you go). It also bugs me in PureScript. However, Agda, Idris, and Elm, all of which have syntax heavily inspired by Haskell, all do it the "right way", so there's no reason a Haskell-inspired language can't. Plus, this doesn't look that much like Haskell, certainly not to the point of being derivative.
- whateveracct 11y agoHaskell is a bit of the odd man out in terms of syntax for type annotations. Scala, OCaml, Agda, Idris, Elm all use single colon. I'm actually unsure why Haskell is the way it is.
- hollerith 11y agoHaskell's designers wanted single colon for the cons operator, and the cons operator is legal on the left-hand side of an "equation" (sorry, don't recall the official terminology) because Haskell allows pattern matching there. (I'm not saying I agree with the decision.)
- gleenn 11y agoRuby...