Skip to content

Commit

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

Expand Down
7 changes: 7 additions & 0 deletions src/monads/nothing-monad.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { isNothing, nothing } from "../cell/Nothing.js"
import { defineHandler } from "../generic/index.js"
import { fmap, join } from "../monad/index.js"
import { isFunction } from "../utils/isFunction.js"

defineHandler(fmap, [isFunction, isNothing], (f, mx) => nothing)
defineHandler(join, [isNothing], (mmx) => nothing)
3 changes: 3 additions & 0 deletions src/utils/isFunction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function isFunction(x: any): x is Function {
return typeof x === "function"
}

0 comments on commit 4895420

Please sign in to comment.