I was trying to write a TypeScript type that turns [A, B, C, ...] (an array of objects) into (A & B & C & ...). It seemed inexpressible, then I realized it's what Object.assign does! But then I looked at the type for that and... whoops. https://github.com/Microsoft/TypeScript/blob/2f73986b44a4ec10c7ebe7188e23863c3879d54e/lib/lib.es2015.core.d.ts#L286 …
-
Show this thread
-
Unless I'm misunderstanding what's happening here, Object.assign in TypeScript silently switches from enforcing types to not enforcing them if you call Object.assign() with more than four arguments. This seems very bad?
3 replies 1 retweet 11 likesShow this thread -
It seems like you'd at least want to punt in the more comprehensive way that Haskell does in these situations. E.g., this part of the Prelude that defines the types for tuple constructors... one at a time, for everything from 1 argument to 62 arguments. https://downloads.haskell.org/~ghc/7.4.1/docs/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html …
2 replies 0 retweets 7 likesShow this thread -
Reminder that GHC limits tuples to 62 elements because "Manuel says: Including one more declaration gives a segmentation fault", as documented in the GHC source code. https://github.com/ghc/ghc/blob/e3f341f334d89c88f388d8e864ed8762d0890a64/libraries/ghc-prim/GHC/Tuple.hs …
5 replies 9 retweets 33 likesShow this thread -
Replying to @garybernhardt
Rust allows tuples of any arbitrary size, but most traits are only implemented for tuples of up to 16 elements. Same for fixed size arrays (though it goes up to 32 for those). Diesel has this monster https://github.com/diesel-rs/diesel/blob/57e17f224b7938b33487d2a0e6ba83fb524dd42e/diesel/src/macros/tuples.rs …
2 replies 2 retweets 21 likes
If you're curious, multiple attempts have been made at allowing variadic generics, but the problem with making that work for tuples is that you naturally want to treat them as an hlist and write impls recursively, but you can't take a pointer to the tail of a tuple
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.