3 ms·
That's only possible because F#'s (and OCaml's) type system is so simple (basically the only possible relationship is equality, with is indicated by reusing the
by tomp 6y ago
That's only possible because F#'s (and OCaml's) type system is so simple (basically the only possible relationship is equality, with is indicated by reusing the same letter twice). But if your system is more complex, even like Java's, you often need additional constraints, e.g. <X : Hashable> or something. In that case, you probably do need to declare your type parameters.
Best, of course, would be some middle ground assisted by a fantastic compiler.
group_by : list[`a] -> (`a -> (`b : hashable)) -> Map[`b, list[`a]]
or something
- uryga 6y ago> you often need additional constraints, e.g. <X : Hashable> or something in haskell: noConstraint :: List a -> (a -> b) -> List b withConstraints :: (Hashable a, Frobable b) => List a -> (a -> b) -> List b you still don't have to declare `a` and `b`, you're just adding a constraint on them. (iirc in haskell types have to start with an uppercase character, which means you can use lowercase letters for type variables without extra apostrophes etc)