-
Notifications
You must be signed in to change notification settings - Fork 2
/
Main.elm
112 lines (99 loc) · 2.16 KB
/
Main.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
module Main exposing (main)
import Html exposing (..)
import Html.Attributes exposing (..)
import Brands.Functor exposing (set)
import Brands.Foldable exposing (foldMap)
import Brands.Expr exposing (..)
import Brands.Html as BH
import Brands.List as BL
import Brands.Maybe as BM
main : Html a
main =
div
[ style
[ ("display", "flex")
, ("flex-direction", "column")
]
]
[ span' <| BM.prj <| set BM.functor 12 <| BM.inj <| Nothing
, span' <| BM.prj <| set BM.functor 12 <| BM.inj <| Just "hi"
, foldMap BL.foldable BH.monoid viewLevel <| BL.inj userLevels
, fieldset
[]
[ legend [] [text "Expr a"]
, section
[]
[ h4 [] [text "Pretty print"]
, article
[]
[ span [] [text "three: "]
, span [] [text (pretty three)]
]
, article
[]
[ span [] [text "four: "]
, span [] [text (pretty four)]
]
, article
[]
[ span [] [text "conditional: "]
, span [] [text (pretty conditional)]
]
]
, section
[]
[ h4 [] [text "Evaluated"]
, article
[]
[ span [] [text "three: "]
, span [] [text (toString (eval three))]
]
, article
[]
[ span [] [text "four: "]
, span [] [text (toString (eval four))]
]
, article
[]
[ span [] [text "conditional: "]
, span [] [text (toString (eval conditional))]
]
]
]
]
userLevels : List Level
userLevels =
[ Administrator
, User
, User
, Moderator
, User
]
span' : a -> Html b
span' x =
span [] [text <| toString x]
type Level
= User
| Moderator
| Administrator
viewLevel : Level -> Html a
viewLevel level =
case level of
User ->
text "Hello friend!"
Moderator ->
button [] [text "Mute everone"]
Administrator ->
button [] [text "Delete DB"]
three : Expr Int
three =
add (val 1) (val 2)
four : Expr Int
four =
add (val 1) three
conditional : Expr Int
conditional =
if' (eq three four) then'
three
else'
four