Public
Edited
Sep 29, 2023
Insert cell
Insert cell
Insert cell
m = monet.default
Insert cell
R = import("https://cdn.skypack.dev/ramda@0.29.0")
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
user1 = m.Maybe.of({
name: "Alex",
config: {
notification: true,
passId: 30
}
})
Insert cell
getProp = prop => obj => m.Maybe.fromNull(R.path(prop.split('.'), obj))
Insert cell
p1 = user1.flatMap(getProp('config.notification'))
Insert cell
p1.orSome('Prop undefined')
Insert cell
person = forename => surname => address => `${forename} ${surname} lives in ${address}`
Insert cell
m.Some('Dulwich, London')
.ap(
m.Some('Baker')
.ap(
m.Some('Tom')
.map(person)
)
).some()
Insert cell
m.Maybe.fromEmpty().flatMap(() => m.Some(3))
Insert cell
m.List.fromArray([]).headMaybe()
Insert cell
r = m.Reader(printer => printer.write("hello Alex"))
Insert cell
r2 = m.Reader(val => {
return val + 3
})
Insert cell
r.map(x => `---${x}22---`).run({ write: val => val + 3 })
Insert cell
r2.map(x => x * 2).run(3)
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