Maybe is used to wrap an operation that might fail.
So, when you ask for the head of a list, you might get Just the head OR you
might get Nothing if the list is empty.

However, the issue here is again, an error on my part. Sorry about that.

The actual solution to the currentBox is:

currentBox =
    List.concat model.cells
    |> List.filter (\box -> box.id == boxId)
    |> List.head
    |> Maybe.withDefault (Box -1 Nothing) -- this value should never happen
in your context


You don't need to filter each row, you need to concatenate the rows into a
single list and filter that list on the id of the box.

Sorry about the misleading code from the previous message (I should have
tested it but was too lazy).


-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to