-
Notifications
You must be signed in to change notification settings - Fork 0
/
InitDataUI.purs
187 lines (159 loc) · 5.21 KB
/
InitDataUI.purs
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
module InteractiveData.Class.InitDataUI
( class GetInitSym
, class GetInitSymRL
, class Init
, class InitGenericSpec
, class InitGenericSpecRL
, class InitRecord
, class InitRecordRL
, init
, initGenericSpec
, initGenericSpecRL
, initRecord
, initRecordRL
) where
import Data.Symbol (class IsSymbol)
import DataMVC.Record.DataUI (class DataUiRecord)
import DataMVC.Types (DataUI)
import InteractiveData.Core (class IDHtml, IDSurface)
import InteractiveData.DataUIs (record)
import InteractiveData.DataUIs.Record as R
import MVC.Record (RecordMsg, RecordState)
import Prim.Row as Row
import Prim.RowList (class RowToList, RowList)
import Prim.RowList as RL
import Record as Record
import Type.Proxy (Proxy(..))
--------------------------------------------------------------------------------
--- Init
--------------------------------------------------------------------------------
class
Init
(token :: Type)
(a :: Type)
where
init :: token -> a
--------------------------------------------------------------------------------
--- InitRecord
--------------------------------------------------------------------------------
class
InitRecord
(token :: Type)
(row :: Row Type)
(datauis :: Row Type)
| token row -> datauis
where
initRecord :: token -> Proxy row -> Record datauis
instance
( RowToList row rowlist
, InitRecordRL rowlist token datauis
) =>
InitRecord token row datauis
where
initRecord :: token -> Proxy row -> Record datauis
initRecord token _ = initRecordRL @rowlist token Proxy
--------------------------------------------------------------------------------
--- InitRecordRL
--------------------------------------------------------------------------------
class
InitRecordRL
(rowlist :: RowList Type)
(token :: Type)
(datauis :: Row Type)
| rowlist token -> datauis
where
initRecordRL :: token -> Proxy rowlist -> Record datauis
instance InitRecordRL RL.Nil token ()
where
initRecordRL :: token -> Proxy RL.Nil -> Record ()
initRecordRL _ _ = {}
instance
( InitRecordRL rowlistPrev tok datauisPrev
, Row.Cons sym (DataUI (IDSurface srf) fm fs msg sta typ) datauisPrev datauis
, Init tok (DataUI (IDSurface srf) fm fs msg sta typ)
, IsSymbol sym
, Row.Lacks sym datauisPrev
) =>
InitRecordRL (RL.Cons sym typ rowlistPrev) tok datauis
where
initRecordRL :: tok -> Proxy (RL.Cons sym typ rowlistPrev) -> Record datauis
initRecordRL tok _ =
Record.insert prxSym dataUi tail
where
dataUi :: DataUI (IDSurface srf) fm fs msg sta typ
dataUi = init tok
tail :: { | datauisPrev }
tail = initRecordRL @rowlistPrev tok Proxy
prxSym :: Proxy sym
prxSym = Proxy
--------------------------------------------------------------------------------
--- InitGenericSpec
--------------------------------------------------------------------------------
class
InitGenericSpec
(token :: Type)
(row :: Row Type)
(specs :: Row Type)
| row token -> specs
where
initGenericSpec :: token -> Proxy row -> Record specs
instance
( RowToList row rowlist
, InitGenericSpecRL token rowlist specs
) =>
InitGenericSpec token row specs
where
initGenericSpec :: token -> Proxy row -> Record specs
initGenericSpec token Proxy = initGenericSpecRL @token @rowlist token Proxy
--------------------------------------------------------------------------------
--- InitGenericSpecRL
--------------------------------------------------------------------------------
class
InitGenericSpecRL
(token :: Type)
(rowlist :: RowList Type)
(specs :: Row Type)
| rowlist token -> specs
where
initGenericSpecRL :: token -> Proxy rowlist -> Record specs
instance InitGenericSpecRL token RL.Nil () where
initGenericSpecRL :: token -> Proxy RL.Nil -> Record ()
initGenericSpecRL _ _ = {}
instance
( InitGenericSpecRL token rowlistPrev specsPrev
, Row.Cons sym (DataUI (IDSurface html) fm fs (RecordMsg rmsg) (RecordState rsta) (Record r)) specsPrev specs
, InitRecord token typ productSpec
, IsSymbol sym
, Row.Lacks sym specsPrev
, DataUiRecord productSpec fm fs (IDSurface html) rmsg rsta r
, IDHtml html
) =>
InitGenericSpecRL token (RL.Cons sym (Record typ) rowlistPrev) specs
where
initGenericSpecRL :: token -> Proxy (RL.Cons sym (Record typ) rowlistPrev) -> Record specs
initGenericSpecRL token _ =
Record.insert prxSym headVal' tail
where
tail :: { | specsPrev }
tail = initGenericSpecRL @token @rowlistPrev token Proxy
headVal :: Record productSpec
headVal = initRecord @token @typ token Proxy
headVal' :: DataUI (IDSurface html) fm fs (RecordMsg rmsg) (RecordState rsta) (Record r)
headVal' = record { mode: R.Indices } headVal
prxSym :: Proxy sym
prxSym = Proxy
--------------------------------------------------------------------------------
--- GetInitSym
--------------------------------------------------------------------------------
class
GetInitSym
(row :: Row Type)
(initSym :: Symbol)
| row -> initSym
instance (GetInitSymRL rowlist initSym, RowToList row rowlist) => GetInitSym row initSym
class
GetInitSymRL
(rowlist :: RowList Type)
(initSym :: Symbol)
| rowlist -> initSym
instance GetInitSymRL (RL.Cons initSym typ rowlistPrev) initSym