2 ms·
Oh my so many warts. In haskell, ocaml but also F#. > Specifically, method constraints were added, introduced by a deliberately baroque syntax: let inline (
by rurban 6y ago
Oh my so many warts. In haskell, ocaml but also F#.
> Specifically, method
constraints were added, introduced by a deliberately baroque syntax:
let inline (+) (x: ^T) (y: ^U) : ^V = ((^T or ^U):
(static member op_Addition : ^T * ^U -> ^V) (x, y))
> This definition says that any use of + is implemented via inlining a call to an appropriately-typed op_Addition method, defined on the type ˆT or ^U, i.e. the type of either the left-hand or right-hand argument. The ˆT notation for type variables indicates statically resolved type parameters (SRTP), i.e. type parameters which are resolved to a nominal type at compile-time.
Why ^ and not using the existing : for seperating types from values? :T * :U -> :V
would have looked like types, not pascal ptrs.
Equally interesting are ocaml warts like let x2 = 1.0 +. 2.0
(+ not overloaded or defined for floats), or haskell's decision to torpedo the "class" keyword.
Or ocaml hijacking ::
let xs = 1 :: xs, with :: being cons, which was initially the lisp dot notation '(1 . xs)
In retrospect perl's syntax is sane compared to this.
- Smaug123 6y agoYou're not actually supposed to use statically resolved type parameters. It's deliberately strange and difficult, because mere mortals are not supposed to use it. `::` is normal for cons in an ML, right? Of the ML family of languages, I'm only aware of Haskell that chooses differently (they use the single colon).
- smabie 6y agoI agree, though Haskell is certainly the most advanced. ML languages tend to be... primitive, at least to the modern eye. The lack of function polymorphism in OCaml is such a huge bummer. Modular implicits have been proposed (in a paper from 2014), but it doesn't seem that they are being actively worked on. If I could get multicore and modular implicits, OCaml would be the ideal language.
- octachron 6y agoModular implicits are being worked on actively, it is just a hard feature to get right in a scalable and future-compatible way.