Skip to content

Commit

Permalink
monad -- fmap join bind
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Jun 23, 2024
1 parent 1fed72c commit 8c3fac7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
monads/nothing-monad
用 generic 函数定义 lift -- 删除 `skipIncompleteInputs`
monads/supported-monad -- 删除 `maybeUnwrapSupported`

> propagator 支持 dependencies for provenance
>
> - https://github.com/cicada-lang/propagator/issues/2
fix `maybeUnwrapSupported` -- learn from `nary-unpacking`

`barometer` -- 的测试带上 `promises` -- 用论文中讲故事的方式来写测试

fix `isContradiction` for `Supported`
Expand Down
5 changes: 5 additions & 0 deletions src/monad/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineGeneric } from "../generic/index.js"

export const fmap = defineGeneric({ default: (f, mx) => f(mx) })
export const join = defineGeneric({ default: (mmx) => mmx })
export const bind = (mx: any, f: (x: any) => any) => join(fmap(f, mx))

0 comments on commit 8c3fac7

Please sign in to comment.