Or here is a similar approach to what Max suggested. If you do
List.concatMap with sub-lists instead of List.filterMap with Maybes, you
don't have to wrap each node individually.
view model =
div []
<| List.concatMap
[ [ static nodes that always appear ]
, (when model.gif (div [] [ blah blah ])
, [ more static nodes ]
]
when : String -> Node -> List Node
when url node =
if String.isEmpty url then
[]
else
[ node ]
On Mon, May 16, 2016 at 5:47 PM, Nick H <[email protected]> wrote:
> Here is another strategy that came to mind. Instead of returning a value
> that is sometimes invisible, you could have a modifier that sometimes
> performs a no-op:
>
> appendWhen : Bool -> Node -> List Node -> List Node
> appendWhen condition node nodes =
> if condition then
> nodes ++ [node]
> else
> nodes
>
> On Mon, May 16, 2016 at 5:26 PM, Max Goldstein <[email protected]>
> wrote:
>
>> Perhaps use List.filterMap to drop Nothing? But all of the nonconditional
>> nodes must be prefaced with Just <| which is annoying.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.