module App.View exposing (view)

import Html exposing (Html, div, text, a)
import Html.Attributes exposing (class, href)
import Components.View
import Detail.View
import App.Model exposing (..)
import App.Messages exposing (..)
import Nav.Model exposing (Page(..))

view : Model -> Html Msg
view model =
    let
        page =
            viewPage model
    in
        div [ class "app" ]
            [ div [ class "app__sidebar" ]
                [ a [ href "/", class "app__home" ] [ text "PANOPTICON" ] ]
            , div [ class "app__container" ] [ page ]
            ]

viewPage : Model -> Html Msg
viewPage model =
    case model.page of
        Components ->
            componentsView model

        Component _ _ _ _ ->
            detailView model

componentsView : Model -> Html Msg
componentsView model =
    Html.map ComponentsMsg <| Components.View.view model.components

detailView : Model -> Html Msg
detailView model =
    Html.map DetailMsg <| Detail.View.view model.detail

Change link to frontpage to avoid reloading app

module App.View exposing (view)

import Html exposing (Html, div, text, a)
import Html.Attributes exposing (class, href)
import Components.View
import Detail.View
import App.Model exposing (..)
import App.Messages exposing (..)
import Nav.Model exposing (Page(..))
import Nav.Nav exposing (toHash)

view : Model -> Html Msg
view model =
    let
        page =
            viewPage model
    in
        div [ class "app" ]
            [ div [ class "app__sidebar" ]
                [ a [ href <| toHash Components, class "app__home" ] [ text "PANOPTICON" ] ]
            , div [ class "app__container" ] [ page ]
            ]

viewPage : Model -> Html Msg
viewPage model =
    case model.page of
        Components ->
            componentsView model

        Component _ _ _ _ ->
            detailView model

componentsView : Model -> Html Msg
componentsView model =
    Html.map ComponentsMsg <| Components.View.view model.components

detailView : Model -> Html Msg
detailView model =
    Html.map DetailMsg <| Detail.View.view model.detail


module Update exposing (update)

import Action exposing (Action(..))
import Model exposing (Model)
import List exposing (indexedMap)
import Types exposing (Piece(..), Player(..))

update : Action -> Model -> (Model, Cmd Action)
update action model =
  case action of
    -- Place a piece in the given index; assumed the move is legal
    PlacePieceInIndex flatIndex ->
      ( { model |
          board =
            let
                mapper : Int -> Maybe Piece -> Maybe Piece
                mapper index currentPiece =
                  if index == flatIndex
                  then if currentPiece == Nothing then Just model.pieceOfPlayer else currentPiece
                  else currentPiece
            in indexedMap mapper model.board
        -- Flip the turn players
        , turnPlayer =
          if model.turnPlayer == Player1
          then Player2
          else Player1
        -- Flip the current player's piece
        , pieceOfPlayer =
          if model.pieceOfPlayer == X then O else X
        }
      , Cmd.none
      )
    _ -> (model, Cmd.none)

Fix premature player change bug

module Update exposing (update)

import Action exposing (Action(..))
import Model exposing (Model)
import List exposing (indexedMap)
import Types exposing (Piece(..), Player(..))
import Zone exposing (Zone)

update : Action -> Model -> (Model, Cmd Action)
update action model =
  case action of
    -- Place a piece in the given index; assumed the move is legal
    PlacePieceInIndex flatIndex ->
      let
        zoneToPlacePlayerPiece : Int -> List (Maybe Piece) -> Maybe Zone -> Maybe Zone
        zoneToPlacePlayerPiece index pieces acc =
          case pieces of
            [] -> acc
            piece :: pieces ->
              let recursiveResult = zoneToPlacePlayerPiece (index + 1) pieces acc
              in
                if index == flatIndex
                then case piece of
                  Nothing -> Just (Zone.fromFlat index)
                  _ -> recursiveResult
                else recursiveResult
        zone = zoneToPlacePlayerPiece 0 model.board Nothing
      in case zone of
        Nothing -> (model, Cmd.none)
        Just zone ->
          let
            index = Zone.toFlat <| zone
          in
            ( { model |
              board =
                let
                  mapper : Int -> Maybe Piece -> Maybe Piece
                  mapper index' currentPiece =
                    if index == index' then Just model.pieceOfPlayer else currentPiece
                in indexedMap mapper model.board
              -- Flip the turn players
              , turnPlayer =
                if model.turnPlayer == Player1
                then Player2
                else Player1
              -- Flip the current player's piece
              , pieceOfPlayer =
                if model.pieceOfPlayer == X then O else X
              }
            , Cmd.none
            )
    _ -> (model, Cmd.none)


module Events.EventItem exposing (view)

import Msgs exposing (Msg)
import Html exposing (..)
import Html.Attributes exposing (..)

import Models exposing (EventItem)
import Routing exposing (eventPath, onLinkClick)

import Markdown

view : EventItem -> Html Msg
view event =
  let
    path =
      eventPath event.id
  in
    article [] [
      hr [][],
      div [ class "heading" ] [
        a [ class "btn regular", href path, onLinkClick (Msgs.ChangeLocation path)] [
          h2 [ class "subtitle is-4" ] [
            text event.title
          ]
        ]
      ]
      , Markdown.toHtml [ class "content" ] event.text
    ]

Add styles to events page

module Events.EventItem exposing (view)

import Msgs exposing (Msg)
import Html exposing (..)
import Html.Attributes exposing (..)

import Models exposing (EventItem)
import Routing exposing (eventPath, onLinkClick)

import Markdown

participantRow : Int -> String -> Html Msg
participantRow index participant =
  tr [] [
    th [] [ text (toString index) ],
    td [] [ text participant ]
  ]

view : EventItem -> Html Msg
view event =
  let
    path =
      eventPath event.id
  in
    article [] [
      div [ class "heading" ] [
        a [ class "btn regular", href path, onLinkClick (Msgs.ChangeLocation path)] [
          h1 [ class "title" ] [
            text event.title
          ],
          hr [][],
          h2 [ class "subtitle is-6" ] [
            text ("Julkaistu " ++ event.created_on)
          ]
        ]
      ]
      , Markdown.toHtml [ class "content" ] event.text
      , table [ class "table" ] [
        tbody [] [
          tr [] [
            th [] [ text "Missä:" ],
            td [] [ text event.location ]
          ],
          tr [] [
            th [] [ text "Alku:" ],
            td [] [ text event.event_start_time ]
          ],
          tr [] [
            th [] [ text "Loppu:" ],
            td [] [ text event.event_end_time ]
          ],
          tr [] [
            th [] [ text "Ilmottautuminen alkaa:" ],
            td [] [ text event.registration_start_time ]
          ],
          tr [] [
            th [] [ text "Ilmottautuminen päättyy:" ],
            td [] [ text event.registration_end_time ]
          ],
          tr [] [
            th [] [ text "Osallistujia:" ],
            td [] [
              text (
                (List.length event.participants |> toString) ++
                "/" ++
                (toString event.max_participants)
              )
            ]
          ]
        ]
      ]
      , h2 [ class "subtitle" ] [ text "Osallistujat" ]
      , table [ class "table" ] [
        thead [] [
          tr [] [
            th [] [ text "#" ],
            th [] [ text "Nimi" ]
          ]
        ],
        tbody [] (
          List.indexedMap participantRow event.participants
        )
      ]
      , hr [][]
      , text ("Kirjoittajat: " ++ (String.join ", " event.authors))
    ]


module Toolbox.Action (..) where

import Dict
import Effects exposing (Effects)
import Toolbox.Types exposing (Model, Response)

type Action
  = DownloadedIngredients (Maybe Response)
  | NoOp

update : Action -> Model -> ( Model, Effects Action )
update action model =
  case action of
    DownloadedIngredients maybeResponse ->
      ( responseToModel maybeResponse
      , Effects.none
      )

    NoOp ->
      ( model, Effects.none )

responseToModel : Maybe Response -> Model
responseToModel maybeResponse =
  case maybeResponse of
    Just r ->
      { ingredients =
          let
            ids =
              [1..(List.length r.ingredients - 1)]
          in
            List.map2 (,) ids r.ingredients |> Dict.fromList
      }

    Nothing ->
      { ingredients = Dict.empty }

Refactor enumerating a list into a separate function.

module Toolbox.Action (..) where

import Dict
import Effects exposing (Effects)
import Toolbox.Types exposing (Model, Response)

type Action
  = DownloadedIngredients (Maybe Response)
  | NoOp

update : Action -> Model -> ( Model, Effects Action )
update action model =
  case action of
    DownloadedIngredients maybeResponse ->
      ( responseToModel maybeResponse
      , Effects.none
      )

    NoOp ->
      ( model, Effects.none )

enumerate : List a -> List ( Int, a )
enumerate list =
  let
    ids =
      [1..(List.length list - 1)]
  in
    List.map2 (,) ids list

responseToModel : Maybe Response -> Model
responseToModel maybeResponse =
  case maybeResponse of
    Just r ->
      { ingredients = enumerate r.ingredients |> Dict.fromList }

    Nothing ->
      { ingredients = Dict.empty }


module Display (..) where

import Html exposing (Html, div, h1)
import Mouse

view : Html
view =
  h1 [] [ Html.text "Welcome to Tic Tac Toe"]

main =
  view

Add grid to display page

module Display (..) where

import Html exposing (..)
import Html.Attributes exposing (..)
import Mouse

cell : Attribute
cell =
  style
    [("margin", "10px")
    , ("width", "30%")
    , ("height", "200px")
    , ("text-align", "center")
    , ("-webkit-user-select", "none")
    , ("user-select", "none")
    , ("font-size", "6em")
    , ("border-radius", "0")
    , ("-webkit-appearance", "none")
    , ("padding", "0px")
    , ("background", "white")
    , ("border", "2px solid #4A4A4A"),
      ("display", "inline-block")]

header : Attribute
header =
  style
    [("text-align", "center")]

header : Attribute
header =
  style
    [("text-align", "center")]

view : Html
view =
  div [] [
    h1 [header] [ Html.text "Welcome to Tic Tac Toe"],
    div [cell] [],
    div [cell] [],
    div [cell] [],
    div [cell] [],
    div [cell] [],
    div [cell] [],
    div [cell] [],
    div [cell] [],
    div [cell] []
  ]

main =
  view


module Internal.TextField.HelperText.Implementation exposing
    ( Property
    , helperText
    , persistent
    , validationMsg
    )

import Html exposing (Html)
import Internal.Options as Options exposing (cs, css, when)

type alias Config =
    { persistent : Bool
    , validationMsg : Bool
    }

defaultConfig : Config
defaultConfig =
    { persistent = False
    , validationMsg = False
    }

type alias Property m =
    Options.Property Config m

persistent : Property m
persistent =
    Options.option (\config -> { config | persistent = True })

validationMsg : Property m
validationMsg =
    Options.option (\config -> { config | validationMsg = True })

helperText : List (Property m) -> List (Html m) -> Html m
helperText options =
    let
        ({ config } as summary) =
            Options.collect defaultConfig options
    in
    Options.styled Html.p
        (cs "mdc-text-field-helper-text"
            :: (cs "mdc-text-field-helper-text--persistent" |> when config.persistent)
            :: (cs "mdc-text-field-helper-text--validation-msg" |> when config.validationMsg)
            :: options
        )

Make sure helper text displays again

module Internal.TextField.HelperText.Implementation exposing
    ( Property
    , helperText
    , persistent
    , validationMsg
    )

import Html exposing (Html)
import Internal.Options as Options exposing (cs, css, when, aria, styled)

type alias Config =
    { persistent : Bool
    , validationMsg : Bool
    }

defaultConfig : Config
defaultConfig =
    { persistent = False
    , validationMsg = False
    }

type alias Property m =
    Options.Property Config m

persistent : Property m
persistent =
    Options.option (\config -> { config | persistent = True })

validationMsg : Property m
validationMsg =
    Options.option (\config -> { config | validationMsg = True })

helperText : List (Property m) -> List (Html m) -> Html m
helperText options text =
    let
        ({ config } as summary) =
            Options.collect defaultConfig options
    in
    styled Html.div
        [ cs "mdc-text-field-helper-line" ]
        [ styled Html.div
            (cs "mdc-text-field-helper-text"
                :: (cs "mdc-text-field-helper-text--persistent" |> when config.persistent)
                :: (cs "mdc-text-field-helper-text--validation-msg" |> when config.validationMsg)
                 :: (aria "hidden" "true")
                :: options
            )
            text
        ]


module Main exposing (..)

import Navigation
import View
import Update
import Model exposing (Model)
import Route exposing (Location(Login))
import Msg exposing (Msg(..))
import Material
import Util

main : Program Never
main =
    Navigation.program (Navigation.makeParser Route.locFor)
        { init = init
        , update = Update.update
        , urlUpdate = urlUpdate
        , view = View.view
        , subscriptions = subscriptions
        }

subscriptions : Model -> Sub Msg
subscriptions model =
    Material.subscriptions Mdl model

urlUpdate : Maybe Route.Location -> Model -> ( Model, Cmd Msg )
urlUpdate location oldModel =
    let
        newModelWithClearedForms =
            { oldModel | route = location, newUserForm = (Model.initialModel Nothing).newUserForm }

        newModel =
            case newModelWithClearedForms.apiKey of
                Nothing ->
                    { newModelWithClearedForms | route = Just Login }

                Just apiKey ->
                    newModelWithClearedForms
    in
        newModel ! (Util.cmdsForModelRoute newModel)

init : Maybe Route.Location -> ( Model, Cmd Msg )
init location =
    urlUpdate location <| Model.initialModel location

Handle url redirect for login page

module Main exposing (..)

import Navigation
import View
import Update
import Model exposing (Model)
import Route exposing (Location(Login))
import Msg exposing (Msg(..))
import Material
import Util

main : Program Never
main =
    Navigation.program (Navigation.makeParser Route.locFor)
        { init = init
        , update = Update.update
        , urlUpdate = urlUpdate
        , view = View.view
        , subscriptions = subscriptions
        }

subscriptions : Model -> Sub Msg
subscriptions model =
    Material.subscriptions Mdl model

urlUpdate : Maybe Route.Location -> Model -> ( Model, Cmd Msg )
urlUpdate location oldModel =
    let
        newModelWithClearedForms =
            { oldModel | route = location, newUserForm = (Model.initialModel Nothing).newUserForm }

        ( newModel, loginRedirectCmd ) =
            case newModelWithClearedForms.apiKey of
                Nothing ->
                    case newModelWithClearedForms.route of
                        Just Login ->
                            newModelWithClearedForms ! []

                        _ ->
                            { newModelWithClearedForms | route = Just Login } ! [ Navigation.modifyUrl (Route.urlFor Login) ]

                Just apiKey ->
                    newModelWithClearedForms ! []
    in
        ( newModel
        , Cmd.batch <| loginRedirectCmd :: (Util.cmdsForModelRoute newModel)
        )

init : Maybe Route.Location -> ( Model, Cmd Msg )
init location =
    urlUpdate location <| Model.initialModel location


module Models exposing (..)

-- Material

import Material

type alias Model =
    { mdl : Material.Model
    , plants : List Plant
    }

initialModel : Model
initialModel =
    { mdl = Material.model
    , plants =
        [ { id = 1, name = "Basil", desc = "A green plant." }
        , { id = 2, name = "Thyme", desc = "Another green plant." }
        ]
    }

type alias PlantId =
    Int

type alias Plant =
    { id : Int
    , name : String
    , desc : String
    }

Use type alias rather than type for PlantId

module Models exposing (..)

-- Material

import Material

type alias Model =
    { mdl : Material.Model
    , plants : List Plant
    }

initialModel : Model
initialModel =
    { mdl = Material.model
    , plants =
        [ { id = 1, name = "Basil", desc = "A green plant." }
        , { id = 2, name = "Thyme", desc = "Another green plant." }
        ]
    }

type alias PlantId =
    Int

type alias Plant =
    { id : PlantId
    , name : String
    , desc : String
    }


module Trampoline where

{-| Trampolining loops for unbounded recursion.
Since most javascript implementations lack tail-call elimination, deeply tail-recursive functions will result in a stack overflow.

```haskell
fac' : Int -> Int -> Int
fac' n acc = if n <= 0
             then acc
             else fac' (n - 1) (n * acc)

fac : Int -> Int
fac n = fac' n 1

-- Stack overflow
main = asText <| fac 1000000000000
```

Trampolining allows for long-running tail-recursive loops to be run without pushing calls onto the stack:
```haskell
facT : Int -> Int -> Trampoline Int
facT n acc = Trampoline <| if n <= 0
                           then Left acc
                           else Right <| \() -> facT (n - 1) (n * acc)
fac : Int -> Int
fac n = trampoline <| facT n 0

-- Doesn't stack overflow
main = asText <| fac 1000000000000
```
# Trampoline
@docs Trampoline, trampoline
 -}
import Native.Trampoline

{-| A computation that might loop. A trampoline is either the resulting value or a thunk that needs to be run more. -}
data Trampoline a = Done a
                  | Continue (() -> Trampoline a)

{-| Run a trampolining loop in constant space. -}
trampoline : Trampoline a -> a
trampoline = Native.Trampoline.trampoline

Update trampoline docs to new interface.

module Trampoline where

{-| Trampolining loops for unbounded recursion.
Since most javascript implementations lack tail-call elimination, deeply tail-recursive functions will result in a stack overflow.

```haskell
fac' : Int -> Int -> Int
fac' n acc = if n <= 0
             then acc
             else fac' (n - 1) (n * acc)

fac : Int -> Int
fac n = fac' n 1

-- Stack overflow
main = asText <| fac 1000000000000
```

Trampolining allows for long-running tail-recursive loops to be run without pushing calls onto the stack:
```haskell
facT : Int -> Int -> Trampoline Int
facT n acc = if n <= 0
             then Done acc
             else Continue <| \() -> facT (n - 1) (n * acc)
fac : Int -> Int
fac n = trampoline <| facT n 0

-- Doesn't stack overflow
main = asText <| fac 1000000000000
```
# Trampoline
@docs Trampoline, trampoline
 -}
import Native.Trampoline

{-| A computation that might loop. A trampoline is either the resulting value or a thunk that needs to be run more. -}
data Trampoline a = Done a
                  | Continue (() -> Trampoline a)

{-| Run a trampolining loop in constant space. -}
trampoline : Trampoline a -> a
trampoline = Native.Trampoline.trampoline


module Test where

import ElmTest.Assertion exposing (..)
import ElmTest.Test exposing (..)

tests : List Test
tests =
    [ (2^3) `equals` 1
    , 3 `equals` 3
    , defaultTest (assert True)
    , test "test head" (assertEqual 1 (Maybe.withDefault 0 (List.head [1..10])))
    ]

tests2 : List Test
tests2 =
    [ (2^3) `equals` 8
    , 3 `equals` 3
    , defaultTest (assert True)
    , test "test head" (assertEqual 1 (Maybe.withDefault 0 (List.head [1..10])))
    ]

passingTest : Test
passingTest =
    test "passing test" (assertEqual 0 0)

failingTest : Test
failingTest =
    test "failing test" (assertEqual 1 0)

suite =
    Suite "Some tests" tests2

suite2 =
    Suite
        "A Test Suite"
        [ suite
        , Suite "Some other tests" tests2
        , Suite "More tests!" tests2
        , 3 `equals` 3
        , Suite "Even more!!" tests2
        ]

suite3 =
    Suite
        "A Test Suite"
        [ suite
        , Suite "Some other tests" tests
        , Suite "More tests!" tests2
        , 3 `equals` 3
        , Suite "Even more!!" tests2
        ]

Update examples for new API

module Test where

import ElmTest exposing (..)

tests : List Test
tests =
    [ (2^3) `equals` 1
    , 3 `equals` 3
    , defaultTest (assert True)
    , test "test head" (assertEqual 1 (Maybe.withDefault 0 (List.head [1..10])))
    ]

tests2 : List Test
tests2 =
    [ (2^3) `equals` 8
    , 3 `equals` 3
    , defaultTest (assert True)
    , test "test head" (assertEqual 1 (Maybe.withDefault 0 (List.head [1..10])))
    ]

passingTest : Test
passingTest =
    test "passing test" (assertEqual 0 0)

failingTest : Test
failingTest =
    test "failing test" (assertEqual 1 0)

suite1 =
    suite "Some tests" tests2

suite2 =
    suite
        "A Test Suite"
        [ suite1
        , suite "Some other tests" tests2
        , suite "More tests!" tests2
        , 3 `equals` 3
        , suite "Even more!!" tests2
        ]

suite3 =
    suite
        "A Test Suite"
        [ suite2
        , suite "Some other tests" tests
        , suite "More tests!" tests2
        , 3 `equals` 3
        , suite "Even more!!" tests2
        ]


module Main where

import List

import ElmTest.Assertion as A
import ElmTest.Run as R
import ElmTest.Runner.Console exposing (runDisplay)
import ElmTest.Test exposing (..)

import Console exposing (..)
import Console.Runner exposing (Request, Response)

tests : List Test
tests = [ (R.run (0 `equals` 0)) `equals` (R.Pass "0 == 0")
        , test "pass" <| A.assert (R.pass <| R.Pass "")
        , test "fail" <| A.assertNotEqual (R.fail <| R.Pass "") True
        ] ++ (List.map defaultTest <| A.assertionList [1..10] [1..10])

console = runDisplay <| Suite "All Tests" tests

Update tests for new public API

module Main where

import List
import Task

import Console exposing (..)
import ElmTest exposing (..)

tests : List Test
tests =
    [ 0 `equals` 0
    , test "pass" <| assert True
    , test "fail" <| assertNotEqual True False
    ]
    ++
    (List.map defaultTest <| assertionList [1..10] [1..10])

consoleTests : IO ()
consoleTests =
    consoleRunner <| suite "All Tests" tests

port runner : Signal (Task.Task x ())
port runner =
    Console.run consoleTests


module Core.Flags exposing (Flags, Mode(..), initFlags, getVersion, getMode, isDev)

type Mode
    = HE1
    | HE2

type alias Flags =
    { apiHttpUrl : String
    , apiWsUrl : String
    , version : String
    , mode : Mode
    }

initFlags : String -> String -> String -> String -> Flags
initFlags apiHttpUrl apiWsUrl version mode =
    { apiHttpUrl = apiHttpUrl
    , apiWsUrl = apiWsUrl
    , version = version
    , mode = toMode mode
    }

getVersion : Flags -> String
getVersion =
    .version

getMode : Flags -> Mode
getMode =
    .mode

isDev : Flags -> Bool
isDev { version } =
    version == "dev"

-- internals

toMode : String -> Mode
toMode mode =
    case mode of
        "HE2" ->
            HE2

        _ ->
            HE1

Add helper function to check if Game is on HE2 Mode

module Core.Flags exposing (Flags, Mode(..), initFlags, getVersion, getMode, isDev, isHE2)

type Mode
    = HE1
    | HE2

type alias Flags =
    { apiHttpUrl : String
    , apiWsUrl : String
    , version : String
    , mode : Mode
    }

initFlags : String -> String -> String -> String -> Flags
initFlags apiHttpUrl apiWsUrl version mode =
    { apiHttpUrl = apiHttpUrl
    , apiWsUrl = apiWsUrl
    , version = version
    , mode = toMode mode
    }

getVersion : Flags -> String
getVersion =
    .version

getMode : Flags -> Mode
getMode =
    .mode

isDev : Flags -> Bool
isDev { version } =
    version == "dev"

isHE2 : Flags -> Bool
isHE2 { mode } =
    mode == HE2

-- internals

toMode : String -> Mode
toMode mode =
    case mode of
        "HE2" ->
            HE2

        _ ->
            HE1


module Main exposing (..)

import Html exposing (programWithFlags)
import Model exposing (Model)
import Data.Wallet exposing (Wallet)
import Update exposing (Msg, fetchBalance, update)
import View exposing (view)

main =
    programWithFlags { init = init, update = update, view = view, subscriptions = (\_ -> Sub.none) }

type alias Flags =
    { addresses : List String
    }

wallet : String -> Wallet
wallet address =
    Data.Wallet.wallet address True

init : Flags -> ( Model, Cmd Msg )
init { addresses } =
    ( { wallets = List.map wallet addresses, newAddress = "" }, Cmd.batch <| List.map fetchBalance addresses )

Make main module only expose main

module Main exposing (main)

import Html exposing (programWithFlags)
import Model exposing (Model)
import Data.Wallet exposing (Wallet)
import Update exposing (Msg, fetchBalance, update)
import View exposing (view)

main =
    programWithFlags { init = init, update = update, view = view, subscriptions = (\_ -> Sub.none) }

type alias Flags =
    { addresses : List String
    }

wallet : String -> Wallet
wallet address =
    Data.Wallet.wallet address True

init : Flags -> ( Model, Cmd Msg )
init { addresses } =
    ( { wallets = List.map wallet addresses, newAddress = "" }, Cmd.batch <| List.map fetchBalance addresses )


module Main exposing (..)

import Html exposing (Html, div, program, text)
import Mouse
import Keyboard

-- MODEL

type alias Model =
    Int

init : ( Model, Cmd Msg )
init =
    ( 0, Cmd.none )

-- MESSAGES

type Msg
    = MouseMsg Mouse.Position
    | KeyMsg Keyboard.KeyCode

-- VIEW

view : Model -> Html Msg
view model =
    div [] [ text (toString model) ]

update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    case msg of
        MouseMsg positionMouse ->
            ( model + 1, Cmd.none )

        KeyMsg keyCodeKeyboard ->
            ( model + 2, Cmd.none )

subscriptions : Model -> Sub Msg
subscriptions model =
    Sub.batch
        [ Mouse.downs MouseMsg
        , Keyboard.ups KeyMsg
        ]

main : Program Never Model Msg
main =
    program
        { init = init
        , view = view
        , update = update
        , subscriptions = subscriptions
        }

Implement my fisrt Cmd app

module Main exposing (..)

import Html exposing (Html, button, div, program, text)
import Html.Events exposing (onClick)
import Random

-- MODEL

type alias Model =
    Int

init : ( Model, Cmd Msg )
init =
    ( 0, Cmd.none )

-- MESSAGES

type Msg
    = Roll
    | OnResult Int

-- VIEW

view : Model -> Html Msg
view model =
    div []
        [ button [ onClick Roll ] [ text "Roll" ]
        , text (toString model)
        ]

update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    case msg of
        Roll ->
            ( model, Random.generate OnResult (Random.int 1 6) )

        OnResult res ->
            ( res, Cmd.none )

subscriptions : Model -> Sub Msg
subscriptions model =
    Sub.none

main : Program Never Model Msg
main =
    program
        { init = init
        , view = view
        , update = update
        , subscriptions = subscriptions
        }


module IdeaFight.Shuffle exposing (shuffle)

import Random exposing (Generator)

extractValueHelper : List a -> Int -> List a -> ( a, List a )
extractValueHelper values index accumulator =
    case ( index, values ) of
        ( _, [] ) ->
            Debug.crash "Out of values to extract"

        ( 0, head :: tail ) ->
            ( head, List.append (List.reverse accumulator) tail )

        ( _, head :: tail ) ->
            extractValueHelper tail (index - 1) <| head :: accumulator

extractValue : List a -> Int -> ( a, List a )
extractValue values index =
    extractValueHelper values index []

shuffle : List a -> Generator (List a)
shuffle values =
    case values of
        [] ->
            Random.map (\_ -> []) Random.bool

        values ->
            let
                randomIndexGenerator =
                    Random.int 0 <| List.length values - 1

                extractAndRecurse =
                    \index ->
                        let
                            ( randomHead, remainder ) =
                                extractValue values index

                            remainderGen =
                                shuffle remainder
                        in
                        Random.map (\randomTail -> randomHead :: randomTail) remainderGen
            in
            Random.andThen extractAndRecurse randomIndexGenerator

Rearrange types in shuffle to avoid crash

module IdeaFight.Shuffle exposing (shuffle)

import Random exposing (Generator)

extractValueHelper : a -> List a -> Int -> List a -> ( a, List a )
extractValueHelper first_value rest_values index accumulator =
    case ( index, rest_values ) of
        ( 0, _) ->
            ( first_value, List.append (List.reverse accumulator) rest_values )

        ( _, []) ->
            ( first_value, List.reverse accumulator )

        ( _, head :: tail ) ->
            extractValueHelper head tail (index - 1) <| first_value :: accumulator

extractValue : a -> List a -> Int -> ( a, List a )
extractValue first_value rest_values index =
    extractValueHelper first_value rest_values index []

shuffle : List a -> Generator (List a)
shuffle values =
    case values of
        [] ->
            Random.constant []

        (first_value :: rest_values) ->
            let
                randomIndexGenerator =
                    Random.int 0 <| List.length rest_values

                extractAndRecurse =
                    \index ->
                        let
                            ( randomHead, remainder ) =
                                extractValue first_value rest_values index

                            remainderGen =
                                shuffle remainder
                        in
                        Random.map (\randomTail -> randomHead :: randomTail) remainderGen
            in
            Random.andThen extractAndRecurse randomIndexGenerator


import Website.Message (report)

main = report [markdown|

# Try Elm

Write and compile code online! You may want to check out:

  * Code Examples
  * Learning Resources

|]

Make the try message a bit more helpful

import Website.Message (report)

main = report [markdown|

# Online Editor

Write and compile code online!

  * Hello World!
  * Images
  * Gradients

For more guidance check out:

  * Tons more examples
  * Learning resources

|]


module Main where

import Html exposing (Html)
import Html.Attributes as Attr

main : Html
main =
    Html.div
        [ Attr.class "card-panel teal lighten-2" ]
        [ Html.h2 [] [ Html.text "Hello World!" ] ]

Add basic material-based example layout w/ navbar

module Main where

import Html exposing (Html)
import Html.Attributes as Attr

main : Html
main =
    Html.div []
        [ Html.nav
            [ Attr.class "light-green darken-1" ]
            [ Html.div
                [ Attr.class "nav-wrapper container" ]
                [ Html.span
                    [ Attr.class "brand-logo" ]
                    [ Html.text "Test Scaffolder" ]
                ]
            ]
        , Html.div
            [ Attr.class "container" ]
            [ Html.div [] [ Html.text "<content here>" ] ]
        ]


-- Copyright 2015 Ian D. Bollinger
--
-- Licensed under the MIT license <LICENSE or
-- http://opensource.org/licenses/MIT>. This file may not be copied, modified,
-- or distributed except according to those terms.

import Skald exposing (..)

main =
  tale "Example"
  |> by "Ian D. Bollinger"
  |> thatBeginsIn theRoom
  |> withPlace otherRoom
  |> withCommand "think(?: about)?(?: (\\S+))?" think
  |> withCommand "throw(?: (\\S+))?" throw
  |> run

theRoom =
  place "The Room"
  |> withDescription "A nondescript room."
  |> withExit "north" "The Other Room"
  |> withObject potato

potato =
  object "potato" "An irregularly shaped potato."

otherRoom =
  place "The Other Room"
  |> withDescription "Not very creative, is it?"
  |> withExit "south" "The Room"

think args =
  case args of
    [ _ ] ->
      error "Thinking about that yields no new insight."
    _ ->
      error "When has that solved anything?"

throw args world =
  case args of
    [ name ] ->
      case getItem name world of
        Just object ->
          say ("You throw the **" ++ name ++ "** at nothing in particular.") world
            `andThen` removeFromInventory object
            `andThen` createObject object
        Nothing ->
          error "You don't have such a thing." world
    _ ->
      error "Throw what?" world

Update example to use isVisited

-- Copyright 2015 Ian D. Bollinger
--
-- Licensed under the MIT license <LICENSE or
-- http://opensource.org/licenses/MIT>. This file may not be copied, modified,
-- or distributed except according to those terms.

import Skald exposing (..)

main =
  tale "Example"
  |> by "Ian D. Bollinger"
  |> thatBeginsIn theRoom
  |> withPlace otherRoom
  |> withCommand "think(?: about)?(?: (\\S+))?" think
  |> withCommand "throw(?: (\\S+))?" throw
  |> run

theRoom =
  place "The Room"
  |> whenDescribing (\x ->
      if not (isVisited x)
      then "You see before you a nondescript room."
      else "The room was no more interesting than when you last saw it.")
  |> withExit "north" "The Other Room"
  |> withObject potato

potato =
  object "potato" "An irregularly shaped potato."

otherRoom =
  place "The Other Room"
  |> withDescription "Not very creative, is it?"
  |> withExit "south" "The Room"

think args =
  case args of
    [ _ ] ->
      error "Thinking about that yields no new insight."
    _ ->
      error "When has that solved anything?"

throw args world =
  case args of
    [ name ] ->
      case getItem name world of
        Just object ->
          say ("You throw the **" ++ name ++ "** at nothing in particular.") world
          `andThen` removeFromInventory object
          `andThen` createObject object
        Nothing ->
          error "You don't have such a thing." world
    _ ->
      error "Throw what?" world


module Elmer.Value.Native exposing
  ( global
  , cast
  , nativeType
  , assign
  , wrap
  , unwrap
  , decode
  , decoder
  , field
  , constructor
  )

import Json.Decode as Json
import Elm.Kernel.Value

constructor : Json.Decoder Int
constructor =
  Json.field "$" Json.int

field : String -> Json.Decoder a
field key =
  Json.field key decoder

decoder : Json.Decoder a
decoder =
  Json.map unwrap Json.value

decode : Json.Decoder a -> v -> Result Json.Error b
decode valueDecoder value =
  wrap value
    |> cast
    |> Json.decodeValue valueDecoder
    |> Result.mapError cast
    |> Result.map cast
    |> Result.map (\v -> unwrap v |> cast)

cast : a -> b
cast =
  Elm.Kernel.Value.cast

nativeType : a -> String
nativeType =
  Elm.Kernel.Value.nativeType

assign : String -> v -> v
assign =
  Elm.Kernel.Value.assign

global : String -> a
global =
  Elm.Kernel.Value.global

wrap : a -> v
wrap =
  Elm.Kernel.Value.wrap

unwrap : a -> v
unwrap =
  Elm.Kernel.Value.unwrap

Remove unnecessary calls to cast

module Elmer.Value.Native exposing
  ( global
  , cast
  , nativeType
  , assign
  , wrap
  , unwrap
  , decode
  , decoder
  , field
  , constructor
  )

import Json.Decode as Json
import Elm.Kernel.Value

constructor : Json.Decoder Int
constructor =
  Json.field "$" Json.int

field : String -> Json.Decoder a
field key =
  Json.field key decoder

decoder : Json.Decoder a
decoder =
  Json.map unwrap Json.value

decode : Json.Decoder a -> v -> Result Json.Error b
decode valueDecoder value =
  wrap value
    |> Json.decodeValue valueDecoder
    |> Result.map unwrap

cast : a -> b
cast =
  Elm.Kernel.Value.cast

nativeType : a -> String
nativeType =
  Elm.Kernel.Value.nativeType

assign : String -> v -> v
assign =
  Elm.Kernel.Value.assign

global : String -> a
global =
  Elm.Kernel.Value.global

wrap : a -> v
wrap =
  Elm.Kernel.Value.wrap

unwrap : a -> v
unwrap =
  Elm.Kernel.Value.unwrap


module Game where

import List exposing (sum, take)

score rolls =
  case rolls of
    [first, second, third] ->
      first + second + third
    10::rest ->
      10 + strikeBonus rest + score rest
    first::second::rest ->
      if | first + second == 10 ->
             10 + spareBonus rest + score rest
         | otherwise ->
             first + second + score rest
    [] -> 0
    [_] -> 0

bonus numRolls rolls =
  take numRolls rolls |> sum

spareBonus = bonus 1
strikeBonus = bonus 2

Use `as` pattern match on last frame

module Game where

import List exposing (sum, take)

score rolls =
  case rolls of
    [_, _, _] as lastFrame ->
      sum lastFrame
    10::rest ->
      10 + strikeBonus rest + score rest
    first::second::rest ->
      if | first + second == 10 ->
             10 + spareBonus rest + score rest
         | otherwise ->
             first + second + score rest
    [] -> 0
    [_] -> 0

bonus numRolls rolls =
  take numRolls rolls |> sum

spareBonus = bonus 1
strikeBonus = bonus 2


module Scaffolder (model, view, actions) where

import Html exposing (Html)
import Signal exposing (Signal, Mailbox, Address)
import Html.Attributes as Attr

type Action =
    NoOp

type alias Model =
    { nothing : String }

actions : Mailbox Action
actions =
    Signal.mailbox NoOp

model : Signal Model
model =
    Signal.foldp update initModel actions.signal

initModel : Model
initModel =
    { nothing = "" }

update : Action -> Model -> Model
update action model =
    case action of
        NoOp -> model

view : Address Action -> Model -> Html
view address model =
    Html.div []
        [ Html.nav
            [ Attr.class "light-green darken-1" ]
            [ Html.div
                [ Attr.class "nav-wrapper container" ]
                [ Html.span
                    [ Attr.class "brand-logo" ]
                    [ Html.text "Test Scaffolder" ]
                ]
            ]
        , Html.div
            [ Attr.class "container" ]
            [ Html.div [] [ Html.text "<content here>" ] ]
        ]

Add text areas to test parsing input

module Scaffolder (model, view, actions) where

import Html exposing (Html, div, nav, span, text, textarea, label, form)
import Html.Attributes exposing (class, id, for)
import Signal exposing (Signal, Mailbox, Address)

type Action =
    NoOp

type alias Model =
    { nothing : String }

actions : Mailbox Action
actions =
    Signal.mailbox NoOp

model : Signal Model
model =
    Signal.foldp update initModel actions.signal

initModel : Model
initModel =
    { nothing = "" }

update : Action -> Model -> Model
update action model =
    case action of
        NoOp -> model

view : Address Action -> Model -> Html
view address model =
    div []
        [ nav [ class "light-green darken-1" ]
            [ div [ class "nav-wrapper container" ]
                [ span [ class "brand-logo" ]
                    [ text "Test Scaffolder" ]
                ]
            ]
        , div [ class "container" ]
            [ div [ class "section row" ]
                [ form [ class "col s12" ]
                    [ div [ class "row" ]
                        [ div [ class "input-field col s6" ]
                            [ textarea
                                [ id "textarea1"
                                , class "materialize-textarea"
                                ] []
                            , label [ for "textarea1" ]
                                [ text "Test cases" ]
                            ]
                        , div [ class "input-field col s6" ]
                            [ textarea
                                [ id "textarea2"
                                , class "materialize-textarea"
                                ] []
                            , label [ for "textarea2" ]
                                [ text "Output" ]
                            ]
                        ]
                    ]
                ]
            ]
        ]


module User.Commands exposing (..)

import Http exposing (..)
import Json.Decode as Decode exposing (Decoder, field)
import Json.Encode as Encode
import User.Models exposing (User)
import User.Messages exposing (..)

apiUrl : String
apiUrl =
    "http://localhost:3001/"

registerUrl : String
registerUrl =
    apiUrl ++ "users"

loginUrl : String
loginUrl =
    apiUrl ++ "sessions/create"

userEncoder : User -> Encode.Value
userEncoder user =
    Encode.object
        [ ( "username", Encode.string user.username )
        , ( "password", Encode.string user.password )
        ]

authUser : User -> String -> Http.Request String
authUser user apiUrl =
    Http.request
        { method = "POST"
        , expect = Http.expectJson tokenDecoder
        , timeout = Nothing
        , withCredentials = False
        , headers = []
        , url = apiUrl
        , body = userEncoder user |> Http.jsonBody
        }

authUserCmd : User -> String -> Cmd Msg
authUserCmd user apiUrl =
    Http.send GetTokenSuccess <| authUser user apiUrl

tokenDecoder : Decoder String
tokenDecoder =
    field "id_token" Decode.string

Modify elm api url's to conform to api changes

module User.Commands exposing (..)

import Http exposing (..)
import Json.Decode as Decode exposing (Decoder, field)
import Json.Encode as Encode
import User.Models exposing (User)
import User.Messages exposing (..)

apiUrl : String
apiUrl =
    "http://localhost:3001/"

registerUrl : String
registerUrl =
    apiUrl ++ "users/create"

loginUrl : String
loginUrl =
    apiUrl ++ "users/login"

userEncoder : User -> Encode.Value
userEncoder user =
    Encode.object
        [ ( "username", Encode.string user.username )
        , ( "password", Encode.string user.password )
        ]

authUser : User -> String -> Http.Request String
authUser user apiUrl =
    Http.request
        { method = "POST"
        , expect = Http.expectJson tokenDecoder
        , timeout = Nothing
        , withCredentials = False
        , headers = []
        , url = apiUrl
        , body = userEncoder user |> Http.jsonBody
        }

authUserCmd : User -> String -> Cmd Msg
authUserCmd user apiUrl =
    Http.send GetTokenSuccess <| authUser user apiUrl

tokenDecoder : Decoder String
tokenDecoder =
    field "id_token" Decode.string


module Tests exposing (..)

import Expect
import Grains exposing (square)
import Json.Encode exposing (Value)
import Test exposing (..)

tests : Test
tests =
    describe "Grains"
        [ describe "square"
            [ test "of 1" <|
                \() -> Expect.equal (Just 1) (square 1)
            , test "of 2" <|
                \() -> Expect.equal (Just 2) (square 2)
            , test "of 3" <|
                \() -> Expect.equal (Just 4) (square 3)
            , test "of 4" <|
                \() -> Expect.equal (Just 8) (square 4)
            , test "of 16" <|
                \() -> Expect.equal (Just 32768) (square 16)
            , test "of 32" <|
                \() -> Expect.equal (Just 2147483648) (square 32)
            , test "square 0 raises an exception" <|
                \() -> Expect.equal Nothing (square 0)
            , test "negative square raises an exception" <|
                \() -> Expect.equal Nothing (square -1)
            ]
        ]

Add a note about the missing high value grains test cases

module Tests exposing (..)

import Expect
import Grains exposing (square)
import Json.Encode exposing (Value)
import Test exposing (..)

tests : Test
tests =
    describe "Grains"
        [ describe "square"
            [ test "of 1" <|
                \() -> Expect.equal (Just 1) (square 1)
            , test "of 2" <|
                \() -> Expect.equal (Just 2) (square 2)
            , test "of 3" <|
                \() -> Expect.equal (Just 4) (square 3)
            , test "of 4" <|
                \() -> Expect.equal (Just 8) (square 4)
            , test "of 16" <|
                \() -> Expect.equal (Just 32768) (square 16)
            , test "of 32" <|
                \() -> Expect.equal (Just 2147483648) (square 32)
            , test "square 0 raises an exception" <|
                \() -> Expect.equal Nothing (square 0)
            , test "negative square raises an exception" <|
                \() -> Expect.equal Nothing (square -1)
              {-
                 Where are the bigger test values?!? Because Javascript's numbers
                 can't represent values higher than `Number.MAX_SAFE_INTEGER`
                 (i.e. 9007199254740991), we chose to exclude these final values
                 to avoid the weirdness. A bit more information can be found
                 here: https://github.com/elm-lang/elm-compiler/issues/1246
              -}
            ]
        ]


module Setup.Settings exposing (..)

import Basics.Extra exposing ((=>))
import Json.Decode as Decode
import Json.Decode.Pipeline exposing (..)
import Json.Encode as Encode
import Roster.Data exposing (RosterData)

type alias Data =
    { timerDuration : Int
    , breakDuration : Int
    , intervalsPerBreak : Int
    , rosterData : RosterData
    , showHideShortcut : String
    }

decoder : Decode.Decoder Data
decoder =
    Json.Decode.Pipeline.decode Data
        |> required "timerDuration" Decode.int
        |> optional "breakDuration" Decode.int 5
        |> required "intervalsPerBreak" Decode.int
        |> required "mobsterData" Roster.Data.decoder
        |> optional "showHideShortcut" Decode.string "K"

decode : Encode.Value -> Result String Data
decode data =
    Decode.decodeValue decoder data

encoder : Data -> Encode.Value
encoder settingsData =
    Encode.object
        [ "timerDuration" => Encode.int settingsData.timerDuration
        , "breakDuration" => Encode.int settingsData.breakDuration
        , "intervalsPerBreak" => Encode.int settingsData.intervalsPerBreak
        , "mobsterData" => Roster.Data.encoder settingsData.rosterData
        , "showHideShortcut" => Encode.string settingsData.showHideShortcut
        ]

initial : Data
initial =
    { timerDuration = 5
    , breakDuration = 5
    , intervalsPerBreak = 5
    , rosterData = Roster.Data.empty
    , showHideShortcut = "K"
    }

Remove support for missing fields from very old versions of app.

module Setup.Settings exposing (..)

import Basics.Extra exposing ((=>))
import Json.Decode as Decode
import Json.Decode.Pipeline exposing (..)
import Json.Encode as Encode
import Roster.Data exposing (RosterData)

type alias Data =
    { timerDuration : Int
    , breakDuration : Int
    , intervalsPerBreak : Int
    , rosterData : RosterData
    , showHideShortcut : String
    }

decoder : Decode.Decoder Data
decoder =
    Json.Decode.Pipeline.decode Data
        |> required "timerDuration" Decode.int
        |> required "breakDuration" Decode.int
        |> required "intervalsPerBreak" Decode.int
        |> required "mobsterData" Roster.Data.decoder
        |> required "showHideShortcut" Decode.string

decode : Encode.Value -> Result String Data
decode data =
    Decode.decodeValue decoder data

encoder : Data -> Encode.Value
encoder settingsData =
    Encode.object
        [ "timerDuration" => Encode.int settingsData.timerDuration
        , "breakDuration" => Encode.int settingsData.breakDuration
        , "intervalsPerBreak" => Encode.int settingsData.intervalsPerBreak
        , "mobsterData" => Roster.Data.encoder settingsData.rosterData
        , "showHideShortcut" => Encode.string settingsData.showHideShortcut
        ]

initial : Data
initial =
    { timerDuration = 5
    , breakDuration = 5
    , intervalsPerBreak = 5
    , rosterData = Roster.Data.empty
    , showHideShortcut = "K"
    }


module Main exposing (main)

import Html
import Html.App
import Bench.Native as Benchmark
import Bench.Dict
import Bench.Array

main : Program Never
main =
    Html.App.beginnerProgram
        { model = ()
        , update = \_ _ -> ()
        , view = \() -> Html.text "Done!"
        }
        |> Benchmark.run
            [ {- Bench.Dict.tiny
                 , Bench.Dict.small
                 ,
              -}
              Bench.Dict.medium
              {- ,
                 Bench.Dict.large
                  , Bench.Array.tiny
                    , Bench.Array.small
                    , Bench.Array.medium
                    , Bench.Array.large
              -}
            ]

Revert "Lets focus on dict for a while"

module Main exposing (main)

import Html
import Html.App
import Bench.Native as Benchmark
import Bench.Dict
import Bench.Array

main : Program Never
main =
    Html.App.beginnerProgram
        { model = ()
        , update = \_ _ -> ()
        , view = \() -> Html.text "Done!"
        }
        |> Benchmark.run
            [ Bench.Dict.tiny
            , Bench.Dict.small
            , Bench.Dict.medium
            , Bench.Dict.large
            , Bench.Array.tiny
            , Bench.Array.small
            , Bench.Array.medium
            , Bench.Array.large
            ]


module Main where

import IO.IO exposing (..)
import IO.Runner exposing (Request, Response)
import IO.Runner as Run

import Test
import ElmTest.Runner.Console as Console

sigs : IO ()
sigs = Console.runDisplay Test.suite3

-- | Can't use a type alias in ports, yet :/
port requests : Signal Request
port requests = Run.run responses sigs

port responses : Signal Response

Update for new public API

module Main where

import Task

import Console exposing (..)
import ElmTest.Runner.Console as Console

import Test

tests : IO ()
tests =
    consoleRunner Test.suite3

port runner : Signal (Task.Task x ())
port runner =
    Console.run sigs


import Website.ColorScheme

accents = [accent0,accent1,accent2,accent3,accent4]

topBar k n =
    let n' = toFloat n
        k' = toFloat k
        segs = map (\i -> round (n' * toFloat i / k')) [1..k]
        ws = zipWith (-) segs (0:segs)
        accentCycle = concatMap (\_ -> accents) [ 0 .. k `div` 5 ]
    in  flow right $ zipWith (\c w -> color c $ spacer w 5) accentCycle ws

msg = [markdown|

# Try Elm

To the left is an online editor for writing and compiling
Elm code. If you
are unsure how to get started, take a look at some
examples.
|]

scene (w,h) = container w h middle (box $ width 320 msg)

box e =
  let w = widthOf e
      h = heightOf e
  in  flow down [ topBar 5 (w+40)
                , color mediumGrey . container (w+40) (h+11) midTop .
                        color lightGrey  . container (w+38) (h+10) midTop $ e
                ]

main = lift scene Window.dimensions

Switch to (:) to (::)

import Website.ColorScheme

accents = [accent0,accent1,accent2,accent3,accent4]

topBar k n =
    let n' = toFloat n
        k' = toFloat k
        segs = map (\i -> round (n' * toFloat i / k')) [1..k]
        ws = zipWith (-) segs (0::segs)
        accentCycle = concatMap (\_ -> accents) [ 0 .. k `div` 5 ]
    in  flow right $ zipWith (\c w -> color c $ spacer w 5) accentCycle ws

msg = [markdown|

# Try Elm

To the left is an online editor for writing and compiling
Elm code. If you
are unsure how to get started, take a look at some
examples.
|]

scene (w,h) = container w h middle (box $ width 320 msg)

box e =
  let w = widthOf e
      h = heightOf e
  in  flow down [ topBar 5 (w+40)
                , color mediumGrey . container (w+40) (h+11) midTop .
                        color lightGrey  . container (w+38) (h+10) midTop $ e
                ]

main = lift scene Window.dimensions


module NoSyntaxBitch where
import Html exposing (text)

type alias VariableName = String

type Node
  = Function { args: List Node, body: List Node, return: Node }
  | BinaryExpression { left: Node, right: Node, operator: String }
  | VariableDeclaration { identifier: Node, init: Node }
  | Constant Int
  | Variable VariableName
  | Nothing

fn : a -> b -> c -> { args : a, body : b, return : c }
fn args body return = { args = args, body = body, return = return }

add : { args : List Node, body : List Node, return : Node }
add = fn [Variable "a", Variable "b"]
      [ VariableDeclaration
          { identifier = Variable "sum"
          , init = BinaryExpression
                   { left = Variable "a"
                   , right = Variable "b"
                   , operator = "+"
                   }
          }
      , VariableDeclaration { identifier = Variable "number", init = Constant 56 }
      ]
      (Variable "sum")

main : Html.Html
main =
  text "Hello, World!"

Add UnaryExpression. Add OperatorName alias

module NoSyntaxBitch where
import Html exposing (text)

type alias VariableName = String
type alias OperatorName = String

type Node
  = Function { args: List Node, body: List Node, return: Node }
  | BinaryExpression { left: Node, right: Node, operator: OperatorName }
  | UnaryExpression { right: Node, operator: OperatorName }
  | VariableDeclaration { identifier: Node, init: Node }
  | Constant Int
  | Variable VariableName
  | Nothing

fn : a -> b -> c -> { args : a, body : b, return : c }
fn args body return = { args = args, body = body, return = return }

add : { args : List Node, body : List Node, return : Node }
add = fn [Variable "a", Variable "b"]
      [ VariableDeclaration
          { identifier = Variable "sum"
          , init = BinaryExpression
                   { left = Variable "a"
                   , right = Variable "b"
                   , operator = "+"
                   }
          }
      , VariableDeclaration { identifier = Variable "number", init = Constant 56 }
      ]
      (Variable "sum")

main : Html.Html
main =
  text "Hello, World!"


module Main exposing (..)

import Html
import Init
import Model exposing (Model, Controller)
import Update exposing (update)
import View exposing (view)

-- INIT

main : Program Never Model Controller
main =
    Html.program
        { init = Init.init
        , update = update
        , subscriptions = subscriptions
        , view = view
        }

-- SUBSCRIPTIONS

subscriptions : Model -> Sub Controller
subscriptions model =
    Sub.none

Use Browser instead of Html.program

module Main exposing (..)

import Browser
import Html
import Init
import Model exposing (Model, Controller)
import Update exposing (update)
import View exposing (view)

-- INIT

main : Program Never Model Controller
main =
    Browser.element
        { init = Init.init
        , update = update
        , subscriptions = subscriptions
        , view = view
        }

-- SUBSCRIPTIONS

subscriptions : Model -> Sub Controller
subscriptions model =
    Sub.none


module ReleaseNotes.ArcLengthParameterization exposing (..)

import Html exposing (Html)
import OpenSolid.CubicSpline2d as CubicSpline2d
import OpenSolid.Svg as Svg
import ReleaseNotes.Common exposing (..)
import Svg

main : Html Never
main =
    let
        parameterization =
            CubicSpline2d.arcLengthParameterized 0.5 spline

        overallArcLength =
            CubicSpline2d.arcLength parameterization

        arcLengths =
            List.range 0 numSegments
                |> List.map
                    (\n -> toFloat n * overallArcLength / toFloat numSegments)

        points =
            arcLengths
                |> List.filterMap (CubicSpline2d.pointAlong parameterization)

        pointElements =
            points |> List.map (Svg.point2d [ whiteFill, blackStroke ])
    in
    Svg.render2d renderBounds <|
        Svg.g []
            [ Svg.cubicSpline2d [ blackStroke, noFill ] spline
            , Svg.g [] pointElements
            ]

Make arc length evaluation more robust and clear

module ReleaseNotes.ArcLengthParameterization exposing (..)

import Html exposing (Html)
import OpenSolid.CubicSpline2d as CubicSpline2d
import OpenSolid.Svg as Svg
import ReleaseNotes.Common exposing (..)
import Svg

main : Html Never
main =
    let
        parameterization =
            CubicSpline2d.arcLengthParameterized 0.5 spline

        overallArcLength =
            CubicSpline2d.arcLength parameterization

        arcLengths =
            List.range 0 numSegments
                |> List.map
                    (\n ->
                        let
                            fraction =
                                toFloat n
                                    / toFloat numSegments
                        in
                        fraction * overallArcLength
                    )

        points =
            arcLengths
                |> List.filterMap (CubicSpline2d.pointAlong parameterization)

        pointElements =
            points |> List.map (Svg.point2d [ whiteFill, blackStroke ])
    in
    Svg.render2d renderBounds <|
        Svg.g []
            [ Svg.cubicSpline2d [ blackStroke, noFill ] spline
            , Svg.g [] pointElements
            ]


module Models (..) where

import Meals.Models exposing (Meal)
import Routing

type alias AppModel =
  { meals : List Meal
  , currentMeal : Maybe Meal
  , routing : Routing.Model
  }

initialModel : AppModel
initialModel =
  { meals = []
  , currentMeal = Nothing
  , routing = Routing.initialModel
  }

Add error message to app model

module Models (..) where

import Meals.Models exposing (Meal)
import Routing

type alias AppModel =
  { meals : List Meal
  , currentMeal : Maybe Meal
  , routing : Routing.Model
  , errorMessage : String
  }

initialModel : AppModel
initialModel =
  { meals = []
  , currentMeal = Nothing
  , routing = Routing.initialModel
  , errorMessage = ""
  }


module Main where

import Task

import Console exposing (..)
import ElmTest.Runner.Console as Console

import Test

tests : IO ()
tests =
    consoleRunner Test.suite3

port runner : Signal (Task.Task x ())
port runner =
    Console.run sigs

Update examples for new API

module Main where

import Task

import Console exposing (..)
import ElmTest exposing (consoleRunner)

import Test

tests : IO ()
tests =
    consoleRunner Test.suite3

port runner : Signal (Task.Task x ())
port runner =
    Console.run tests


module Silences.Decoders exposing (..)

import Json.Decode as Json exposing (field)
import Utils.Api exposing (iso8601Time, duration)
import Silences.Types exposing (Silence)
import Utils.Types exposing (Matcher, Time)

show : Json.Decoder Silence
show =
    Json.at [ "data" ] silence

list : Json.Decoder (List Silence)
list =
    Json.at [ "data" ] (Json.list silence)

create : Json.Decoder String
create =
    Json.at [ "data", "silenceId" ] Json.string

-- This should just be the ID

destroy : Json.Decoder String
destroy =
    Json.at [ "status" ] Json.string

silence : Json.Decoder Silence
silence =
    Json.map8 Silence
        (field "id" Json.string)
        (field "createdBy" Json.string)
        (field "comment" Json.string)
        (field "startsAt" iso8601Time)
        (field "endsAt" iso8601Time)
        (duration "startsAt" "endsAt")
        (field "updatedAt" iso8601Time)
        (field "matchers" (Json.list matcher))

matcher : Json.Decoder Matcher
matcher =
    Json.map3 Matcher
        (field "name" Json.string)
        (field "value" Json.string)
        (field "isRegex" Json.bool)

Update silence decoders for empty comment

module Silences.Decoders exposing (..)

import Json.Decode as Json exposing (field)
import Utils.Api exposing (iso8601Time, duration)
import Silences.Types exposing (Silence)
import Utils.Types exposing (Matcher, Time)

show : Json.Decoder Silence
show =
    Json.at [ "data" ] silence

list : Json.Decoder (List Silence)
list =
    Json.at [ "data" ] (Json.list silence)

create : Json.Decoder String
create =
    Json.at [ "data", "silenceId" ] Json.string

-- This should just be the ID

destroy : Json.Decoder String
destroy =
    Json.at [ "status" ] Json.string

silence : Json.Decoder Silence
silence =
    Json.map8 Silence
        (field "id" Json.string)
        (field "createdBy" Json.string)
        -- Remove this maybe once the api either disallows empty comments on
        -- creation, or returns an empty string.
        ((Json.maybe (field "comment" Json.string))
            |> Json.andThen (\x -> Json.succeed <| Maybe.withDefault "" x)
        )
        (field "startsAt" iso8601Time)
        (field "endsAt" iso8601Time)
        (duration "startsAt" "endsAt")
        (field "updatedAt" iso8601Time)
        (field "matchers" (Json.list matcher))

matcher : Json.Decoder Matcher
matcher =
    Json.map3 Matcher
        (field "name" Json.string)
        (field "value" Json.string)
        (field "isRegex" Json.bool)


module Data.Currency exposing (Currency(Bitcoin, Litecoin, Decred, EthereumClassic), currency)

type Currency
    = Bitcoin
    | Litecoin
    | Decred
    | EthereumClassic

currency : String -> Currency
currency address =
    let
        prefix =
            String.left 1 address
    in
        if prefix == "L" then
            Litecoin
        else if prefix == "D" then
            Decred
        else if prefix == "0" then
            EthereumClassic
        else
            Bitcoin

Make currency module expose everything since no private stuff

module Data.Currency exposing (..)

type Currency
    = Bitcoin
    | Litecoin
    | Decred
    | EthereumClassic

currency : String -> Currency
currency address =
    let
        prefix =
            String.left 1 address
    in
        if prefix == "L" then
            Litecoin
        else if prefix == "D" then
            Decred
        else if prefix == "0" then
            EthereumClassic
        else
            Bitcoin


{-
This is a "stub" file.  It's a little start on your solution. It's not a
complete solution though; you have to write some code.

The module name is expected by the test program and must match the name of this
file. It has to stay just the way it is.
-}

module HelloWorld exposing (..)

-- It's good style to include a types at the top level of your modules.

helloWorld : Maybe String -> String
helloWorld name =
  "replace with your code!"

{-
When you have a working solution, REMOVE ALL THE STOCK COMMENTS.
They're here to help you get started but they only clutter a finished solution.
If you leave them in, nitpickers will protest!
-}

Replace a word in one of the guiding comments for clarity

{-
This is a "stub" file.  It's a little start on your solution. It's not a
complete solution though; you have to write some code.

The module name is expected by the test program and must match the name of this
file. It has to stay just the way it is.
-}

module HelloWorld exposing (..)

-- It's good style to include any types at the top level of your modules.

helloWorld : Maybe String -> String
helloWorld name =
  "replace with your code!"

{-
When you have a working solution, REMOVE ALL THE STOCK COMMENTS.
They're here to help you get started but they only clutter a finished solution.
If you leave them in, nitpickers will protest!
-}


import Html
import Html (..)
import Window

counter : Float -> Html
counter count =
    node "div" []
        [ "textAlign"     := "center"
        , "verticalAlign" := "center"
        , "lineHeight"    := px (100 + count)
        , "border"        := "1px solid red"
        , "width"         := px (100 + count)
        , "height"        := px (100 + count)
        ]
        [ text (show count) ]

scene : Int -> (Int,Int) -> Element
scene count (w,h) =
    Html.toElement w h (counter (toFloat count))

main = scene <~ count (every second) ~ Window.dimensions

Update for the new API

import Html (..)
import Html.Tags (..)
import Window

counter : Int -> Html
counter count =
    let px = show (count + 100) ++ "px" in
    div [ style
            [ prop "textAlign"     "center"
            , prop "verticalAlign" "center"
            , prop "lineHeight"    px
            , prop "border"        "1px solid red"
            , prop "width"         px
            , prop "height"        px
            ]
        ]
        [ text (show count) ]

scene : Int -> (Int,Int) -> Element
scene count (w,h) =
    toElement w h (counter count)

main = scene <~ count (every second) ~ Window.dimensions


module App.Entries.State exposing (..)

import App.Entries.Types exposing (..)
import App.Control.Types exposing (Filter(..))

-- INIT

initialModel : Model
initialModel =
    { list =
        [ Entry -1 "First Entry" False
        , Entry -2 "Second Entry" True
        ]
    , filter = All
    , currentId = 0
    }

init : ( Model, Cmd Msg )
init =
    initialModel ! []

-- UPDATE

updateModel : Msg -> Model -> Model
updateModel msg model =
    case msg of

        AddEntry text ->
            { model | list = List.append model.list [ Entry model.currentId text False ] }

        RemoveEntry id ->
            { model | list = List.filter (\entry -> not <| entry.id == id) model.list }

        ToggleComplete id ->
                    { model | list = toggleComplete id model.list }

        ApplyFilter filter ->
            { model | filter = filter }

toggleComplete : Int -> List Entry -> List Entry
toggleComplete id list =
    List.map (updateEntry id) list

updateEntry : Int -> (Entry -> Entry)
updateEntry id =
    \entry ->
        if entry.id == id then
            { entry | complete = not entry.complete }
        else
            entry

Update Entries currentId on AddEntry

module App.Entries.State exposing (..)

import App.Entries.Types exposing (..)
import App.Control.Types exposing (Filter(..))

-- INIT

initialModel : Model
initialModel =
    { list = []
    , filter = All
    , currentId = 0
    }

init : ( Model, Cmd Msg )
init =
    initialModel ! []

-- UPDATE

updateModel : Msg -> Model -> Model
updateModel msg model =
    case msg of

        AddEntry text ->
            { model
                | list = List.append model.list [ Entry model.currentId text False ]
                , currentId = model.currentId + 1
            }

        RemoveEntry id ->
            { model | list = List.filter (\entry -> not <| entry.id == id) model.list }

        ToggleComplete id ->
            { model | list = toggleComplete id model.list }

        ApplyFilter filter ->
            { model | filter = filter }

toggleComplete : Int -> List Entry -> List Entry
toggleComplete id list =
    List.map (updateEntry id) list

updateEntry : Int -> (Entry -> Entry)
updateEntry id =
    \entry ->
        if entry.id == id then
            { entry | complete = not entry.complete }
        else
            entry


module ChapterEditApp.Models exposing (..)

import Json.Encode
import Json.Decode
import Common.Models exposing (FullCharacter, Character, Narration, Chapter, Banner)

newEmptyChapter : Narration -> Chapter
newEmptyChapter narration =
    { id = 0
    , narrationId = narration.id
    , title = ""
    , audio = narration.defaultAudio
    , backgroundImage = narration.defaultBackgroundImage
    , text = Json.Encode.list []
    , participants = narration.characters
    , published = Nothing
    }

type alias LastReactionChapter =
    { id : Int
    , title : String
    }

type alias LastChapter =
    { id : Int
    , title : String
    , text : Json.Decode.Value
    }

type alias LastReaction =
    { chapterInfo : LastReactionChapter
    , character : Character
    , text : Maybe String
    }

type alias LastReactions =
    { chapterId : Int
    , reactions : List LastReaction
    , chapters : List LastChapter
    }

type alias Model =
    { chapter : Maybe Chapter
    , narration : Maybe Narration
    , lastReactions : Maybe LastReactions
    , banner : Maybe Banner
    , flash : Maybe Banner
    , showPublishChapterDialog : Bool
    , uploadingAudio : Bool
    , uploadingBackgroundImage : Bool
    }

Fix structure of empty chapters

module ChapterEditApp.Models exposing (..)

import Json.Encode
import Json.Decode
import Common.Models exposing (FullCharacter, Character, Narration, Chapter, Banner)

newEmptyChapter : Narration -> Chapter
newEmptyChapter narration =
    { id = 0
    , narrationId = narration.id
    , title = ""
    , audio = narration.defaultAudio
    , backgroundImage = narration.defaultBackgroundImage
    , text = Json.Encode.object [ ("type", Json.Encode.string "doc")
                                , ("content", Json.Encode.list [])
                                ]
    , participants = narration.characters
    , published = Nothing
    }

type alias LastReactionChapter =
    { id : Int
    , title : String
    }

type alias LastChapter =
    { id : Int
    , title : String
    , text : Json.Decode.Value
    }

type alias LastReaction =
    { chapterInfo : LastReactionChapter
    , character : Character
    , text : Maybe String
    }

type alias LastReactions =
    { chapterId : Int
    , reactions : List LastReaction
    , chapters : List LastChapter
    }

type alias Model =
    { chapter : Maybe Chapter
    , narration : Maybe Narration
    , lastReactions : Maybe LastReactions
    , banner : Maybe Banner
    , flash : Maybe Banner
    , showPublishChapterDialog : Bool
    , uploadingAudio : Bool
    , uploadingBackgroundImage : Bool
    }


module Toolbox.Update exposing (..)

import Dict
import Http
import Set
import Toolbox.Types exposing (Model, IngredientID, Response)

type Msg
    = DownloadedIngredients Response
    | DownloadFailed Http.Error
    | SelectIngredient IngredientID
    | NoOp

update : Msg -> Model -> ( Model, Cmd Msg )
update action model =
    case action of
        DownloadedIngredients maybeResponse ->
            ( responseToModel model maybeResponse
            , Cmd.none
            )

        -- TODO: handle HTTP errors
        DownloadFailed _ ->
            ( model, Cmd.none )

        SelectIngredient id ->
            ( { model | selectedIds = updateIds id model.selectedIds }
            , Cmd.none
            )

        NoOp ->
            ( model, Cmd.none )

updateIds : IngredientID -> Set.Set IngredientID -> Set.Set IngredientID
updateIds id selectedIds =
    if Set.member id selectedIds then
        Set.remove id selectedIds
    else if Set.size selectedIds < 3 then
        Set.insert id selectedIds
    else
        selectedIds

enumerate : List a -> List ( Int, a )
enumerate list =
    let
        ids =
            [1..(List.length list - 1)]
    in
        List.map2 (,) ids list

responseToModel : Model -> Response -> Model
responseToModel model response =
    { model | ingredients = enumerate response.ingredients |> Dict.fromList }

Use ! [] for empty Cmd in update.

module Toolbox.Update exposing (..)

import Dict
import Http
import Set
import Toolbox.Types exposing (Model, IngredientID, Response)

type Msg
    = DownloadedIngredients Response
    | DownloadFailed Http.Error
    | SelectIngredient IngredientID
    | NoOp

update : Msg -> Model -> ( Model, Cmd Msg )
update action model =
    case action of
        DownloadedIngredients maybeResponse ->
            responseToModel model maybeResponse ! []

        -- TODO: handle HTTP errors
        DownloadFailed _ ->
            model ! []

        SelectIngredient id ->
            { model | selectedIds = updateIds id model.selectedIds } ! []

        NoOp ->
            model ! []

updateIds : IngredientID -> Set.Set IngredientID -> Set.Set IngredientID
updateIds id selectedIds =
    if Set.member id selectedIds then
        Set.remove id selectedIds
    else if Set.size selectedIds < 3 then
        Set.insert id selectedIds
    else
        selectedIds

enumerate : List a -> List ( Int, a )
enumerate list =
    let
        ids =
            [1..(List.length list - 1)]
    in
        List.map2 (,) ids list

responseToModel : Model -> Response -> Model
responseToModel model response =
    { model | ingredients = enumerate response.ingredients |> Dict.fromList }


module Common.Views.Reading exposing (..)

import Html
import Html.Attributes exposing (style)

import Common.Models.Reading exposing (PageState(..))

backgroundImageStyle : Int -> Maybe String -> Int -> List (Html.Attribute msg)
backgroundImageStyle narrationId maybeBgImage backgroundBlurriness =
  let
    imageUrl =
      case maybeBgImage of
        Just backgroundImage ->
          "/static/narrations/" ++
            String.fromInt narrationId ++
            "/background-images/" ++
            backgroundImage

        Nothing ->
          "#"
    filter = "blur(" ++ (String.fromInt backgroundBlurriness) ++ "px)"
  in
    [ style "background-image" <| "url(" ++ imageUrl ++ ")"
    , style "-webkit-filter" filter
    , style "-moz-filter" filter
    , style "filter" filter
    ]

chapterContainerClass : PageState -> String
chapterContainerClass state =
  case state of
    Loader -> "invisible transparent"
    StartingNarration -> "transparent"
    Narrating -> "fade-in"

Fix background images with spaces in them

module Common.Views.Reading exposing (..)

import Html
import Html.Attributes exposing (style)

import Common.Models.Reading exposing (PageState(..))

backgroundImageStyle : Int -> Maybe String -> Int -> List (Html.Attribute msg)
backgroundImageStyle narrationId maybeBgImage backgroundBlurriness =
  let
    imageUrl =
      case maybeBgImage of
        Just backgroundImage ->
          "/static/narrations/" ++
            String.fromInt narrationId ++
            "/background-images/" ++
            backgroundImage

        Nothing ->
          "#"
    filter = "blur(" ++ (String.fromInt backgroundBlurriness) ++ "px)"
  in
    [ style "background-image" <| "url('" ++ imageUrl ++ "')"
    , style "-webkit-filter" filter
    , style "-moz-filter" filter
    , style "filter" filter
    ]

chapterContainerClass : PageState -> String
chapterContainerClass state =
  case state of
    Loader -> "invisible transparent"
    StartingNarration -> "transparent"
    Narrating -> "fade-in"


module HomepageView exposing (..)

import Html exposing (..)
import Html.CssHelpers exposing (..)
import Html.Attributes exposing (..)
import HomepageCss exposing (..)
import Json.Encode as Encode
import SharedStyles exposing (..)

{ id, class, classList } =
    homepageNamespace
main : Html
main =
    div []
        [ header []
            [ img [ id ReactiveLogo, src "assets/logo.png" ] []
            , nav []
                navElems
            , span [ id BuyTickets ]
                [ text "BUY TICKETS" ]
            ]
        , div []
            [ img [ src "assets/banner.png" ] [] ]
        ]

navElems =
    [ "SPEAKERS", "SCHEDULE", "WORKSHOPS", "VENUE", "BLOG", "CONTACT" ]
        |> List.map (\name -> span [ class [ NavLink ] ] [ text name ])

Fix example by adding missing argument to Html

module HomepageView exposing (..)

import Html exposing (..)
import Html.CssHelpers exposing (..)
import Html.Attributes exposing (..)
import HomepageCss exposing (..)
import Json.Encode as Encode
import SharedStyles exposing (..)

{ id, class, classList } =
    homepageNamespace
main : Html a
main =
    div []
        [ header []
            [ img [ id ReactiveLogo, src "assets/logo.png" ] []
            , nav []
                navElems
            , span [ id BuyTickets ]
                [ text "BUY TICKETS" ]
            ]
        , div []
            [ img [ src "assets/banner.png" ] [] ]
        ]

navElems =
    [ "SPEAKERS", "SCHEDULE", "WORKSHOPS", "VENUE", "BLOG", "CONTACT" ]
        |> List.map (\name -> span [ class [ NavLink ] ] [ text name ])


module TM exposing (..)

import Html exposing (text)

main: Html.Html msg
main =
    text "Hello, World!"

-- Model

type alias Model =
    {
      tm: TuringMachine Int String
    , running: Bool
    }

type alias TuringMachine states symbols =
    {
      tape: Tape symbols
    , state: states
    , transitions: Transitions states symbols
    }

type alias Tape symbols =
    {
      left: List symbols
    , head: symbols
    , right: List symbols
    }

type alias Transitions states symbols =
    List (Transition states symbols)

type alias Transition states symbols =
    {
      current: (states, symbols)
    , next: (states, symbols, Move)
    }

type Move =
      Left
    | Right

Create a lookup function for a transition

module TM exposing (..)

import Html exposing (text)
import List exposing (head, tail)

main: Html.Html msg
main =
    text "Hello, World!"

-- Model

type alias Model =
    {
      tm: TuringMachine Int String
    , running: Bool
    }

type alias TuringMachine states symbols =
    {
      tape: Tape symbols
    , state: states
    , transitions: Transitions states symbols
    }

type alias Tape symbols =
    {
      left: List symbols
    , head: symbols
    , right: List symbols
    }

type alias Transitions states symbols =
    List (Transition states symbols)

type alias Transition states symbols =
    {
      current: (states, symbols)
    , next: (states, symbols, Move)
    }

type Move =
      Left
    | Right

lookup: Transitions states symbols -> (states, symbols) -> Maybe (states, symbols, Move)
lookup transitions current =
    case head transitions of
        Just transition ->
            if transition.current == current then
                Just transition.next
            else
                case tail transitions of
                    Just ts -> lookup ts current

                    Nothing -> Nothing

        Nothing -> Nothing


module Main exposing (..)

import Model exposing (..)
import Update exposing (Msg, update)
import View exposing (view)
import Html.App as Html
import Date.Extra.Create exposing (dateFromFields)
import Date exposing (..)

main : Program Never
main =
    Html.program
        { init = init
        , update = update
        , view = view
        , subscriptions = (always Sub.none)
        }

init : ( Model, Cmd Msg )
init =
    ( initialModel
    , Cmd.batch
        [ Update.currentTime
        , Update.getUser
        , Update.getEntries
        , Update.getHolidays
        , Update.getAbsenceTasks
        ]
    )

initialModel : Model
initialModel =
    { httpError = Ok ()
    , loading = True
    , today = Date.Extra.Create.dateFromFields 2016 Date.Jan 1 1 1 1 1
    , currentDate = Date.Extra.Create.dateFromFields 2016 Date.Jan 1 1 1 1 1
    , entries = []
    , totalHours = 0
    , user = { firstName = "", lastName = "" }
    , holidays = []
    , absenceTasks = []
    }

Use 0 msecs as initial date.

module Main exposing (..)

import Model exposing (..)
import Update exposing (Msg, update)
import View exposing (view)
import Html.App as Html
import Date exposing (..)

main : Program Never
main =
    Html.program
        { init = init
        , update = update
        , view = view
        , subscriptions = (always Sub.none)
        }

init : ( Model, Cmd Msg )
init =
    ( initialModel
    , Cmd.batch
        [ Update.currentTime
        , Update.getUser
        , Update.getEntries
        , Update.getHolidays
        , Update.getAbsenceTasks
        ]
    )

initialModel : Model
initialModel =
    { httpError = Ok ()
    , loading = True
    , today = Date.fromTime 0
    , currentDate = Date.fromTime 0
    , entries = []
    , totalHours = 0
    , user = { firstName = "", lastName = "" }
    , holidays = []
    , absenceTasks = []
    }


import Time exposing (Time,second)
import Html exposing (Html,text)
import Set exposing (Set)

-- Model
type alias Coordinate = (Int, Int)

type alias Model =
    { alive : Set Coordinate
    , width : Int
    , height : Int}

init : (Model, Cmd Msg)
init =
    ({alive = Set.empty
    , width = 10
    , height = 10}, Cmd.none)

-- Messages
type Msg
    = Tick Time

-- View
view : Model -> Html Msg
view matrix = text "banana"

-- Update
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
    case msg of
        Tick _ -> (model, Cmd.none)

-- Subscriptions
subscriptions : Model -> Sub Msg
subscriptions model =
    Time.every second Tick

-- Main
main : Program Never Model Msg
main =
    Html.program
        { init = init
        , view = view
        , update = update
        , subscriptions = subscriptions
        }

Change initial model creation to randomly generate points

import Time exposing (Time,second)
import Html exposing (Html,text)
import Set exposing (Set)
import Random

-- Model
type alias Coordinate = (Int, Int)

type alias Model =
    { alive : Set Coordinate
    , width : Int
    , height : Int}

init : (Model, Cmd Msg)
init =
  let
      width = 10
      widthCoordinateGenerator = Random.int 0 <| width - 1
      height = 10
      heightCoordinateGenerator = Random.int 0 <| height - 1
      locationGenerator = Random.pair widthCoordinateGenerator heightCoordinateGenerator
      listGenerator = Random.list (width * height // 2) locationGenerator
  in
    ({alive = Set.empty
    , width = width
    , height = height}, Random.generate Genesis listGenerator)

-- Messages
type Msg
    = Tick Time
    | Genesis (List(Coordinate))

-- View
view : Model -> Html Msg
view matrix = text "banana"

-- Update
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
    case msg of
        Tick _ -> (model, Cmd.none)
        Genesis points ->
          ( { model | alive = Set.fromList points }
          , Cmd.none)

-- Subscriptions
subscriptions : Model -> Sub Msg
subscriptions model =
    Time.every second Tick

-- Main
main : Program Never Model Msg
main =
    Html.program
        { init = init
        , view = view
        , update = update
        , subscriptions = subscriptions
        }


module Component.View exposing (view)

import Component.Model exposing (..)
import Component.Messages exposing (..)
import Html exposing (Html, div, text, a)
import Html.Attributes exposing (class, href)
import Nav.Nav exposing (toHash)
import Nav.Model exposing (Page(..))

statusIcon : Status -> String
statusIcon status =
    "component__status "
        ++ case status of
            Info ->
                ""

            Warn ->
                "icon-exclamation"

            Error ->
                "icon-fire"

url : Model -> String
url model =
    toHash <| Component model.environment model.system model.component model.server

view : Model -> Html Msg
view model =
    a [ href <| url model, class "component" ]
        [ div [ class <| statusIcon model.status ] []
        , div [ class "component__name" ]
            [ text model.component ]
        , div [ class "component__server" ]
            [ text model.server ]
        ]

Add INFO icon to view as well

module Component.View exposing (view)

import Component.Model exposing (..)
import Component.Messages exposing (..)
import Html exposing (Html, div, text, a)
import Html.Attributes exposing (class, href)
import Nav.Nav exposing (toHash)
import Nav.Model exposing (Page(..))

statusIcon : Status -> String
statusIcon status =
    "component__status "
        ++ case status of
            Info ->
                "icon-like"

            Warn ->
                "icon-exclamation"

            Error ->
                "icon-fire"

url : Model -> String
url model =
    toHash <| Component model.environment model.system model.component model.server

view : Model -> Html Msg
view model =
    a [ href <| url model, class "component" ]
        [ div [ class <| statusIcon model.status ] []
        , div [ class "component__name" ]
            [ text model.component ]
        , div [ class "component__server" ]
            [ text model.server ]
        ]


module Website.Message (report) where

import Website.ColorScheme (..)
import Window

accents = [accent0,accent1,accent2,accent3,accent4]

topBar k n =
    let n' = toFloat n
        k' = toFloat k
        segs = map (\i -> round (n' * toFloat i / k')) [1..k]
        ws = zipWith (-) segs (0::segs)
        accentCycle = concatMap (\_ -> accents) [ 0 .. k `div` 5 ]
    in  flow right <| zipWith (\c w -> color c <| spacer w 5) accentCycle ws

scene msg (w,h) = layers [ tiledImage w h "/texture.png"
                         , container w h middle (box <| width 300 msg)
                         ]

box e =
  let w = widthOf e
      h = heightOf e
  in  flow down [ topBar 5 (w+40)
                , color mediumGrey . container (w+40) (h+11) midTop .
                        color lightGrey  . container (w+38) (h+10) midTop <| e
                ]

report msg = scene msg <~ Window.dimensions

Fix links to examples and learn page

module Website.Message (report) where

import Website.ColorScheme (..)
import Window

accents = [accent0,accent1,accent2,accent3,accent4]

topBar k n =
    let n' = toFloat n
        k' = toFloat k
        segs = map (\i -> round (n' * toFloat i / k')) [1..k]
        ws = zipWith (-) segs (0::segs)
        accentCycle = concatMap (\_ -> accents) [ 0 .. k `div` 5 ]
    in  flow right <| zipWith (\c w -> color c <| spacer w 5) accentCycle ws

scene msg (w,h) =
    color mediumGrey <| container w h middle (box <| width 300 msg)

box e =
  let w = widthOf e
      h = heightOf e
  in  flow down [ topBar 5 (w+40)
                , color mediumGrey . container (w+40) (h+11) midTop .
                        color lightGrey  . container (w+38) (h+10) midTop <| e
                ]

report msg = scene msg <~ Window.dimensions


module Toolbox.Views (..) where

import Html exposing (..)
import Html.Attributes exposing (..)
import Toolbox.Action exposing (Action)
import Toolbox.Types exposing (Ingredient, Model)

view : Signal.Address Action -> Model -> Html
view address model =
  case model.response of
    Just r ->
      div
        [ class "container" ]
        [ div
            [ class "row" ]
            [ div
                [ class "col-sm-4" ]
                [ div
                    [ class "card" ]
                    [ div
                        [ class "card-block" ]
                        [ h4 [ class "card-title" ] [ text "Ingredients" ] ]
                    , div
                        [ class "list-group list-group-flush" ]
                        (List.map ingredientItem r.ingredients)
                    ]
                ]
            , div
                [ class "col-sm-8" ]
                [ h2 [] [ text "Recipe (TODO)" ] ]
            ]
        ]

    Nothing ->
      div
        [ class "alert alert-info" ]
        [ text "Please wait..." ]

ingredientItem : Ingredient -> Html
ingredientItem i =
  a
    [ class "list-group-item", href "#" ]
    [ img [ src i.image, width 32, height 32 ] []
    , text i.name
    ]

Disable event propagation and send NoOp action on click.

module Toolbox.Views (..) where

import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Json.Decode
import Toolbox.Action exposing (Action(..))
import Toolbox.Types exposing (Ingredient, Model)

view : Signal.Address Action -> Model -> Html
view address model =
  case model.response of
    Just r ->
      div
        [ class "container" ]
        [ div
            [ class "row" ]
            [ div
                [ class "col-sm-4" ]
                [ div
                    [ class "card" ]
                    [ div
                        [ class "card-block" ]
                        [ h4 [ class "card-title" ] [ text "Ingredients" ] ]
                    , div
                        [ class "list-group list-group-flush" ]
                        (List.map (ingredientItem address) r.ingredients)
                    ]
                ]
            , div
                [ class "col-sm-8" ]
                [ h2 [] [ text "Recipe (TODO)" ] ]
            ]
        ]

    Nothing ->
      div
        [ class "alert alert-info" ]
        [ text "Please wait..." ]

ingredientItem : Signal.Address Action -> Ingredient -> Html
ingredientItem address i =
  a
    [ class "list-group-item", href "#", clickHandler address NoOp ]
    [ img [ src i.image, width 32, height 32 ] []
    , text i.name
    ]

clickHandler address action =
  onWithOptions
    "click"
    { stopPropagation = True, preventDefault = True }
    Json.Decode.value
    (\_ -> Signal.message address action)


module Rogue.View where

import Color exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import String exposing (join)
import Text
import Array exposing (..)

import Rogue.Model exposing (..)

view : Game -> Element
view g = leftAligned (Text.monospace (Text.fromString (toString g.gameMap)))

toString : GameMap -> String
toString {board,start,currentPlayerLocation} =
  let
    rowifier =
      (\row ->
        Array.map
          (\cell ->
            if  | isAt currentPlayerLocation cell -> "@"
                | not <| isOpen cell -> "#"
                | otherwise -> "."
          )
          row
        |> toList
        |> join ""
      )
  in
    Array.map rowifier board
      |> toList
      |> join "\n"

Change view code to use elements

module Rogue.View where

import Color exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import String exposing (join)
import Text
import Array exposing (..)

import Rogue.Model exposing (..)

view : Game -> Element
view g = viewGameMap g.gameMap

viewGameMap : GameMap -> Element
viewGameMap {board,start,currentPlayerLocation} =
  let
    rowifier =
      (\row ->
        Array.map
          (\cell ->
            if  | isAt currentPlayerLocation cell -> person
                | not <| isOpen cell -> barrier
                | otherwise -> open
          )
          row
        |> toList
        |> flow right
      )
  in
    Array.map rowifier board
      |> toList
      |> flow down

txt str =
  Text.fromString str
  |> Text.monospace
  |> centered

person =
  txt "@"
  |> standardize

barrier =
  square 16
  |> filled red
  |> (\sq -> collage 16 16 [sq])
  |> standardize

open =
  txt "."
  |> standardize

standardize : Element -> Element
standardize el =
  el
  |> container 16 16 middle

--toString  =
--  let
--    rowifier =
--      (\row ->
--        Array.map
--          (\cell ->
--            if  | isAt currentPlayerLocation cell -> "@"
--                | not <| isOpen cell -> "#"
--                | otherwise -> "."
--          )
--          row
--        |> toList
--        |> join ""
--      )
--  in
--    Array.map rowifier board
--      |> toList
--      |> join "\n"


module App.Input.View exposing (..)

import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
import Utility.OnEnter exposing (onEnter)

import App.Types as App
import App.Input.Types as Input
import App.List.Types as List

view : Input.Model -> Html App.Msg
view model =
    div []
        [ input
            [ type_ "text"
            , placeholder "Type and enter stuff"
            --, onInput App.MsgForInput <| UpdateInput model.text
            , onEnter App.NoOp <| App.MsgForList <| List.AddEntry (List.Entry 0 "New Entry" False)
            ]
            []
        ]

Refactor add new entries into createAddEntryMsg function

module App.Input.View exposing (..)

import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
import Utility.OnEnter exposing (onEnter)

import App.Types as App
import App.Input.Types as Input
import App.List.Types as List

view : Input.Model -> Html App.Msg
view model =
    div []
        [ input
            [ type_ "text"
            , placeholder "Type and enter stuff"
            --, onInput App.MsgForInput <| UpdateInput model.text
            , onEnter App.NoOp (createAddEntryMsg model)
            ]
            []
        ]

createAddEntryMsg : Input.Model -> App.Msg
createAddEntryMsg model =
    List.Entry 0 model.text False
        |> List.AddEntry
        |> App.MsgForList


module Timer.Styles exposing (StyleElement, Styles(..), styleSheet)

import Color
import Element exposing (Element)
import Style
import Style.Color
import Style.Font
import Timer.Msg exposing (Msg)

type alias StyleElement =
    Element Styles Never Msg

type Styles
    = None
    | Timer
    | MobsterName
    | BreakIcon

styleSheet : Style.StyleSheet Styles Never
styleSheet =
    Style.styleSheet
        [ Style.style None
            [ [ "Lato" ]
                |> List.map Style.Font.font
                |> Style.Font.typeface
            ]
        , Style.style Timer
            [ Style.Font.size 39
            ]
        , Style.style MobsterName
            [ Style.Font.size 15
            ]
        , Style.style BreakIcon
            [ Style.Font.size 50
            , Color.rgb 8 226 108 |> Style.Color.text
            ]
        ]

Add fallback font for timer styles.

module Timer.Styles exposing (StyleElement, Styles(..), styleSheet)

import Color
import Element exposing (Element)
import Style exposing (Font)
import Style.Color
import Style.Font as Font
import Timer.Msg exposing (Msg)

type alias StyleElement =
    Element Styles Never Msg

type Styles
    = None
    | Timer
    | MobsterName
    | BreakIcon

font : List Style.Font
font =
    [ "Lato", "Helvetica Neue", "helvetica", "arial", "sans-serif" ] |> List.map Font.font

styleSheet : Style.StyleSheet Styles Never
styleSheet =
    Style.styleSheet
        [ Style.style None
            [ Font.typeface font
            ]
        , Style.style Timer
            [ Font.size 39
            ]
        , Style.style MobsterName
            [ Font.size 15
            ]
        , Style.style BreakIcon
            [ Font.size 50
            , Color.rgb 8 226 108 |> Style.Color.text
            ]
        ]


module Intro exposing (banner)

import Html exposing (Html, div, text)
import Html.Attributes as Attr exposing (class)

banner : Html Never
banner =
    div [ class "intro" ]
        [ text "Hello, Intro!"
        , inlineScript "require([\"intro\"]);"
        ]

-- UTILITIES

inlineScript : String -> Html Never
inlineScript js =
    Html.node "citatsmle-script" [] [ Html.text js ]

Remove JavaScript intro placeholder for now

module Intro exposing (banner)

import Html exposing (Html, div, text)
import Html.Attributes as Attr exposing (class)

banner : Html Never
banner =
    text ""
    --div [ class "intro" ]
    --    [ text "Hello, Intro!"
    --    , inlineScript "require([\"intro\"]);"
    --    ]

-- UTILITIES

inlineScript : String -> Html Never
inlineScript js =
    Html.node "citatsmle-script" [] [ Html.text js ]


module Routing.App exposing (..)

import App.Model exposing (App)
import App.Msg as App exposing (Msg)
import Navigation

urlParser : Navigation.Parser String
urlParser =
    Navigation.makeParser (\location -> "/")

mapUrl : String -> App -> ( App, Cmd App.Msg )
mapUrl uri model =
    ( model, Cmd.none )

Set default route and redirect when not matched.

module Routing.App exposing (..)

import App.Model exposing (App)
import App.Msg as App exposing (Msg)
import Navigation

{-
   Custom URL Parser

   Transforms location to something Application's init and urlUpdate functions understand, e.g. "/app", 0 or even AppHome
   Sample Scenario:

     Given location "localhost/index#/app"
     When parsed by a customly defined parser
     Then can be turned into "/app"
-}

urlParser : Navigation.Parser String
urlParser =
    Navigation.makeParser (\location -> location.hash)

mapUrl : String -> App -> ( App, Cmd App.Msg )
mapUrl uri model =
    case uri of
        "#/" ->
            ( model, Cmd.none )

        _ ->
            ( model, Navigation.modifyUrl ("#/") )


module Main exposing (..)

import Html exposing (Html, div, input, span, text)
import Html.Attributes as H exposing (..)
import Html.Events exposing (onInput)

--  MAIN

main : Program Never { value : String } Msg
main =
    Html.beginnerProgram
        { model = { value = "20" }
        , view = view
        , update = update
        }

-- MODEL

type alias Model =
    { value : String
    }

-- UPDATE

type Msg
    = SlideTemperature String

update : Msg -> Model -> Model
update msg model =
    case msg of
        SlideTemperature temperature ->
            { model | value = temperature }

-- VIEW

view : Model -> Html Msg
view model =
    div [ id "temperature_wrapper" ]
        [ input
            [ type_ "range"
            , H.min "-30"
            , H.max "40"
            , H.defaultValue "20"
            , onInput SlideTemperature
            , name "biodiversity_report[temperature]"
            , id "biodiversity_report_temperature"
            ]
            []
        , div [ id "temperature_value" ]
            [ text (model.value ++ "°C") ]
        ]

Use Elm conventions for main, initialModel. One typical signature of an Elm 'main' is 'Program Never Model Msg'. And sometimes folks use an 'initialModel' for the initial model, rather than an explicit inline record within 'main'. - Replace record type with Model. - Declare 'initialModel' using literal record, and refer to it within 'main'.

module Main exposing (..)

import Html exposing (Html, div, input, span, text)
import Html.Attributes as H exposing (..)
import Html.Events exposing (onInput)

--  MAIN

main : Program Never Model Msg
main =
    Html.beginnerProgram
        { model = initialModel
        , view = view
        , update = update
        }

-- MODEL

type alias Model =
    { value : String
    }

initialModel : Model
initialModel =
    { value = "20" }

-- UPDATE

type Msg
    = SlideTemperature String

update : Msg -> Model -> Model
update msg model =
    case msg of
        SlideTemperature temperature ->
            { model | value = temperature }

-- VIEW

view : Model -> Html Msg
view model =
    div [ id "temperature_wrapper" ]
        [ input
            [ type_ "range"
            , H.min "-30"
            , H.max "40"
            , H.defaultValue "20"
            , onInput SlideTemperature
            , name "biodiversity_report[temperature]"
            , id "biodiversity_report_temperature"
            ]
            []
        , div [ id "temperature_value" ]
            [ text (model.value ++ "°C") ]
        ]


Dashboard.elm

Add the rest of dashboard

module Dashboard where

import Html exposing (..)
import Html.Attributes exposing (..)
import Maybe
import Signal exposing (Signal, Address)
import String

type alias Dashboard =
  { circuits : List String }

type alias Circuit =
  { serviceName: String
  , name: String
  , currentStatus: BreakerStatus
  , currentLatency: LatencyHistogram
  , currentCount: CircuitCounter
  , historicInformation: List CircuitHistory
  }

type alias CircuitHistory =
  { latency: LatencyHistogram
  , count: CircuitCounter
  }

type alias CircuitCounter =
  { total: Int
  , failures: Maybe Int
  , success: Maybe Int
  , shortCircuited: Maybe Int
  , failover: Maybe Int
  }

type alias LatencyHistogram =
  { mean: Int
  , median: Int
  , min: Int
  , max: Int
  , percentile25: Maybe Int
  , percentile75: Maybe Int
  , percentile90: Maybe Int
  , percentile95: Maybe Int
  , percentile99: Maybe Int
  , percentile995: Maybe Int
  , percentile999: Maybe Int
  }

type alias PartiallyOpenBreaker =
  { open: Int
  , closed: Int
  }

type BreakerStatus
  = Open Int
  | Partial PartiallyOpenBreaker
  | Closed Int

emptyDashboard : Dashboard
emptyDashboard =
  { circuits = [] }

type Action
  = NoOp
  | AddCircuit String

update : Action -> Dashboard -> Dashboard
update action model =
  case action of
    NoOp -> model
    AddCircuit str ->
      { model |
        circuits =
          if String.isEmpty str
            then model.circuits
            else model.circuits ++ [str]
      }

view : Address Action -> Dashboard -> Html
view action model =
  div
    [ class "dashboard-wrapper"]
    [ text "derp" ]

main : Signal Html
main =
  Signal.map (view actions.address) model

model : Signal Dashboard
model =
  Signal.foldp update initialModel actions.signal

initialModel : Dashboard
initialModel =
  emptyDashboard

actions : Signal.Mailbox Action
actions =
  Signal.mailbox NoOp