zip
Source: /nix/store/mls72plk3raskl1r5afh3cl9ik3rn969-source/nix/zip.nix
Module Description
Zip utilities for combining effects
Combinators
zip
Combines two effects into one producing a pair of values.
Both effects share the same context type. The result is an effect
producing {fst: V1, snd: V2} containing both values.
Type Signature
Fx<S, V2> -> Fx<S, V1> -> Fx<S, {fst: V1, snd: V2}>
Parameters
other: Second effect (providessnd)e: First effect (providesfst)
Example
runFx (zip (pure 2) (pure 1)) # => { fst = 1; snd = 2; }
Notes
The order may seem reversed because it’s designed for piping:
e |> zip other runs e first, then other.
See Also
zipLeft- Keeps only first valuezipRight- Keeps only second value
zipLeft
Combines two effects, keeping only the first value.
Runs both effects in sequence but discards the second value. Useful when the second effect is run only for its side effects.
Type Signature
Fx<S, V2> -> Fx<S, V1> -> Fx<S, V1>
Parameters
other: Second effect (value discarded)e: First effect (value kept)
Example
runFx (zipLeft (pure 2) (pure 1)) # => 1
See Also
zip- Keeps both valueszipRight- Keeps second valuethen'- Similar but second effect runs first conceptually
zipRight
Combines two effects, keeping only the second value.
Runs both effects in sequence but discards the first value. Useful when the first effect is run only for its side effects.
Type Signature
Fx<S, V2> -> Fx<S, V1> -> Fx<S, V2>
Parameters
other: Second effect (value kept)e: First effect (value discarded)
Example
runFx (zipRight (pure 2) (pure 1)) # => 2
See Also
zip- Keeps both valueszipLeft- Keeps first value
Generated from /nix/store/mls72plk3raskl1r5afh3cl9ik3rn969-source/nix/zip.nix