@explorable-viz/fluid 0.7.9 → 0.7.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. package/.spago/{argonaut-codecs/v9.0.0 → affjax-node/v1.0.0}/.editorconfig +1 -1
  2. package/.spago/affjax-node/v1.0.0/.eslintrc.json +30 -0
  3. package/.spago/affjax-node/v1.0.0/.gitignore +13 -0
  4. package/.spago/pathy/v9.0.0/.editorconfig +13 -0
  5. package/dist/fluid/fluid/dataset/methane-emissions.fld +123 -0
  6. package/dist/fluid/fluid/dataset/mini-non-renewables.fld +3 -0
  7. package/dist/fluid/fluid/dataset/mini-renewables.fld +6 -0
  8. package/dist/fluid/fluid/dataset/non-renewables.fld +67 -0
  9. package/dist/fluid/fluid/dataset/renewables-new.fld +301 -0
  10. package/dist/fluid/fluid/dataset/renewables-restricted.fld +139 -0
  11. package/dist/fluid/fluid/dataset/renewables.fld +100 -0
  12. package/dist/fluid/fluid/example/arithmetic.fld +1 -0
  13. package/dist/fluid/fluid/example/array.fld +2 -0
  14. package/dist/fluid/fluid/example/compose.fld +2 -0
  15. package/dist/fluid/fluid/example/desugar/list-comp-1.fld +1 -0
  16. package/dist/fluid/fluid/example/desugar/list-comp-10.fld +1 -0
  17. package/dist/fluid/fluid/example/desugar/list-comp-2.fld +1 -0
  18. package/dist/fluid/fluid/example/desugar/list-comp-3.fld +1 -0
  19. package/dist/fluid/fluid/example/desugar/list-comp-4.fld +1 -0
  20. package/dist/fluid/fluid/example/desugar/list-comp-5.fld +1 -0
  21. package/dist/fluid/fluid/example/desugar/list-comp-6.fld +1 -0
  22. package/dist/fluid/fluid/example/desugar/list-comp-7.fld +1 -0
  23. package/dist/fluid/fluid/example/desugar/list-comp-8.fld +1 -0
  24. package/dist/fluid/fluid/example/desugar/list-comp-9.fld +1 -0
  25. package/dist/fluid/fluid/example/desugar/list-enum.fld +1 -0
  26. package/dist/fluid/fluid/example/dict-list-comp.fld +1 -0
  27. package/dist/fluid/fluid/example/dicts.fld +10 -0
  28. package/dist/fluid/fluid/example/div-mod-quot-rem.fld +4 -0
  29. package/dist/fluid/fluid/example/factorial.fld +6 -0
  30. package/dist/fluid/fluid/example/filter.fld +1 -0
  31. package/dist/fluid/fluid/example/first-class-constr.fld +1 -0
  32. package/dist/fluid/fluid/example/flatten.fld +12 -0
  33. package/dist/fluid/fluid/example/foldr-sumSquares.fld +1 -0
  34. package/dist/fluid/fluid/example/graphics/background.fld +7 -0
  35. package/dist/fluid/fluid/example/graphics/grouped-bar-chart.fld +9 -0
  36. package/dist/fluid/fluid/example/graphics/line-chart.fld +13 -0
  37. package/dist/fluid/fluid/example/graphics/stacked-bar-chart.fld +3 -0
  38. package/dist/fluid/fluid/example/include-input-into-output.fld +1 -0
  39. package/dist/fluid/fluid/example/length.fld +1 -0
  40. package/dist/fluid/fluid/example/lexicalScoping.fld +3 -0
  41. package/dist/fluid/fluid/example/lib/some-constants.fld +1 -0
  42. package/dist/fluid/fluid/example/linked-inputs/energyscatter.fld +24 -0
  43. package/dist/fluid/fluid/example/linked-inputs/mini-energyscatter.fld +30 -0
  44. package/dist/fluid/fluid/example/linked-outputs/convolution-data.fld +5 -0
  45. package/dist/fluid/fluid/example/linked-outputs/convolution.fld +12 -0
  46. package/dist/fluid/fluid/example/linked-outputs/line-chart.fld +15 -0
  47. package/dist/fluid/fluid/example/linked-outputs/moving-average.fld +19 -0
  48. package/dist/fluid/fluid/example/linked-outputs/pairs-data.fld +1 -0
  49. package/dist/fluid/fluid/example/linked-outputs/pairs.fld +2 -0
  50. package/dist/fluid/fluid/example/lookup.fld +15 -0
  51. package/dist/fluid/fluid/example/map.fld +1 -0
  52. package/dist/fluid/fluid/example/mergeSort.fld +22 -0
  53. package/dist/fluid/fluid/example/normalise.fld +3 -0
  54. package/dist/fluid/fluid/example/nub.fld +1 -0
  55. package/dist/fluid/fluid/example/pattern-match.fld +12 -0
  56. package/dist/fluid/fluid/example/percent.fld +1 -0
  57. package/dist/fluid/fluid/example/plot/methane.fld +14 -0
  58. package/dist/fluid/fluid/example/plot/non-renewables.fld +22 -0
  59. package/dist/fluid/fluid/example/range.fld +4 -0
  60. package/dist/fluid/fluid/example/record-lookup.fld +3 -0
  61. package/dist/fluid/fluid/example/records.expect.fld +0 -0
  62. package/dist/fluid/fluid/example/records.fld +11 -0
  63. package/dist/fluid/fluid/example/reverse.fld +1 -0
  64. package/dist/fluid/fluid/example/scratchpad.fld +6 -0
  65. package/dist/fluid/fluid/example/slicing/add.expect.fld +1 -0
  66. package/dist/fluid/fluid/example/slicing/add.fld +1 -0
  67. package/dist/fluid/fluid/example/slicing/array/array.expect.fld +2 -0
  68. package/dist/fluid/fluid/example/slicing/array/array.fld +4 -0
  69. package/dist/fluid/fluid/example/slicing/array/dims.expect.fld +3 -0
  70. package/dist/fluid/fluid/example/slicing/array/dims.fld +3 -0
  71. package/dist/fluid/fluid/example/slicing/array/lookup.expect.fld +3 -0
  72. package/dist/fluid/fluid/example/slicing/array/lookup.fld +5 -0
  73. package/dist/fluid/fluid/example/slicing/array/renewables.fld +100 -0
  74. package/dist/fluid/fluid/example/slicing/convolution/edgeDetect.expect.fld +1 -0
  75. package/dist/fluid/fluid/example/slicing/convolution/edgeDetect.fld +1 -0
  76. package/dist/fluid/fluid/example/slicing/convolution/emboss-wrap.fld +1 -0
  77. package/dist/fluid/fluid/example/slicing/convolution/emboss.expect.fld +1 -0
  78. package/dist/fluid/fluid/example/slicing/convolution/emboss.fld +1 -0
  79. package/dist/fluid/fluid/example/slicing/convolution/filter/edge-detect.fld +5 -0
  80. package/dist/fluid/fluid/example/slicing/convolution/filter/emboss.fld +5 -0
  81. package/dist/fluid/fluid/example/slicing/convolution/filter/gaussian.fld +5 -0
  82. package/dist/fluid/fluid/example/slicing/convolution/gaussian.expect.fld +1 -0
  83. package/dist/fluid/fluid/example/slicing/convolution/gaussian.fld +1 -0
  84. package/dist/fluid/fluid/example/slicing/convolution/test-image.fld +7 -0
  85. package/dist/fluid/fluid/example/slicing/dict/create.expect.fld +2 -0
  86. package/dist/fluid/fluid/example/slicing/dict/create.fld +1 -0
  87. package/dist/fluid/fluid/example/slicing/dict/difference.expect.fld +4 -0
  88. package/dist/fluid/fluid/example/slicing/dict/difference.fld +3 -0
  89. package/dist/fluid/fluid/example/slicing/dict/disjointUnion.expect.fld +2 -0
  90. package/dist/fluid/fluid/example/slicing/dict/disjointUnion.fld +1 -0
  91. package/dist/fluid/fluid/example/slicing/dict/foldl.expect.fld +3 -0
  92. package/dist/fluid/fluid/example/slicing/dict/foldl.fld +1 -0
  93. package/dist/fluid/fluid/example/slicing/dict/get.expect.fld +5 -0
  94. package/dist/fluid/fluid/example/slicing/dict/get.fld +3 -0
  95. package/dist/fluid/fluid/example/slicing/dict/intersectionWith.expect.fld +5 -0
  96. package/dist/fluid/fluid/example/slicing/dict/intersectionWith.fld +4 -0
  97. package/dist/fluid/fluid/example/slicing/dict/map.expect.fld +8 -0
  98. package/dist/fluid/fluid/example/slicing/dict/map.fld +5 -0
  99. package/dist/fluid/fluid/example/slicing/dict/match.expect.fld +6 -0
  100. package/dist/fluid/fluid/example/slicing/dict/match.fld +5 -0
  101. package/dist/fluid/fluid/example/slicing/divide.expect.fld +1 -0
  102. package/dist/fluid/fluid/example/slicing/divide.fld +1 -0
  103. package/dist/fluid/fluid/example/slicing/dtw/average-series.expect.fld +8 -0
  104. package/dist/fluid/fluid/example/slicing/dtw/average-series.fld +8 -0
  105. package/dist/fluid/fluid/example/slicing/dtw/compute-dtw.expect.fld +6 -0
  106. package/dist/fluid/fluid/example/slicing/dtw/compute-dtw.fld +6 -0
  107. package/dist/fluid/fluid/example/slicing/explained.expect.fld +1 -0
  108. package/dist/fluid/fluid/example/slicing/explained.fld +1 -0
  109. package/dist/fluid/fluid/example/slicing/filter.expect.fld +4 -0
  110. package/dist/fluid/fluid/example/slicing/filter.fld +6 -0
  111. package/dist/fluid/fluid/example/slicing/intersperse-1.expect.fld +4 -0
  112. package/dist/fluid/fluid/example/slicing/intersperse-2.expect.fld +4 -0
  113. package/dist/fluid/fluid/example/slicing/intersperse.fld +5 -0
  114. package/dist/fluid/fluid/example/slicing/length.expect.fld +1 -0
  115. package/dist/fluid/fluid/example/slicing/length.fld +1 -0
  116. package/dist/fluid/fluid/example/slicing/linked-outputs/bar-chart-line-chart.expect.fld +0 -0
  117. package/dist/fluid/fluid/example/slicing/linked-outputs/bar-chart-line-chart.fld +29 -0
  118. package/dist/fluid/fluid/example/slicing/linked-outputs/stacked-bar-scatter-plot.expect.fld +0 -0
  119. package/dist/fluid/fluid/example/slicing/linked-outputs/stacked-bar-scatter-plot.fld +39 -0
  120. package/dist/fluid/fluid/example/slicing/list-comp-1.expect.fld +6 -0
  121. package/dist/fluid/fluid/example/slicing/list-comp-2.expect.fld +6 -0
  122. package/dist/fluid/fluid/example/slicing/list-comp.fld +8 -0
  123. package/dist/fluid/fluid/example/slicing/lookup.expect.fld +6 -0
  124. package/dist/fluid/fluid/example/slicing/lookup.fld +14 -0
  125. package/dist/fluid/fluid/example/slicing/map.expect.fld +1 -0
  126. package/dist/fluid/fluid/example/slicing/map.fld +1 -0
  127. package/dist/fluid/fluid/example/slicing/matrix-update.expect.fld +5 -0
  128. package/dist/fluid/fluid/example/slicing/matrix-update.fld +10 -0
  129. package/dist/fluid/fluid/example/slicing/multiply.expect.fld +1 -0
  130. package/dist/fluid/fluid/example/slicing/multiply.fld +1 -0
  131. package/dist/fluid/fluid/example/slicing/nth.expect.fld +1 -0
  132. package/dist/fluid/fluid/example/slicing/nth.fld +1 -0
  133. package/dist/fluid/fluid/example/slicing/output-not-source.expect.fld +2 -0
  134. package/dist/fluid/fluid/example/slicing/output-not-source.fld +1 -0
  135. package/dist/fluid/fluid/example/slicing/section-5-example-1.expect.fld +10 -0
  136. package/dist/fluid/fluid/example/slicing/section-5-example-2.expect.fld +10 -0
  137. package/dist/fluid/fluid/example/slicing/section-5-example-3.expect.fld +10 -0
  138. package/dist/fluid/fluid/example/slicing/section-5-example.fld +14 -0
  139. package/dist/fluid/fluid/example/slicing/zeros-1.expect.fld +3 -0
  140. package/dist/fluid/fluid/example/slicing/zeros-2.expect.fld +3 -0
  141. package/dist/fluid/fluid/example/slicing/zeros.fld +4 -0
  142. package/dist/fluid/fluid/example/slicing/zipWith-1.expect.fld +4 -0
  143. package/dist/fluid/fluid/example/slicing/zipWith.fld +4 -0
  144. package/dist/fluid/fluid/example/text-viz/explainable-table.fld +7 -0
  145. package/dist/fluid/fluid/example/text-viz/fake-probabilities.fld +3 -0
  146. package/dist/fluid/fluid/example/text-viz/figure-spm-4.fld +42 -0
  147. package/dist/fluid/fluid/example/text-viz/left-barchart-table.fld +5 -0
  148. package/dist/fluid/fluid/example/text-viz/likelihoods.fld +9 -0
  149. package/dist/fluid/fluid/example/text-viz/right-barchart-table.fld +5 -0
  150. package/dist/fluid/fluid/example/text-viz/table-spm-1.fld +30 -0
  151. package/dist/fluid/fluid/lib/convolution.fld +16 -0
  152. package/dist/fluid/fluid/lib/dtw.fld +47 -0
  153. package/dist/fluid/fluid/lib/fnum.fld +22 -0
  154. package/dist/fluid/fluid/lib/graphics.fld +221 -0
  155. package/dist/fluid/fluid/lib/prelude.fld +266 -0
  156. package/dist/fluid/fluid/lib/text-viz.fld +18 -0
  157. package/dist/fluid/fluid.mjs +28285 -0
  158. package/package.json +1 -1
  159. package/.spago/node-process/v11.0.0/.eslintrc.json +0 -29
  160. package/.spago/node-process/v11.0.0/.gitignore +0 -8
  161. package/.spago/node-process/v11.1.0/.eslintrc.json +0 -29
  162. package/.spago/node-process/v11.1.0/.gitignore +0 -8
  163. package/.spago/node-process/v11.2.0/.eslintrc.json +0 -29
  164. package/.spago/node-process/v11.2.0/.gitignore +0 -8
  165. package/.spago/optparse/v6.0.0/.gitignore +0 -8
  166. package/.spago/optparse/v6.0.0/.npmrc +0 -1
  167. /package/.spago/{argonaut-codecs → pathy}/v9.0.0/.gitignore +0 -0
  168. /package/.spago/{argonaut-codecs → pathy}/v9.0.0/.tidyrc.json +0 -0
@@ -0,0 +1,139 @@
1
+ -- typedef Year = Num
2
+ -- typedef Country = Str
3
+ -- typedef EnergyType = Str
4
+ -- typedef Output = Num
5
+ -- typedef CountryData = List (EnergyType, Output)
6
+ -- typedef AnnualData = List (Country, CountryData)
7
+ -- typedef Data = List (Year, AnnualData)
8
+ -- The original dataset sometimes has '~0' instead of '0'.
9
+
10
+ -- Including only 3 countries here. Also, have reduced the Hydro value for China 2015 from 296 to 96 (ouch)
11
+ -- to make the charts fit nicely into my grant proposal. Fix this once proposal submitted!
12
+ -- https://www.ren21.net/wp-content/uploads/2019/05/GSR2014_Full-Report_English.pdf
13
+ [
14
+ (2013, [
15
+ ("China", [
16
+ ("Bio", 6.2),
17
+ ("Hydro", 260),
18
+ ("Solar", 19.9),
19
+ ("Wind", 91)
20
+ ]),
21
+ ("USA", [
22
+ ("Bio", 15.8),
23
+ ("Hydro", 78),
24
+ ("Solar", 12.1),
25
+ ("Wind", 61)
26
+ ]),
27
+ ("Germany", [
28
+ ("Bio", 8.1),
29
+ ("Hydro", 5.6),
30
+ ("Solar", 36),
31
+ ("Wind", 34)
32
+ ])
33
+ ]),
34
+ -- https://www.ren21.net/wp-content/uploads/2019/05/GSR2015_Full-Report_English.pdf
35
+ (2014, [
36
+ ("China", [
37
+ ("Bio", 10),
38
+ ("Hydro", 280),
39
+ ("Solar", 28),
40
+ ("Wind", 115)
41
+ ]),
42
+ ("USA", [
43
+ ("Bio", 16.1),
44
+ ("Hydro", 79),
45
+ ("Solar", 18),
46
+ ("Wind", 66)
47
+ ]),
48
+ ("Germany", [
49
+ ("Bio", 8.8),
50
+ ("Hydro", 5.6),
51
+ ("Solar", 38),
52
+ ("Wind", 39)
53
+ ])
54
+ ]),
55
+ -- https://www.ren21.net/gsr-2016/00-Reference-Tables.php
56
+ (2015, [
57
+ ("China", [
58
+ ("Bio", 10.3),
59
+ ("Hydro", 96),
60
+ ("Solar", 44),
61
+ ("Wind", 145)
62
+ ]),
63
+ ("USA", [
64
+ ("Bio", 16.7),
65
+ ("Hydro", 80),
66
+ ("Solar", 26),
67
+ ("Wind", 74)
68
+ ]),
69
+ ("Germany", [
70
+ ("Bio", 7.1),
71
+ ("Hydro", 5.6),
72
+ ("Solar", 40),
73
+ ("Wind", 45)
74
+ ])
75
+ ]),
76
+ -- https://www.ren21.net/gsr-2017/pages/tables/tables/#table-R2
77
+ (2016, [
78
+ ("China", [
79
+ ("Bio", 12),
80
+ ("Hydro", 305),
81
+ ("Solar", 77),
82
+ ("Wind", 169)
83
+ ]),
84
+ ("USA", [
85
+ ("Bio", 16.8),
86
+ ("Hydro", 80),
87
+ ("Solar", 41),
88
+ ("Wind", 82)
89
+ ]),
90
+ ("Germany", [
91
+ ("Bio", 7.6),
92
+ ("Hydro", 5.6),
93
+ ("Solar", 41),
94
+ ("Wind", 50)
95
+ ])
96
+ ]),
97
+ -- https://www.ren21.net/gsr-2018/pages/tables/tables/#Table_R2
98
+ (2017, [
99
+ ("China", [
100
+ ("Bio", 14.9),
101
+ ("Hydro", 313),
102
+ ("Solar", 131),
103
+ ("Wind", 188)
104
+ ]),
105
+ ("USA", [
106
+ ("Bio", 16.7),
107
+ ("Hydro", 80),
108
+ ("Solar", 51),
109
+ ("Wind", 89)
110
+ ]),
111
+ ("Germany", [
112
+ ("Bio", 8),
113
+ ("Hydro", 5.6),
114
+ ("Solar", 42),
115
+ ("Wind", 56)
116
+ ])
117
+ ]),
118
+ -- https://www.ren21.net/gsr-2019/tables/table_02/table_02/
119
+ (2018, [
120
+ ("China", [
121
+ ("Bio", 17.8),
122
+ ("Hydro", 322),
123
+ ("Solar", 176),
124
+ ("Wind", 210)
125
+ ]),
126
+ ("USA", [
127
+ ("Bio", 16.2),
128
+ ("Hydro", 80),
129
+ ("Solar", 62),
130
+ ("Wind", 96)
131
+ ]),
132
+ ("Germany", [
133
+ ("Bio", 8.4),
134
+ ("Hydro", 5.6),
135
+ ("Solar", 45),
136
+ ("Wind", 59)
137
+ ])
138
+ ])
139
+ ]
@@ -0,0 +1,100 @@
1
+ -- The original dataset sometimes has '~0' instead of '0'.
2
+ -- Including only 3 countries here. Also, have reduced the Hydro value for China 2015 from 296 to 96 (ouch)
3
+ -- to make the charts fit nicely into grant proposal. Fix this once proposal submitted!
4
+ [
5
+ -- https://www.ren21.net/wp-content/uploads/2019/05/GSR2014_Full-Report_English.pdf
6
+ { year: 2013, country: "China", energyType: "Bio", output: 6.2 },
7
+ { year: 2013, country: "China", energyType: "Hydro", output: 260 },
8
+ { year: 2013, country: "China", energyType: "Solar", output: 19.9 },
9
+ { year: 2013, country: "China", energyType: "Wind", output: 91 },
10
+
11
+ { year: 2013, country: "USA", energyType: "Bio", output: 15.8 },
12
+ { year: 2013, country: "USA", energyType: "Hydro", output: 78 },
13
+ { year: 2013, country: "USA", energyType: "Solar", output: 12.1 },
14
+ { year: 2013, country: "USA", energyType: "Wind", output: 61 },
15
+
16
+ { year: 2013, country: "Germany", energyType: "Bio", output: 8.1 },
17
+ { year: 2013, country: "Germany", energyType: "Hydro", output: 5.6 },
18
+ { year: 2013, country: "Germany", energyType: "Solar", output: 36 },
19
+ { year: 2013, country: "Germany", energyType: "Wind", output: 34 },
20
+
21
+ -- https://www.ren21.net/wp-content/uploads/2019/05/GSR2015_Full-Report_English.pdf
22
+ { year: 2014, country: "China", energyType: "Bio", output: 10 },
23
+ { year: 2014, country: "China", energyType: "Hydro", output: 280 },
24
+ { year: 2014, country: "China", energyType: "Solar", output: 28 },
25
+ { year: 2014, country: "China", energyType: "Wind", output: 115 },
26
+
27
+ { year: 2014, country: "USA", energyType: "Bio", output: 16.1 },
28
+ { year: 2014, country: "USA", energyType: "Hydro", output: 79 },
29
+ { year: 2014, country: "USA", energyType: "Solar", output: 18 },
30
+ { year: 2014, country: "USA", energyType: "Wind", output: 66 },
31
+
32
+ { year: 2014, country: "Germany", energyType: "Bio", output: 8.8 },
33
+ { year: 2014, country: "Germany", energyType: "Hydro", output: 5.6 },
34
+ { year: 2014, country: "Germany", energyType: "Solar", output: 38 },
35
+ { year: 2014, country: "Germany", energyType: "Wind", output: 39 },
36
+
37
+ -- https://www.ren21.net/gsr-2016/00-Reference-Tables.php
38
+ { year: 2015, country: "China", energyType: "Bio", output: 10.3 },
39
+ { year: 2015, country: "China", energyType: "Hydro", output: 96 },
40
+ { year: 2015, country: "China", energyType: "Solar", output: 44 },
41
+ { year: 2015, country: "China", energyType: "Wind", output: 145 },
42
+
43
+ { year: 2015, country: "USA", energyType: "Bio", output: 16.7 },
44
+ { year: 2015, country: "USA", energyType: "Hydro", output: 80 },
45
+ { year: 2015, country: "USA", energyType: "Solar", output: 26 },
46
+ { year: 2015, country: "USA", energyType: "Wind", output: 74 },
47
+
48
+ { year: 2015, country: "Germany", energyType: "Bio", output: 7.1 },
49
+ { year: 2015, country: "Germany", energyType: "Hydro", output: 5.6 },
50
+ { year: 2015, country: "Germany", energyType: "Solar", output: 40 },
51
+ { year: 2015, country: "Germany", energyType: "Wind", output: 45 },
52
+
53
+ -- https://www.ren21.net/gsr-2017/pages/tables/tables/#table-R2
54
+ { year: 2016, country: "China", energyType: "Bio", output: 12 },
55
+ { year: 2016, country: "China", energyType: "Hydro", output: 305 },
56
+ { year: 2016, country: "China", energyType: "Solar", output: 77 },
57
+ { year: 2016, country: "China", energyType: "Wind", output: 169 },
58
+
59
+ { year: 2016, country: "USA", energyType: "Bio", output: 16.8 },
60
+ { year: 2016, country: "USA", energyType: "Hydro", output: 80 },
61
+ { year: 2016, country: "USA", energyType: "Solar", output: 41 },
62
+ { year: 2016, country: "USA", energyType: "Wind", output: 82 },
63
+
64
+ { year: 2016, country: "Germany", energyType: "Bio", output: 7.6 },
65
+ { year: 2016, country: "Germany", energyType: "Hydro", output: 5.6 },
66
+ { year: 2016, country: "Germany", energyType: "Solar", output: 41 },
67
+ { year: 2016, country: "Germany", energyType: "Wind", output: 50 },
68
+
69
+ -- https://www.ren21.net/gsr-2018/pages/tables/tables/#Table_R2
70
+ { year: 2017, country: "China", energyType: "Bio", output: 14.9 },
71
+ { year: 2017, country: "China", energyType: "Hydro", output: 313 },
72
+ { year: 2017, country: "China", energyType: "Solar", output: 131 },
73
+ { year: 2017, country: "China", energyType: "Wind", output: 188},
74
+
75
+ { year: 2017, country: "USA", energyType: "Bio", output: 16.7 },
76
+ { year: 2017, country: "USA", energyType: "Hydro", output: 80 },
77
+ { year: 2017, country: "USA", energyType: "Solar", output: 51 },
78
+ { year: 2017, country: "USA", energyType: "Wind", output: 89 },
79
+
80
+ { year: 2017, country: "Germany", energyType: "Bio", output: 8 },
81
+ { year: 2017, country: "Germany", energyType: "Hydro", output: 5.6 },
82
+ { year: 2017, country: "Germany", energyType: "Solar", output: 42 },
83
+ { year: 2017, country: "Germany", energyType: "Wind", output: 56 },
84
+
85
+ -- https://www.ren21.net/gsr-2019/tables/table_02/table_02/
86
+ { year: 2018, country: "China", energyType: "Bio", output: 17.8 },
87
+ { year: 2018, country: "China", energyType: "Hydro", output: 322 },
88
+ { year: 2018, country: "China", energyType: "Solar", output: 176 },
89
+ { year: 2018, country: "China", energyType: "Wind", output: 210 },
90
+
91
+ { year: 2018, country: "USA", energyType: "Bio", output: 16.2 },
92
+ { year: 2018, country: "USA", energyType: "Hydro", output: 80 },
93
+ { year: 2018, country: "USA", energyType: "Solar", output: 62 },
94
+ { year: 2018, country: "USA", energyType: "Wind", output: 96 },
95
+
96
+ { year: 2018, country: "Germany", energyType: "Bio", output: 8.4 },
97
+ { year: 2018, country: "Germany", energyType: "Hydro", output: 5.6 },
98
+ { year: 2018, country: "Germany", energyType: "Solar", output: 45 },
99
+ { year: 2018, country: "Germany", energyType: "Wind", output: 59 }
100
+ ]
@@ -0,0 +1 @@
1
+ (1 + 5) * ((let x = 2; y = 8 in x * y) - (let y = 3 in y * y))
@@ -0,0 +1,2 @@
1
+ let xs = [| i * j | (i, j) in (3, 3) |]
2
+ in (xs ! (1, 1), dims xs)
@@ -0,0 +1,2 @@
1
+ let incr = (+) 1 in
2
+ (compose incr incr) 3
@@ -0,0 +1 @@
1
+ [ x + y | x <- [5, 4, 3], y <- [9, 7, 5] ]
@@ -0,0 +1 @@
1
+ [ x | [x] <- [[], [4, 6]] ]
@@ -0,0 +1 @@
1
+ [ z | x <- [5, 4, 3], y <- [9, 7, 5], let z = x + y, c <- [9, 7, 5] ]
@@ -0,0 +1 @@
1
+ [ z | x <- [5, 4, 3], y <- [9, 7, 5], let z = x + y, z < 10 ]
@@ -0,0 +1 @@
1
+ [ x | x : xs <- [[5], [4], [3], []] ]
@@ -0,0 +1 @@
1
+ [ z | x <- [5, 4, 3], let z = x ]
@@ -0,0 +1 @@
1
+ [ z | let z = 5 ]
@@ -0,0 +1 @@
1
+ [ [] | [] <- [[5], [4], [3], []] ]
@@ -0,0 +1 @@
1
+ [ x | [x] <- [[5], [4], [3], []] ]
@@ -0,0 +1 @@
1
+ [ x + y | [x, y] <- [[5], [4, 6], [3], [], [9, 10]] ]
@@ -0,0 +1 @@
1
+ [ x | {fst: x, snd: []} <- [{fst: 5, third: "hello", snd: []}, {fst: 6, snd: [7, 8]}] ]
@@ -0,0 +1,10 @@
1
+ let d = {};
2
+ e = { ["a"]: 5, ["a" ++ "b"] : 6 };
3
+ f = { ["ab"]: 12 }
4
+ in {
5
+ d: d,
6
+ e: e,
7
+ e_ab: e.ab,
8
+ f: dict_map ((+) 1) e,
9
+ g: dict_difference e f
10
+ }
@@ -0,0 +1,4 @@
1
+ [[5 `div` 3, 5 `div` -3, -5 `div` 3, -5 `div` -3],
2
+ [5 `mod` 3, 5 `mod` -3, -5 `mod` 3, -5 `mod` -3],
3
+ [5 `quot` 3, 5 `quot` -3, -5 `quot` 3, -5 `quot` -3],
4
+ [5 `rem` 3, 5 `rem` -3, -5 `rem` 3, -5 `rem` -3]]
@@ -0,0 +1,6 @@
1
+ let fact x =
2
+ if x == 0
3
+ then 1
4
+ else x * fact (x - 1)
5
+ in
6
+ fact 8
@@ -0,0 +1 @@
1
+ filter ((<) 5) [8, 4, 7, 3]
@@ -0,0 +1 @@
1
+ zipWith (:) [10, 12, 20] [[], [], [], [], []]
@@ -0,0 +1,12 @@
1
+ let
2
+ flatten Empty = [];
3
+ flatten (NonEmpty t1 (key, val) t2) =
4
+ concat2 (flatten t1) ((key, val) : flatten t2)
5
+ in
6
+ flatten
7
+ (NonEmpty
8
+ (NonEmpty Empty (3, "simon") Empty)
9
+ (4, "john")
10
+ (NonEmpty (NonEmpty Empty (6, "sarah") Empty) (7, "claire") Empty)
11
+ )
12
+
@@ -0,0 +1 @@
1
+ foldr (fun x y -> x * x + y * y) 0 [6, 3, 2]
@@ -0,0 +1,7 @@
1
+ let rect = Rect 0 0 1 3 "red";
2
+ g = Group [Viewport 0 0 1 3 "white" 0 (Scale 1 1) (Translate 0 0) rect];
3
+ w = 1.0;
4
+ m = 0.25;
5
+ x_scale = max (w - 2 * m) 0 / w;
6
+ translate = Translate (m / x_scale) 0
7
+ in Viewport 0 0 w 3 "gray" 0 (Scale x_scale 1) translate g
@@ -0,0 +1,9 @@
1
+ let year = 2015;
2
+ -- List (Country, List (EnergyType, Output)) -> List (Country, List (EnergyType, Output))
3
+ let exclude countries yearData =
4
+ flip map yearData (second (filter (fun (country, countryData) -> not (elem country countries))))
5
+ in caption ("Renewables (GW) by country and energy type, " ++ numToStr year)
6
+ (groupedBarChart True colours1 0.2
7
+ (exclude
8
+ [] -- ["Geothermal", "Ocean", "CSP"]
9
+ (lookup year data)))
@@ -0,0 +1,13 @@
1
+ let year1 = head data;
2
+ -- List (EnergyType, Output) -> List (EnergyType, Output)
3
+ let addTotal kvs =
4
+ ("Total", sum (map snd kvs)) : kvs;
5
+ -- Country -> List (Year, List (EnergyType, Output))
6
+ let countryData country =
7
+ map (second (compose addTotal (lookup country))) data in
8
+ -- List Country
9
+ (fun country ->
10
+ caption country
11
+ (lineChart True ("black" : colours1) (fst year1)
12
+ (countryData country)))
13
+ "China"
@@ -0,0 +1,3 @@
1
+ let year = 2015 in
2
+ caption ("Total renewables (GW) by country, " ++ numToStr year)
3
+ (stackedBarChart True colours1 0.2 (lookup year data))
@@ -0,0 +1 @@
1
+ length [2, 3]
@@ -0,0 +1,3 @@
1
+ let decr = let x = 2 in flip (-) x;
2
+ x = 8 in
3
+ numToStr (decr x)
@@ -0,0 +1 @@
1
+ let x = 1;
@@ -0,0 +1,24 @@
1
+ let isCountry name x = name == x.country;
2
+ isYear year x = year == x.year;
3
+
4
+ let plot year countries =
5
+ let rens = filter (isYear year) renewables;
6
+ nonRens = filter (isYear year) nonRenewables;
7
+ let plotCountry country =
8
+ let rens' = filter (isCountry country) rens;
9
+ rensOut = sum (map (fun x -> x.output) rens');
10
+ rensCap = sum (map (fun x -> x.capacity) rens');
11
+ x = head (filter (isCountry country) nonRens);
12
+ nonRensCap = x.nuclearCap + x.petrolCap + x.gasCap + x.coalCap
13
+ in {
14
+ x: rensCap / (rensCap + nonRensCap),
15
+ y: (rensOut + x.nuclearOut) / (rensCap + x.nuclearCap)
16
+ }
17
+ in map plotCountry countries
18
+
19
+ in ScatterPlot {
20
+ caption: "Clean energy efficiency vs. proportion of renewable energy capacity",
21
+ points: plot 2018 [ "BRA", "CHN", "DEU", "FRA", "EGY", "IND", "JPN", "MEX", "NGA", "USA" ],
22
+ xlabel: "Renewables/TotalEnergyCap",
23
+ ylabel: "Clean Capacity Factor"
24
+ }
@@ -0,0 +1,30 @@
1
+ let sumNonRenewables x = x.nuclearCap + x.petrolCap + x.gasCap + x.coalCap;
2
+ let country_check name x = name == x.country;
3
+ let year_check year x = year == x.year;
4
+
5
+ let energy year c_names =
6
+ let rens2018 = filter (year_check year) renewables;
7
+ let nonrens2018 = filter (year_check year) nonRenewables;
8
+ let energy_per_country c_name =
9
+ let filteredRen = filter (country_check c_name) rens2018;
10
+ let non_ren_x = head (filter (country_check c_name) nonrens2018);
11
+ let rensOut = sum (map (fun x = x.output) filteredRen);
12
+ let rensCap = sum (map (fun x = x.capacity) filteredRen);
13
+ let nonRensCap = sumNonRenewables non_ren_x
14
+ in {
15
+ name: c_name,
16
+ totalCap: rensCap + nonRensCap,
17
+ nonRenewables: nonRensCap,
18
+ renCapFactor: (rensOut + non_ren_x.nuclearOut) / (rensCap + non_ren_x.nuclearCap)
19
+ }
20
+ in
21
+ map energy_per_country c_names
22
+ in ScatterPlot {
23
+ caption: "Clean energy efficiency against proportion of renewable energy cap",
24
+ points: [{
25
+ x: country.nonRenewables / country.totalCap,
26
+ y: country.renCapFactor
27
+ }| country <- energy 2018 ["USA"]],
28
+ xlabel: "Renewables/TotalEnergyCap",
29
+ ylabel: "Clean Capacity Factor"
30
+ }
@@ -0,0 +1,5 @@
1
+ [[15, 13, 6 , 9, 16],
2
+ [12, 5 , 15, 4, 13],
3
+ [14, 9 , 20, 8, 1 ],
4
+ [4 , 10, 3 , 7, 19],
5
+ [3 , 11, 15, 2, 9 ]]
@@ -0,0 +1,12 @@
1
+ (let filter' = [[0, 0, 0],
2
+ [3, 7, 1],
3
+ [0, 0, 0]];
4
+ filter = [| nth2 i j filter' | (i, j) in (3, 3) |];
5
+ image = [| nth2 i j data | (i, j) in (5, 5) |]
6
+ in convolve image filter wrap,
7
+ let filter' = [[0, 2, 0],
8
+ [0, 7, 0],
9
+ [0, 5, 0]];
10
+ filter = [| nth2 i j filter' | (i, j) in (3, 3) |];
11
+ image = [| nth2 i j data | (i, j) in (5, 5) |]
12
+ in convolve image filter zero)
@@ -0,0 +1,15 @@
1
+ let series type country = [
2
+ { x: row.year, y: row.output }
3
+ | year <- [2013..2018], row <- renewables,
4
+ row.year == year, row.energyType == type, row.country == country
5
+ ] in LineChart {
6
+ tickLabels: { x: Default, y: Default },
7
+ caption: "Change in renewable energy output of USA relative to China",
8
+ size: { width: 330, height: 285 },
9
+ plots: [
10
+ LinePlot { name: type, points: plot }
11
+ | type <- ["Bio", "Hydro", "Solar", "Wind"],
12
+ let plot = zipWith (fun p1 p2 -> { x: p1.x, y: p1.y / p2.y })
13
+ (series type "USA") (series type "China")
14
+ ]
15
+ }
@@ -0,0 +1,19 @@
1
+ let nthPad n xs =
2
+ nth (min (max n 0) (length xs - 1)) xs;
3
+ movingAvg ys window =
4
+ [ sum [ nthPad n ys | n <- [ i - window .. i + window ] ] / (1 + 2 * window)
5
+ | i <- [ 0 .. length ys - 1 ] ];
6
+ movingAvg' rs window =
7
+ zipWith
8
+ (fun x y -> {x: x, y: y})
9
+ (map (fun r -> r.x) rs)
10
+ (movingAvg (map (fun r -> r.y) rs) window);
11
+ let points =
12
+ [ { x: r.year, y: r.emissions } | r <- methane, r.type == "Agriculture" ]
13
+ in LineChart {
14
+ tickLabels: { x: Rotated, y: Default },
15
+ size: { width: 330, height: 285 },
16
+ caption: "SSP5-8.5 projected methane emissions (Agriculture)",
17
+ plots: [ LinePlot { name: "Moving average", points: movingAvg' points 1 },
18
+ LinePlot { name: "Original curve", points: points } ]
19
+ }
@@ -0,0 +1,2 @@
1
+ let q = 1 in
2
+ ((fun (w, x) -> (w, (w, x))) data)
@@ -0,0 +1,15 @@
1
+ let lookup k Empty = None;
2
+ lookup k (NonEmpty t1 (key, val) t2) =
3
+ match compare k key as {
4
+ LT -> lookup k t1;
5
+ EQ -> Some val;
6
+ GT -> lookup k t2
7
+ }
8
+ in
9
+ lookup
10
+ 6
11
+ (NonEmpty
12
+ (NonEmpty Empty (3, "simon") Empty)
13
+ (4, "john")
14
+ (NonEmpty (NonEmpty Empty (6, "sarah") Empty) (7, "claire") Empty)
15
+ )
@@ -0,0 +1 @@
1
+ map ((+) 1) [4, 6, 12, 14, 3, 2, -4]
@@ -0,0 +1,22 @@
1
+ let split [] = ([], []);
2
+ split (x : xs) =
3
+ let (ys, zs) = split xs in (x : zs, ys);
4
+
5
+ merge xs ys =
6
+ match (xs, ys) as {
7
+ ([], _) -> ys;
8
+ (x : xs', []) -> xs;
9
+ (x : xs', y : ys') ->
10
+ if x < y
11
+ then x : merge xs' ys
12
+ else y : merge xs ys'
13
+ };
14
+
15
+ mergesort xs =
16
+ if length xs < 2
17
+ then xs
18
+ else
19
+ let (ys, zs) = split xs in
20
+ merge (mergesort ys) (mergesort zs)
21
+ in
22
+ mergesort [3, 1, 2]
@@ -0,0 +1,3 @@
1
+ let (x, y) = (6.0, 12.0);
2
+ sum = x + y in
3
+ (floor (x * 100.0 / sum), floor (y * 100 / sum))
@@ -0,0 +1 @@
1
+ nub [1, 2, 3, 3, 4]
@@ -0,0 +1,12 @@
1
+ -- Silly test of pattern-matching for list notation
2
+ let
3
+ zip3 [] [] = [];
4
+ zip3 [x1] [y1] = (x1, y1) : zip3 [] [];
5
+ zip3 [x1, x2] [y1, y2] =
6
+ (x1, y1) : zip3 [x2] [y2];
7
+ zip3 [x1, x2, x3] [y1, y2, y3] =
8
+ (x1 , y1) : zip3 [x2, x3] [y2, y3];
9
+ zip3 (x1 : x2 : x3 : x4 : xs) (y1 : y2 : y3 : y4 : ys) =
10
+ (x1, y1) : (x2, y2) : (x3, y3) : (x4, y4) : zip3 xs ys
11
+ in
12
+ length (zip3 [3, 4, 5, 6] [5, 6, 7, 8])
@@ -0,0 +1 @@
1
+ mkPercent 0.25
@@ -0,0 +1,14 @@
1
+ let series type = [
2
+ { x: row.year, y: row.emissions }
3
+ | row <- methane, row.type == type
4
+ ] in LineChart {
5
+ size: { width: 450, height: 285 },
6
+ tickLabels: { x: Rotated, y: Default },
7
+ caption: "Sources of methane emissions for Africa and the Middle East (IPCC AR6)",
8
+ plots: [
9
+ LinePlot { name: type, points: series type }
10
+ | type <- ["Agricultural Waste Burning", "Agriculture", "Energy Sector",
11
+ "Forest Burning", "Grassland Burning", "Industrial Sector",
12
+ "Residential Commercial Other", "Transportation Sector", "Waste"]
13
+ ]
14
+ }
@@ -0,0 +1,22 @@
1
+ let countries = ["BRA", "EGY", "IND", "JPN"];
2
+ let totalFor year country =
3
+ let [ row ] = [ row | row <- nonRenewables, row.year == year, row.country == country ]
4
+ in row.nuclearOut + row.gasOut + row.coalOut + row.petrolOut;
5
+ stack year = [ { y: country, z: totalFor year country } | country <- countries ];
6
+ yearData year = [ row | row <- nonRenewables, row.year == year, row.country `elem` countries ]
7
+ in MultiView {
8
+ barChart: BarChart {
9
+ caption: "Non-renewables output",
10
+ size: { width: 275, height: 185 },
11
+ stackedBars: [ { x: numToStr year, bars: stack year } | year <- [2014..2018] ]
12
+ },
13
+ scatterPlot: ScatterPlot {
14
+ caption: "",
15
+ points: [ {
16
+ x: sum [ row.nuclearOut | row <- yearData year ],
17
+ y: sum [ row.nuclearCap | row <- yearData year ]
18
+ } | year <- [2014..2018] ],
19
+ xlabel: "Nuclear capacity",
20
+ ylabel: "Nuclear output"
21
+ }
22
+ }
@@ -0,0 +1,4 @@
1
+ let range1 (m, n) = [m..n];
2
+ range2 ((m1, n1), (m2, n2)) =
3
+ [ (i1, i2) | i1 <- range1 (m1, m2), i2 <- range1 (n1, n2)]
4
+ in range2 ((0, 0), (1, 1))
@@ -0,0 +1,3 @@
1
+ let city = { name: "Germany" };
2
+ country = { cities: [ "Germany" ] }
3
+ in city.name `elem` country.cities
File without changes