Open YetAnotherMinion opened 7 years ago
Hey that looks pretty cool. Ive been in your situation, but I usually had something a bit clunkier, like a function called buttonAttributes : Bool -> List Attribute
.
I use maybeCons
all the time. Just yesterday that I made a PR over in Maybe.Extra
for this function. https://github.com/elm-community/maybe-extra/pull/38
Saying that here for recording keeping in case anyone makes a maybeCons
PR on List-Extra
I have found it useful when building views to be able to conditionally include an Attribute or child element. It seem natural to use Maybe to represent this conditional nature. However I usually only have one conditional attribute and several unconditional attributes so it feels a little awkward and overkill to wrap many elements in Just and then call
filterMap identity
. I would prefer to write the list literal and then conditionally add items.For example when a tabbed container, I want to only attach click handlers to the non selected tabs to simplify my update logic.
Cons
Haskell does not feel the need to implement this. It is really simple function anyone can write if they really need it.