processing (ex. Diff with Virtual Dom ) - Code is easier to understand in general. - Thread-safe (ex. multiple threads cannot corrupt the state ) - Compiler can check the type of data even without notation. - No generic map, apply, fold, or filter type functions. Instead it uses names with the prefix of its module as List.map, Dict.filter.
name : String, age : Int, experience : NinjaLevel } ninja = Ninja “katana” 23 Junior ninja.name -- output “Katana” Record type NinjaLevel = Junior | Senior | Guru | Ninja Union Type type Answer = Yes | No | Other String
manager and versions “based on file ( elm-package.json )”) - elm-make ( Elm compiler) Comunidade: - elm-install ( Install modules directly from github and official ) - elm-format ( Code formatter ) - ellie-app (online editor, https://ellie-app.com/new ) - Html to Elm (atom plugin, online : https://mbylstra.github.io/html-to-elm/) - elm-live ( A flexible dev server for Elm. Live reload included. https://git.io/elm-live )
application • Update — a way to update your state • View — a way to view your state as HTML • Commands — A Cmd lets you do stuff: generate a random number, send an HTTP request, etc. • • Subscriptions — A Sub lets you register that you are interested in something: tell me about location changes, listen for web socket messages, Mouse, Keyboard ,etc.
-- MODEL type alias Model = { ninja } http://package.elm-lang.org/packages/elm-lang/html/latest This uses Virtual Dom Maybe a Record, Integer, String, … etc
= Reset | ... update : Msg -> Model -> Model update msg model = case msg of Reset -> ... ... Pattern matching for all Msg Send to elm runtime as the changes it has to do
Model -> Html Msg view model = div [ id “divNinja”, class “ninja-name”, onClick Reset ] [ text (model.ninja).name ] ... List of Html.Attributes List of child elements
<script src="main.js"></script> <script> var node = document.getElementById('main'); var app = Elm.Main.embed(node); // Note: if your Elm module is named "MyThing.Root" you // would call "Elm.MyThing.Root.embed(node)" instead. </script>