-
Notifications
You must be signed in to change notification settings - Fork 2
/
Main06.elm
74 lines (48 loc) · 921 Bytes
/
Main06.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
module Main exposing (..)
import Html
add : number -> number -> number
add a b =
a + b
increment : number -> number
increment =
add 1
multiply : number -> number -> number
multiply a b =
a * b
double : number -> number
double x =
x + x
triple : number -> number
triple =
multiply 3
tripleAndIncrement : number -> number
tripleAndIncrement =
triple >> increment
person : { age : number, name : String }
person =
{ name = "Marcel"
, age = 30
}
newPerson : { name : String, age : number }
newPerson =
{ person
| age = 31
}
type Msg
= Msg1 Int
| Msg2 String
msg : Msg
msg =
Msg2 "Marcel"
hey : Msg -> String
hey msg =
case msg of
Msg1 num ->
"The number is " ++ (toString (num))
Msg2 name ->
"Hello " ++ name
main : Html.Html a
main =
person.age
|> toString
|> Html.text