sebastiaanvisser / clay

A CSS preprocessor as embedded Haskell.
Other
360 stars 73 forks source link

There should be safe versions of `lighten` and `darken` #155

Closed adius closed 4 years ago

adius commented 6 years ago
lighten :: Float -> Color -> Maybe Color 
lighten 0.5 white == Nothing

or maybe it returns a tuple a la (error, value)

What do you think?

turion commented 5 years ago

@ad-si So in which cases should it return Nothing? lighten x white and darken x black? I thought the problem is rather, that Other can't be lightened. I agree that there probably should be no calls to error, as there currently is, but that's a major change. That being said, I'm fine with changing this to lighten :: Float -> Color -> Maybe Color or even lighten :: Float -> Color -> Either ColorError Color with some new error type to be defined, but then the old behaviour should be preserved in a function unsafeLighten.

We could also do that in steps, i.e. first add a safeLighten function, then deprecate or rename the current lighten.

PR welcome.

github-actions[bot] commented 4 years ago

Stale issue message