module Main exposing (main)

import Html exposing (..)


main =
    view initialModel


type State
    = Open
    | Closed


initialModel : { state : State, values : List String }
initialModel =
    { state = Open
    , values = fruits
    }


fruits : List String
fruits =
    [ "bananas"
    , "apples"
    , "oranges"
    , "peaches"
    , "strawberries"
    ]


view : { state : State, values : List String } -> Html a
view model =
    case model.state of
        Open ->
            viewOpen model

        Closed ->
            viewClosed model


viewOpen : { state : State, values : List String } -> Html a
viewOpen model =
    div []
        [ p [] [ text "Click to Open" ]
        , ul [] (List.map dropdownItem model.values)
        ]


viewClosed : Html a
viewClosed =
    div []
        [ p [] [ text "Click to Close" ]
        ]


dropdownItem : String -> Html a
dropdownItem value =
    li [] [ text value ]

module Main exposing (main)

import Html exposing (..)


main =
    view initialModel


type State
    = Open
    | Closed


type alias Model =
    { state : State, values : List String }


initialModel : Model
initialModel =
    { state = Open
    , values = fruits
    }


fruits : List String
fruits =
    [ "bananas"
    , "apples"
    , "oranges"
    , "peaches"
    , "strawberries"
    ]


view : Model -> Html a
view model =
    case model.state of
        Open ->
            viewOpen model

        Closed ->
            viewClosed


viewOpen : Model -> Html a
viewOpen model =
    div []
        [ p [] [ text "Click to Open" ]
        , ul [] (List.map dropdownItem model.values)
        ]


viewClosed : Html a
viewClosed =
    div []
        [ p [] [ text "Click to Close" ]
        ]


dropdownItem : String -> Html a
dropdownItem value =
    li [] [ text value ]

Add a `Model` type alias
Add a `Model` type alias

Using the record type is awkward so alias it as `Model` so we can use it
in signatures easily.

Note that this is different than the `State` type which is _not_ an
alias but instead is its own thing.
