You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
justIf bool value =if bool thenJust value
elseNothing
Test.fuzz Fuzz.int "justIf False _ = Nothing"<|\int ->Maybe.Extra.justIf False int
|>Expect.equal NothingTest.fuzz Fuzz.int "justIf True a = Just a"<|\int ->Maybe.Extra.justIf True a
|>Expect.equal (Just 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.
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
.The text was updated successfully, but these errors were encountered: