ELM in 300'000 ms!

Hello, I'm Ju 🙇🏻

You can find me as @arkh4m

engineering.alphasights.com

WHAT IS ELM?

  • Purely Functional

  • Optionally Typed

  • Monad Friendly

  • Immutable

  • Awesome!

Yes, it compiles to Javascript.

DEMO TIME!

import Html exposing (text)

main =
  text "Hello, World"
import Html exposing (text)

add : Int -> Int -> Int
add x y =
  x + y

main =
  text (toString (add 5 6))
import Html exposing (text)

add : Int -> Int -> Int
add x y =
  x + y
  
mult : Int -> Int -> Int
mult x y =
  x * y
  
add2 = add(2)
mult3 = mult(3)

main =
  -- text (toString (mult3 (add2 5)))
  -- add2 5 |> mult3 |> toString |> text
  -- text <| toString <| mult3 <| add2(5)
  add2 5 |> (add2 >> mult3 >> add2) |> toString |> text
import Html exposing (Html, div, button, text)
import Html.App exposing (beginnerProgram)
import Html.Events exposing (onClick)

main =
  beginnerProgram
    { model = model
    , view = view
    , update = update
    }
  
-- MODEL

type alias Model = Int

model : Model
model =
  0
-- UPDATE

type Msg = Increment | Decrement

update : Msg -> Model -> Model
update msg model =
  case msg of
    Increment ->
      model + 1
    Decrement ->
      model - 1
      
-- VIEW

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

THANKS!

Elm in 300'000 ms!

By arkh4m

Elm in 300'000 ms!

  • 980