Public
Edited
Dec 29, 2023
1 fork
Insert cell
Insert cell
mdPlus`## TODO

- [x] convert type level heterogeneous lists to row types
- [x] decide on which purescript lens library to build on
- [x] let's try purescript-profunctor-lenses (Data.Lens)
- make sense to use it since it has the generics deriving.
- [x] let's use the PR which implements VTA for nice syntax.
- [x] let's try and start from the record types slide (at 15:20 on the video) [code](https://github.com/rudihorn/haskell-lenses/blob/master/Lens/Record/Base.hs)
- [x] fetch @"A" rec
- [x] simple update
- [ ] type changing update
- [ ] decide on encoding of schema properties (fundeps <-> unique not null)
`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
module.val
Insert cell
Insert cell
module.greet("me")
Insert cell
Insert cell
module.main()
Insert cell
Insert cell
Insert cell
Insert cell
ps = await Purescript(source)
Insert cell
// module = ps.module
module = ps.module
Insert cell
errors = ps.errors
Insert cell
warnings = ps.warnings
Insert cell
Insert cell
import { Purescript } from '@jmatsushita/purescript'
Insert cell
Purescript
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
PurescriptEditor = async (doc = '', extensions = []) => {
const {StreamLanguage} = await import(`https://jspm.dev/@codemirror/language@6.9.3`)
const { haskell } = await import(`https://jspm.dev/@codemirror/legacy-modes/mode/haskell`);
return CodeMirror(doc, {
extensions: [myDefaultTheme, StreamLanguage.define(haskell), ...extensions]
});
}
Insert cell
Insert cell
import {localStorageView} from '@tomlarkworthy/local-storage-view'
Insert cell
Insert cell
Insert cell
viewof source = localStorageView("part1", { defaultValue: part1 })
Insert cell
// creating a fake source to subscribe from, together with a bound localStorageView didn't work.
// Uncaught TypeError: e.closest is not a function
// at inputs.min.js:40:1444
// viewof source = Inputs.input()
// viewof sourceStorage = localStorageView("sourceStorage")
// Inputs.bind(viewof source, viewof sourceStorage)
// See reproducer here https://observablehq.com/d/f7e7508476855e8b#cell-264
Insert cell
Inputs.bind(viewof editor, viewof source)
Insert cell
// Note you need to get these the right way round to have the page load work correctly
// Inputs.bind(viewof source, viewof sourceStorage)
Insert cell
// set helper
function set(input, value) {
input.value = value;
input.dispatchEvent(new Event("input", {bubbles: true}));
}
Insert cell
Insert cell
toTable = (array, source) => array ? array.map(row => objectFilter(objectMap(row, toReadableRow(source)), hideColumns)) : []
Insert cell
hideColumns = k => k !== "allSpans" && k !== "moduleName" && k !== "filename" && k !== "errorLink"
Insert cell
toColumns = array => array && array[0] ? Object.keys(array[0]).filter(hideColumns) : []
Insert cell
toReadableRow = source => (v,k) => {
switch(k) {
case "allSpans":
return JSON.stringify(v)

case "position":
// console.log(source.split("\n"))
// console.log(source.split("\n").slice(v.startLine - 1, v.endLine))
return source.split("\n").slice(v.startLine - 1, v.endLine).join("\n")
default:
return v;
}
}
Insert cell
toTable(warnings, source)
Insert cell
toColumns(warnings)
Insert cell
warnings
Insert cell
errors.contents
Insert cell
toColumns(errors.contents)
Insert cell
toTable(errors.contents, source)
Insert cell
Insert cell
Insert cell
Insert cell
function unsafe_html() {
const span = document.createElement("span");
span.innerHTML = String.raw.apply(this, arguments);
return span;
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more