char: ‘a’ • string: “abc” • if … then … else • case .. of a -> doSomething b -> — single line comment {- multi line comment -} achar = ‘a’ astring = “abc” isEven number = if number % 2 == 0 then True else False
Int • add x y = x + y • \n -> n + 1 • let .. in • type Tree = Branch | Leaf evenFilter data = let isEven number = if number % 2 == 0 then True else False in List.filter isEven data
b) -> Maybe b andThen maybe callback = case maybe of Just value -> callback value Nothing -> Nothing from Let’s be mainstream! User focused design in Elm
Inc | Dec update : Msg -> Model -> Model update msg model = case msg of Inc -> model + 1 Dec -> model - 1 view : Model -> Html Msg view model = div [] [ button [onClick Inc] [text “+”] , text (toString model) , button [onClick Dec] [text “-“] ]