Skip to content

pipe

Calling pipe with a list of operations is a do pipeline over the Id monad. Because M a = a for Id, all Nix values work without any wrapping:

let
x = pipe [ (n: n * 2) (n: n + 1) ];
y = pipe [ (n: n / 2) (n: n - 1) ];
z = pipe [ x y ]; # subpipes are first class
in z 100

You can also define your own monad instances (the library ships Id and Maybe). Pipelines can be generic over the monad type and run unchanged on different instances.

  • Drop in lib.pipe, composable |> with first class subpipes
  • Freer monad core, do style sequencing over any monad
  • Bring your own monad, define pure / bind / isM for custom instances
  • Monad generic pipelines, write once, run on Id, Maybe, or your own

pipe is the lightweight functional glue of the ecosystem, monadic composition without ceremony. It pairs naturally with nfx’s algebraic effects when you need structured sequencing in plain Nix.

Source Code Support this project