-
Notifications
You must be signed in to change notification settings - Fork 0
/
TableData.dcl
44 lines (38 loc) · 1.46 KB
/
TableData.dcl
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
definition module TableData
import iTasks
import Text.HTML
class TableData a where
htmlTable :: a -> HtmlTag
// Appending two tables glues the right one to the right of the left one.
// Appending tables only makes sense when they are compatible, and their
// header and column information matches the length of the rows, and all rows
// have the same length. The result has as many rows as the shorter one.
appendTable :: a a -> a
// Convenience function for viewing table data directly.
//
// If you need to transform your data to table data, do as follows.
//
// viewInformation () [ViewUsing (htmlTable o myDataToTableData) (htmlView 'M'.newMap)] myData
// where myDataToTableData = ...
//
// Or, for shared data:
//
// viewSharedInformation () [ViewUsing (htmlTable o myDataToTableData) (htmlView 'M'.newMap)] myShare
// where myDataToTableData = ...
viewAsTable :: !d !m -> (Task m) | toPrompt d & TableData m & iTask m
// A table without headers
instance TableData [[a]] | iTask a
// A table with headers
// ( [a] // column headers
// , [[b]] // row data
// )
instance TableData ([a], [[b]]) | iTask a & iTask b
// A table with headers where columns and rows can have css classes
// ( [a] // column headers
// , [Maybe String] // column classes
// , [ ( [b] // row data
// , Maybe String // row class
// )
// ]
// )
instance TableData ([a], [Maybe String], [([b], Maybe String)]) | iTask a & iTask b