Skip to content
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

Merged
merged 5 commits into from
Mar 22, 2024
Merged

Triple.Extra #52

merged 5 commits into from
Mar 22, 2024

Conversation

gampleman
Copy link
Collaborator

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.

Copy link
Collaborator

@lue-bird lue-bird left a 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 to fromListBeginning or fromBeginningOfList?
  • joinBy seems somewhat inconsistent because
    • we don't have sumBy, productBy etc either
    • in all other -By operations like minimumBy or sortBy the given function(s) do not map the result which means a name like joinMap is probably more consistent
    • I feel like the arguments in the explicit join sep (map a b c triple) are much more clear

@miniBill
Copy link
Collaborator

triple, first, second, third are obviously good

The swizzles I'd avoid having in core-extra

The other functions feel... weird? Like, is doing the product of three numbers in a triple a common operation at all? Or sorting them?

@gampleman
Copy link
Collaborator Author

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 sortWith) since they're somewhat challenging to implement correctly.

@lydell
Copy link
Contributor

lydell commented Mar 21, 2024

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?

@gampleman gampleman requested a review from lue-bird March 21, 2024 16:41
@gampleman
Copy link
Collaborator Author

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

src/Triple/Extra.elm Outdated Show resolved Hide resolved
@gampleman gampleman merged commit 3ce1762 into master Mar 22, 2024
4 checks passed
@gampleman gampleman deleted the triple-extra branch March 22, 2024 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Triple library missing
4 participants