commit 30290c425b527854126ea04482d68b5be9feeabd
parent dfda2dd288c7d211f21a364e46ffd83023467fe3
Author: Robert Russell <robert@rr3.xyz>
Date: Sun, 4 Oct 2026 14:02:11 -0700
Function: add "#" to end of composition operators to avoid conflict with Algebra.Category (tentative/temporary)
Diffstat:
2 files changed, 58 insertions(+), 20 deletions(-)
diff --git a/src/Lude/Function.hs b/src/Lude/Function.hs
@@ -1,5 +1,4 @@
module Lude.Function (
- identity,
app,
($),
rapp,
@@ -8,30 +7,36 @@ module Lude.Function (
flip,
on,
fork,
+ compose00#,
+ (.#),
compose00,
-- (.),
+ compose01#,
+ (.*#),
compose01,
(.*),
+ compose10#,
+ (*.#),
compose10,
(*.),
+ compose11#,
+ (*.*#),
compose11,
(*.*),
) where
import Data.Function (($))
-import Lude.Algebra.Category.Core (identity)
import Lude.Haskell
-- TODO: Generalize some of this? E.g., for CCCs?
--- TODO: How should we deal with the (.) naming conflict with category?
-
-- TODO: Repr-generic S combinators?
--------------------------------------------------------------------------------
-infixr 9 ., .*, *., *.*
+infixr 9 .*, *., *.*
+infixr 9 .#, .*#, *.#, *.*#
--------------------------------------------------------------------------------
@@ -72,38 +77,71 @@ fork f g h = lam# \x -> app2# f (app# g x) (app# h x)
--------------------------------------------------------------------------------
-- Composition
-compose00,
- (.)
+compose00#,
+ (.#)
:: forall {r0 :: Repr} (a0 :: Type# r0) {s :: Repr} (b :: Type# s) {t :: Repr} (c :: Type# t)
. (Functional# r0, Functional# s) => (b -> c) -> (a0 -> b) -> (a0 -> c)
-compose00 = composeFunction
-(.) = compose00
+compose00# = composeFunction
+(.#) = compose00#
+{-# INLINE compose00# #-}
+{-# INLINE (.#) #-}
+
+compose00
+ :: forall (a0 :: Type) (b :: Type) (c :: Type)
+ . (b -> c) -> (a0 -> b) -> (a0 -> c)
+compose00 = compose00#
{-# INLINE compose00 #-}
-{-# INLINE (.) #-}
-compose01,
- (.*)
+compose01#,
+ (.*#)
:: forall {r0 :: Repr} (a0 :: Type# r0) {r1 :: Repr} (a1 :: Type# r1) {s :: Repr} (b :: Type# s) {t :: Repr} (c :: Type# t)
. (Functional# r0, Functional# r1, Functional# s) => (b -> c) -> (a0 -> a1 -> b) -> (a0 -> a1 -> c)
-compose01 g f = lam# \x0 -> compose00 g (f `app#` x0)
+compose01# g f = lam# \x0 -> compose00# g (f `app#` x0)
+(.*#) = compose01#
+{-# INLINE compose01# #-}
+{-# INLINE (.*#) #-}
+
+compose01,
+ (.*)
+ :: forall (a0 :: Type) (a1 :: Type) (b :: Type) (c :: Type)
+ . (b -> c) -> (a0 -> a1 -> b) -> (a0 -> a1 -> c)
+compose01 = compose01#
(.*) = compose01
{-# INLINE compose01 #-}
{-# INLINE (.*) #-}
-compose10,
- (*.)
+compose10#,
+ (*.#)
:: forall {r0 :: Repr} (a0 :: Type# r0) {s0 :: Repr} (b0 :: Type# s0) {s :: Repr} (b :: Type# s) {t :: Repr} (c :: Type# t)
. (Functional# r0, Functional# s0, Functional# s) => (b0 -> b -> c) -> (a0 -> b) -> (b0 -> a0 -> c)
-compose10 g f = lam# \y -> compose00 (g `app#` y) f
+compose10# g f = lam# \y -> compose00# (g `app#` y) f
+(*.#) = compose10#
+{-# INLINE compose10# #-}
+{-# INLINE (*.#) #-}
+
+compose10,
+ (*.)
+ :: forall (a0 :: Type) (b0 :: Type) (b :: Type) (c :: Type)
+ . (b0 -> b -> c) -> (a0 -> b) -> (b0 -> a0 -> c)
+compose10 = compose10#
(*.) = compose10
{-# INLINE compose10 #-}
{-# INLINE (*.) #-}
-compose11,
- (*.*)
+compose11#,
+ (*.*#)
:: forall {r0 :: Repr} (a0 :: Type# r0) {r1 :: Repr} (a1 :: Type# r1) {s0 :: Repr} (b0 :: Type# s0) {s :: Repr} (b :: Type# s) {t :: Repr} (c :: Type# t)
. (Functional# r0, Functional# r1, Functional# s0, Functional# s) => (b0 -> b -> c) -> (a0 -> a1 -> b) -> (b0 -> a0 -> a1 -> c)
-compose11 g f = lam# \y -> compose01 (g `app#` y) f
+compose11# g f = lam# \y -> compose01# (g `app#` y) f
+(*.*#) = compose11#
+{-# INLINE compose11# #-}
+{-# INLINE (*.*#) #-}
+
+compose11,
+ (*.*)
+ :: forall (a0 :: Type) (a1 :: Type) (b0 :: Type) (b :: Type) (c :: Type)
+ . (b0 -> b -> c) -> (a0 -> a1 -> b) -> (b0 -> a0 -> a1 -> c)
+compose11 = compose11#
(*.*) = compose11
{-# INLINE compose11 #-}
{-# INLINE (*.*) #-}
diff --git a/src/Lude/Order/Total.hs b/src/Lude/Order/Total.hs
@@ -30,7 +30,7 @@ class (Latticed a) => TotallyOrdered (a :: Type# r) where
cmp :: a -> a -> Ordering
default cmp :: (Functional# r) => a -> a -> Ordering
- cmp = unsafe_fromJust .* pcmp
+ cmp = unsafe_fromJust .*# pcmp
min, max :: forall {r :: Repr} (a :: Type# r). (TotallyOrdered a) => Biendo a
min = glb