commit 3ec2498811182f8374267dc14cda113346fb6093
parent 79de4f2c7452ec562e8f5b54be650e44fc764fc8
Author: Robert Russell <robert@rr3.xyz>
Date: Sat, 19 Sep 2026 15:46:51 -0700
Function: add fork (phi combinator)
Diffstat:
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/Lude.hs b/src/Lude.hs
@@ -7,7 +7,7 @@ import Lude.Bool as X
import Lude.Constraint as X
import Lude.Equivalence as X
import Lude.Error as X
-import Lude.Function as X hiding ((.))
+import Lude.Function as X
import Lude.Haskell as X
import Lude.IO as X
import Lude.List as X
diff --git a/src/Lude/Function.hs b/src/Lude/Function.hs
@@ -7,8 +7,9 @@ module Lude.Function (
const,
flip,
on,
+ fork,
compose00,
- (.),
+ -- (.),
compose01,
(.*),
compose10,
@@ -26,7 +27,7 @@ import Lude.Haskell
-- TODO: How should we deal with the (.) naming conflict with category?
--- TODO: Repr-generic S and Phi combinators?
+-- TODO: Repr-generic S combinators?
--------------------------------------------------------------------------------
@@ -58,6 +59,12 @@ on
on f g = lam2# \x y -> app2# f (app# g x) (app# g y)
{-# INLINE on #-}
+fork
+ :: forall {r :: Repr} (a :: Type @r) {s :: Repr} (b :: Type @s) {t :: Repr} (c :: Type @t) {u :: Repr} (d :: Type @u)
+ . (Functional# r, Functional# s, Functional# t) => (b -> c -> d) -> (a -> b) -> (a -> c) -> (a -> d)
+fork f g h = lam# \x -> app2# f (app# g x) (app# h x)
+{-# INLINE fork #-}
+
--------------------------------------------------------------------------------
-- Composition