Closed Janiczek closed 2 months ago
I think justIf
is a way better name than toMaybe
, fwiw
I think the classList
style function for List.Extra
would actually be a much more useful solution, that seems to come up a lot (especially in view code).
Maybe.Extra.justIf : Bool -> a -> Maybe a
Motivating use case
I had a dropdown menu with a few actions for the user to choose. I needed to remove one of the actions from the list based on a boolean.
Normally I'd do it with:
Our code is full of this pattern.
Maybe there's also some
Html.Attributes.classList
-like way? I'm thinkingList.Extra.filter : List (a, Bool) -> List a
.