@JoGrenat #elmlang
Functional
programming
Immutability
Components
Types
One-way
data flow
Virtual DOM
Happiness (DX)
let
twentyFour =
3 * 8
sixteen =
4 * 4
in
twentyFour + sixteen
case myStringMaybe of
Just myString -> myString
Nothing -> "Empty"
case myListOfString of
head :: tail -> head
[] -> "no value in list"
case myNumber of
0 -> "0"
1 -> "1"
_ -> "Nor 0 nor 1"
Cmd Msg
main : Program Never Model Msg
main =
program { view = view, init = init, update = update, subscriptions = subscriptions }
-- ...
subscriptions : Model -> Sub Msg
subscriptions model =
usernameFromLS ReceivedUsernameFromLS
port registerUsernameToLS : String -> Cmd msg
port usernameFromLS : (String -> msg) -> Sub msg
const app = Elm.Main.embed(root);
app.ports.registerUsernameToLS.subscribe(username => {
window.localStorage.setItem('username', username)
});
if (window.localStorage.getItem('username') !== null) {
const username = window.localStorage.getItem('username');
app.ports.usernameFromLS.send(username);
}
Official website: http://elm-lang.org
Syntax: http://elm-lang.org/docs/syntax
Feedback: http://bit.ly/2DEBZud