Skip to content

miyamoen/select-list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yet another SelectList implementation

A SelectList is a non-empty list which always has exactly one element selected. It is one of zipper.

Inspired by these modules

selectedMap is the feature function in this package. Use selectedMap in view.

    view : SelectList String -> Html Msg
    view selectList =
        ul [] <|
            SelectList.selectedMap
                (\position item ->
                    li [ onClick (Set item) ]
                        [ text <| toString <| SelectList.index item
                        , text <| toString <| SelectList.selected item
                        ]
                )
                selectList

Get a focused item and index from select list. Position describes whether it is selected, or not.

Compared with List.indexedMap.

    selectedMap : (Position -> SelectList a -> b) -> SelectList a -> List b
    indexedMap : (Int -> a -> b) -> List a -> List b

Unlike indexedMap, we can get full access to all elements in the list. And set new list to Model.

If you don't use non-empty list, use selectedMapForList that receives List instead of SelectList.

List.indexedMap is replaced with selectedMapForList .

example

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages