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: