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

Passing ((-) x) as function to map functions is not intuitive #6

Open
kuon opened this issue Jun 10, 2017 · 3 comments
Open

Passing ((-) x) as function to map functions is not intuitive #6

kuon opened this issue Jun 10, 2017 · 3 comments

Comments

@kuon
Copy link
Contributor

kuon commented Jun 10, 2017

I noticed that if we do:

desaturatedColor =
    Color.red
    |> mapSaturation ((-) 0.3)

We end up with a color with saturation -0.7 instead of 0.7.

I think being able to pass ((-) x) is good. One workaround would be to chain the passed function with abs, it wouldn't break (*), (+) and always as generating negative makes no real sense (it would change the behavior of (+) -0.5 if the value is less than 0.5 but is it an issue?).

@kuon kuon changed the title Passing ((-) x) as function is not intuitive Passing ((-) x) as function to map functions is not intuitive Jun 10, 2017
@mdgriffith
Copy link
Owner

Interesting, yeah that isn't intuitive.

One potential problem with using abs is with something like:

--existing value of 0.3
 mapSaturation ((-) 0.6)
-- results in 0.3, though it should probably result in 0.

Maybe just having a note in the docs to write the full lambda like:

mapSaturation (\x -> x - 0.6)

@kuon
Copy link
Contributor Author

kuon commented Jun 11, 2017

Yeah I guess, while abs somehow make it intuitive, it has too many drawbacks.

We could suggest the full lambda and also something like:

sub a b =
    b - a

mapSaturation (sub 0.6)

I dunno if any operator makes sense (maybe something like -: instead of sub, but in the end sub is shorter than (-:) so...).

But I guess pointing the issue clearly in the doc and provide the example should be enough.

@kuon
Copy link
Contributor Author

kuon commented Nov 2, 2017

Do you want a PR with doc update for this? So we can close that one:)

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

No branches or pull requests

2 participants