@explorable-viz/fluid 0.7.88 → 0.7.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +11 -6
  2. package/dist/fluid/fluid/lib/matrix.fld +39 -0
  3. package/dist/fluid/fluid/lib/prelude.fld +2 -2
  4. package/dist/fluid/fluid/lib/stats.fld +21 -22
  5. package/dist/fluid/shared/fluid.mjs +3253 -4601
  6. package/dist/fluid/shared/load-figure.js +6653 -5851
  7. package/dist/fluid/shared/webtest-lib.js +18 -18
  8. package/package.json +2 -3
  9. package/script/bundle-website.sh +8 -29
  10. package/.spago/affjax-node/v1.0.0/.editorconfig +0 -13
  11. package/.spago/affjax-node/v1.0.0/.eslintrc.json +0 -30
  12. package/.spago/affjax-node/v1.0.0/.gitignore +0 -13
  13. package/.spago/argonaut/v9.0.0/.editorconfig +0 -13
  14. package/.spago/argonaut/v9.0.0/.gitignore +0 -9
  15. package/.spago/argonaut/v9.0.0/.tidyrc.json +0 -10
  16. package/.spago/argonaut-traversals/v10.0.0/.editorconfig +0 -13
  17. package/.spago/argonaut-traversals/v10.0.0/.gitignore +0 -9
  18. package/.spago/argonaut-traversals/v10.0.0/.tidyrc.json +0 -10
  19. package/.spago/avar/v5.0.0/.editorconfig +0 -13
  20. package/.spago/avar/v5.0.0/.eslintrc.json +0 -29
  21. package/.spago/avar/v5.0.0/.gitignore +0 -14
  22. package/.spago/avar/v5.0.0/.tidyrc.json +0 -10
  23. package/.spago/fork/v6.0.0/.editorconfig +0 -13
  24. package/.spago/fork/v6.0.0/.gitignore +0 -9
  25. package/.spago/fork/v6.0.0/.tidyrc.json +0 -10
  26. package/.spago/node-http/v8.0.0/.eslintrc.json +0 -29
  27. package/.spago/node-http/v8.0.0/.gitignore +0 -8
  28. package/.spago/node-net/v4.0.0/.eslintrc.json +0 -29
  29. package/.spago/node-net/v4.0.0/.gitignore +0 -8
  30. package/.spago/node-url/v6.0.0/.eslintrc.json +0 -26
  31. package/.spago/node-url/v6.0.0/.gitignore +0 -8
  32. package/.spago/options/v7.0.0/.editorconfig +0 -13
  33. package/.spago/options/v7.0.0/.gitignore +0 -9
  34. package/.spago/options/v7.0.0/.tidyrc.json +0 -10
  35. package/.spago/pathy/v9.0.0/.editorconfig +0 -13
  36. package/.spago/pathy/v9.0.0/.gitignore +0 -9
  37. package/.spago/pathy/v9.0.0/.tidyrc.json +0 -10
  38. package/.spago/profunctor-lenses/v8.0.0/.editorconfig +0 -13
  39. package/.spago/profunctor-lenses/v8.0.0/.gitignore +0 -9
  40. package/.spago/profunctor-lenses/v8.0.0/.tidyrc.json +0 -10
  41. package/dist/fluid/fluid/lib/convolution.fld +0 -31
  42. package/script/bundle-page.sh +0 -30
package/README.md CHANGED
@@ -9,7 +9,7 @@ Fluid is an experimental programming language which integrates a bidirectional d
9
9
 
10
10
  ### Software required
11
11
  - git
12
- - Node.js >=14.0.0
12
+ - Node.js >=18.0.0
13
13
  - yarn >= 1.22
14
14
 
15
15
  Additionally, for Windows users only:
@@ -20,11 +20,12 @@ Additionally, for Windows users only:
20
20
 
21
21
  - Clone the repository (for Windows users, do this under the Ubuntu WSL)
22
22
  - Run `./script/setup/dev-setup.sh` from the top-level directory
23
- - Run `yarn build`
23
+ - `yarn install` to install Node dependencies
24
+ - `yarn build`
24
25
 
25
26
  ## Use
26
27
 
27
- The following assumes you have already succesfully run `yarn build` (see above).
28
+ The following assumes you have already successfully run `yarn build` (see above).
28
29
 
29
30
  ### Running programs from the command line
30
31
 
@@ -41,10 +42,14 @@ Note that the path is relative and should not include the `.fld` extension, e.g.
41
42
  Success
42
43
  ```
43
44
 
44
- ### Running the fluid.org website locally
45
+ ### Running websites locally (as part of Fluid development)
46
+ As an example, to build and run the website `literate-execution`:
47
+ - `yarn build` to ensure Fluid source code has been compiled (can be skipped on subsequent runs)
48
+ - `yarn bundle-website -w literate-execution` (can be skipped if the website being run is `fluid-org`)
49
+ - `yarn serve literate-execution` (you may be prompted to proceed; press `y`)
50
+ - Open a browser to the served URL (defaults to `127.0.0.1:8080`)
45
51
 
46
- - `yarn serve fluid-org` (you may be prompted to proceed: type `y`).
47
- - Open a browser at the served URL (usually `127.0.0.1:8080`)
52
+ Note: `yarn bundle-serve literate-execution` is a convenient shorthand for `bundle-website -w` followed by `serve`.
48
53
 
49
54
  ## Testing
50
55
 
@@ -0,0 +1,39 @@
1
+ let zero m n image =
2
+ let (m_max, n_max) = dims image
3
+ in if (m >= 1) `and` (m <= m_max) `and` (n >= 1) `and` (n <= n_max)
4
+ then image!(m, n)
5
+ else 0;
6
+
7
+ let wrap m n image =
8
+ let (m_max, n_max) = dims image
9
+ in image!( ((m - 1) `mod` m_max) + 1, ((n - 1) `mod` n_max) + 1);
10
+
11
+ let extend m n image =
12
+ let (m_max, n_max) = dims image;
13
+ m' = min (max m 1) m_max;
14
+ n' = min (max n 1) n_max
15
+ in image!(m', n');
16
+
17
+ let matrixSum matr =
18
+ let (m, n) = dims matr
19
+ in foldl (+) 0 [ matr!(i, j) | (i, j) <- range (1, 1) (m, n)];
20
+
21
+ let convolve image kernel lookup =
22
+ let ((m, n), (i, j)) = (dims image, dims kernel);
23
+ (half_i, half_j) = (i `quot` 2, j `quot` 2);
24
+ area = i * j
25
+ in [| let interMatrix =
26
+ """Intermediate matrix for element (${m'}, ${n'})"""
27
+ [| let x = m' + i' - 1 - half_i;
28
+ y = n' + j' - 1 - half_j in
29
+ lookup x y image * kernel!(i', j')
30
+ | (i', j') in (i, j) |]
31
+ in matrixSum interMatrix `quot` area
32
+ | (m', n') in (m, n) |];
33
+
34
+ let matMul a b =
35
+ let ((m, n), (i, j)) = (dims a, dims b) in
36
+ if not (n == i)
37
+ then error "Dimension mismatch"
38
+ else [| sum [ a!(i', k) * b!(k, j') | k <- enumFromTo 1 n]
39
+ | (i', j') in (m, j) |];
@@ -267,9 +267,9 @@ let slice begin end xs =
267
267
 
268
268
 
269
269
  -- (a -> Boolean) -> List a -> (List a, List a)
270
- let splitOn p data =
270
+ let splitOn p data =
271
271
  let go fls trs [] = (reverse fls, reverse trs);
272
- go fls trs (x : xs) =
272
+ go fls trs (x : xs) =
273
273
  if p x
274
274
  then go fls (x : trs) xs
275
275
  else go (x : fls) trs xs
@@ -19,46 +19,45 @@ let mergesort xs =
19
19
  let (ys, zs) = split xs in
20
20
  merge (mergesort ys) (mergesort zs);
21
21
 
22
- -- assume data is sorted
23
- let findQuantile q p data =
24
- let rank = (p / q) * (length data - 1)
22
+ -- assume xs is sorted
23
+ let findQuantile q p xs =
24
+ let rank = (p / q) * (length xs - 1)
25
25
  in if rank == floor rank
26
- then nth rank data
26
+ then nth rank xs
27
27
  else let x1 = floor rank;
28
28
  x2 = ceiling rank;
29
- left = nth x1 data;
30
- right = nth x2 data
29
+ left = nth x1 xs;
30
+ right = nth x2 xs
31
31
  in left + (rank - x1) * (right - left);
32
32
 
33
33
  let findPercentile = findQuantile 100;
34
34
 
35
35
  let accumBins data Nil = [];
36
36
  accumBins data [l] = [];
37
- accumBins data (l : r : es) =
37
+ accumBins data (l : r : es) =
38
38
  let (ge, le) = splitOn (fun x -> x <= r) data
39
- in (le , r - l) : accumBins ge (r : es);
39
+ in (le, r - l) : accumBins ge (r : es);
40
40
 
41
- let cut data nbins =
42
- let low = minimum data;
43
- binwidth = (maximum data - low) / nbins;
41
+ let cut xs nbins =
42
+ let low = minimum xs;
43
+ binwidth = (maximum xs - low) / nbins;
44
44
  edges = [ low + (x * binwidth) | x <- enumFromTo 0 nbins ]
45
- in accumBins data edges;
45
+ in accumBins xs edges;
46
46
 
47
- let qcut data qs =
48
- let low = minimum data;
49
- high = maximum data;
50
- edges = append (low : [ findPercentile x data | x <- qs], [high])
51
- in accumBins data edges;
47
+ let qcut xs qs =
48
+ let (low, high) = (minimum xs, maximum xs);
49
+ edges = append (low : [ findPercentile x xs | x <- qs], [high])
50
+ in accumBins xs edges;
52
51
 
53
- let likelihoodLE data target =
54
- length (filter (fun x -> x <= target) data) / length data;
52
+ let likelihoodLE xs target =
53
+ length (filter (fun x -> x <= target) xs) / length xs;
55
54
 
56
- let likelihoodGE data target =
57
- length (filter (fun x -> x >= target) data) / length data;
55
+ let likelihoodGE xs target =
56
+ length (filter (fun x -> x >= target) xs) / length xs;
58
57
 
59
58
  let likelihoodMap table prob = (fromSome (find (fun x -> x.prob <= prob) table)).msg;
60
59
 
61
- let mkPercent num = (numToStr (num * 100)) ++ "%";
60
+ let mkPercent num = numToStr (num * 100) ++ "%";
62
61
 
63
62
  let leqP n m =
64
63
  if n <= m