-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Triple.Extra #52
Triple.Extra #52
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't say much because I've never used triples
- would be nice to still add the codegen code in a separate folder in case one wants to change the documentation in the future for example
- the swizzles do in fact seem only very rarely useful and I'd always prefer explicit construction personally
fromListHead
: maybe rename it tofromListBeginning
orfromBeginningOfList
?joinBy
seems somewhat inconsistent because- we don't have
sumBy
,productBy
etc either - in all other
-By
operations likeminimumBy
orsortBy
the given function(s) do not map the result which means a name likejoinMap
is probably more consistent - I feel like the arguments in the explicit
join sep (map a b c triple)
are much more clear
- we don't have
The swizzles I'd avoid having in The other functions feel... weird? Like, is doing the product of three numbers in a triple a common operation at all? Or sorting them? |
Hm I tend to agree with some of these sentiments. The functions I added are just stuff we have in Tuple.Extra. But perhaps it's better to be more conservative to begin with. I'll probably like to keep the sorting functions (or at least |
I’m curious about the swizzles. Is that something you came up with yourself, or something you’ve seen somewhere else? Also just for curiosity, what could they be used for? |
They're a common feature of GPU oriented languages like GLSL. I always found them super fun, but perhaps the reason they'd be useful in those contexts is that those languages generally compute around fix length vectors, whereas actually triples are fairly rare in Elm (and we don't actually particularly want to promote them). So you can do things like: vec4 opaque = vec4(color.rgb, 1.0);
vec3 mirrored = position.yxz;
vec3 onlyRed = color.rrr; and so on |
This adds a library for dealing with Triples (fixes #21).
I think the most controversial idea here are the swizzles. I'm happy to delete them for now if the other maintainers have qualms.