Elm

Print

import Html exposing (text)

main =
text "Hello World"

Variables

x = 4
x: Int = 4

Data types

-- Basic types
x: number
x: Int
x: Float
x: String
x: Char
x: Bool

-- List
myList: List = [1, 2, 3]

-- Tuple
myTuple: Tuple = (1, 2, 3)

-- Maybe
x: Maybe

-- Result
x: Result

Operators

-- Arithmetic operators
% -- modulo (remainder)
// -- floor division

-- Logical operators
== -- equal
!= -- not equal
&& -- AND
|| -- OR
xor -- XOR
not -- NOT

Control flow

if a > b then
    -- statement
else 
    -- statement

Functions

add x y = x+y

-- Call function
add 5 10

Error handling

-- Maybe type
userName: Maybe String
userName = Just "Peter"
userName = Nothing

-- Result type
userId: Result String Int
userId = Ok 10
userId = Err "Not a valid id"