3 ms·
Rust has something similar, where some libraries implement on all the different tuples (X1, X2), (X1, X2, X3), (X1, X2, X3, X4), etc.
by rackjack 5y ago
Rust has something similar, where some libraries implement on all the different tuples (X1, X2), (X1, X2, X3), (X1, X2, X3, X4), etc.
- cies 5y agoSo has Haskell. I've also seen it in other languages as well. I guess in Rust and Haskell they are not params of type "Object". Those languages try to maintain type safety where every they can.
- grumpyprole 5y agoPerhaps Haskell could have defined tuples inductively. There are HList libraries that essentially offer this functionality though.
- tome 5y agoAh yes, but they're missing a trick! There's a library for that: https://hackage.haskell.org/package/product-profunctors https://hackage.haskell.org/package/product-profunctors
- piaste 5y agoHeh: https://hackage.haskell.org/package/product-profunctors-0.11.0.3/docs/Data-Profunctor-Product-Examples.html#v:cl_map https://hackage.haskell.org/package/product-profunctors-0.11... > cl_map :: Default Zipper a b => (b -> r) -> a -> [r] > A challenge from a Clojurist on Hacker News (https://news.ycombinator.com/item?id=23939350 https://news.ycombinator.com/item?id=23939350) The referenced comment: > I think the general feeling is that there are some code patterns that are safe and easy to do with dynamic typing, but impossible with simple type systems or more complex with more advanced type system. > An example would be Common Lisp's `map` function [0] (it takes a number of sequences and a function that has as many parameters as there are sequences). It would be hard to come up with a type for this in Java, and it would be a pretty complicated type in Haskell.