From 22ed581b2d3b1480961febc584c9f373c67dcbf4 Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Tue, 27 Jan 2026 11:22:47 +1000 Subject: [PATCH] rename mapMaybe -> bindMaybe --- nt/primitives/bootstrap/maybe.nix | 4 ++-- nt/primitives/bootstrap/nt.nix | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/nt/primitives/bootstrap/maybe.nix b/nt/primitives/bootstrap/maybe.nix index 0bf0dbe..0479bbb 100644 --- a/nt/primitives/bootstrap/maybe.nix +++ b/nt/primitives/bootstrap/maybe.nix @@ -47,8 +47,8 @@ in rec { # unwrapSome = unwrapMaybe (v: v); # unwrapNone = f: unwrapMaybe f (v: v); - # Map (Monadic Bind Operation) - mapMaybe = f: T: + # Monadic Bind Operation + bindMaybe = f: T: if isSome T then Some (f T._value) else T; diff --git a/nt/primitives/bootstrap/nt.nix b/nt/primitives/bootstrap/nt.nix index 114b72d..dbbc777 100644 --- a/nt/primitives/bootstrap/nt.nix +++ b/nt/primitives/bootstrap/nt.nix @@ -16,7 +16,7 @@ inherit (this.maybe) isSome - mapMaybe + bindMaybe ; inherit @@ -30,17 +30,17 @@ in rec { # check if a value is NixTypes compatible isNT = T: openNT T - |> mapMaybe (content: attrNames content |> contains ["sig" "derive" "ops" "req"]) + |> bindMaybe (content: attrNames content |> contains ["sig" "derive" "ops" "req"]) |> isSome; isNTClass = T: openNT T - |> mapMaybe (content: attrNames content == ["sig" "derive" "ops" "req"]) + |> bindMaybe (content: attrNames content == ["sig" "derive" "ops" "req"]) |> isSome; isNTType = T: openNT T - |> mapMaybe (content: + |> bindMaybe (content: attrNames content == ["instance" "sig" "derive" "ops" "req"] && content.instance == false) @@ -48,7 +48,7 @@ in rec { isNTInstance = T: openNT T - |> mapMaybe (content: + |> bindMaybe (content: attrNames content == ["instance" "sig" "derive" "ops" "req"] && content.instance == true) @@ -60,19 +60,19 @@ in rec { impls = type: T: assert enfIsNT T "nt.impls"; openNT T - |> mapMaybe (content: content.derive |> elem (toTypeSig type)) + |> bindMaybe (content: content.derive |> elem (toTypeSig type)) |> isSome; is = type: T: assert enfIsNT T "nt.is"; openNT T - |> mapMaybe (content: content.sig == toTypeSig type) + |> bindMaybe (content: content.sig == toTypeSig type) |> isSome; typeSig = T: assert enfIsNT T "nt.typeSig"; openNT T - |> mapMaybe (getAttr "sig") + |> bindMaybe (getAttr "sig") |> isSome; toTypeSig = x: