Skip to content

Instantly share code, notes, and snippets.

@crawftv
Created January 21, 2022 04:43
Show Gist options
  • Save crawftv/2bbf9a51053bdfc0ea895862feb137d6 to your computer and use it in GitHub Desktop.
Save crawftv/2bbf9a51053bdfc0ea895862feb137d6 to your computer and use it in GitHub Desktop.
code for article
module Main exposing (main)
import Browser
import Html exposing (Html, button, div, text)
import Html.Attributes exposing (style)
import Html.Events exposing (onClick)
import Debug
type alias Model =
{
selectedGender : Maybe Gender
, selectedNumber : Maybe Number
, selectedCase : Maybe Case
}
type Number = Singular | Plural
type Gender = Masculine | Feminine | Neuter
type Case = Nominative | Genitive | Dative | Accusative | Vocative
initialModel : Model
initialModel =
{ selectedGender = Nothing
, selectedNumber = Nothing
, selectedCase = Nothing
}
type Msg
= SelectGender Gender
-- | SelectNumber Number
-- | SelectCase Case
view : Model -> Html Msg
view model =
div []
[ button [onClick (SelectGender Masculine)] [text "Masculine"]
, button [onClick (SelectGender Feminine)] [text "Feminine"]
, button [onClick (SelectGender Neuter)] [text "Neuter"]
,div [] [text (Debug.toString model)]
]
update : Msg -> Model -> Model
update msg model =
case msg of
SelectGender gender ->
{ model | selectedGender = Just gender }
main : Program () Model Msg
main =
Browser.sandbox
{ init = initialModel
, view = view
, update = update
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment