commit 498b7dd4b09f2491997df1e0e7f3ef85e6d0a00f
parent cf79187724b1c45985f94a29c038a00876cda1f8
Author: Robert Russell <robert@rr3.xyz>
Date: Fri, 9 Oct 2026 18:47:55 -0700
Haskell.Functional: add ($#)
Diffstat:
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/Lude/Function.hs b/src/Lude/Function.hs
@@ -87,7 +87,7 @@ 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 $# x0)
(.*#) = compose01#
{-# INLINE compose01# #-}
{-# INLINE (.*#) #-}
@@ -107,7 +107,7 @@ 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 $# y) f
(*.#) = compose10#
{-# INLINE compose10# #-}
{-# INLINE (*.#) #-}
@@ -127,7 +127,7 @@ 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 $# y) f
(*.*#) = compose11#
{-# INLINE compose11# #-}
{-# INLINE (*.*#) #-}
diff --git a/src/Lude/Haskell/Category.hs b/src/Lude/Haskell/Category.hs
@@ -95,7 +95,7 @@ identityFunction = lam# \x -> x
composeFunction
:: forall {r :: Repr} (a :: Type# r) {s :: Repr} (b :: Type# s) {t :: Repr} (c :: Type# t)
. (Functional# r, Functional# s) => (b -> c) -> (a -> b) -> (a -> c)
-composeFunction f g = lam# \x -> f `app#` (g `app#` x)
+composeFunction f g = lam# \x -> f $# (g $# x)
{-# INLINE composeFunction #-}
-- | Entailments between two constraints, which form a category
diff --git a/src/Lude/Haskell/Functional.hs b/src/Lude/Haskell/Functional.hs
@@ -1,6 +1,7 @@
module Lude.Haskell.Functional (
Lev,
Functional# (..),
+ ($#),
lam2#,
app2#,
) where
@@ -30,6 +31,10 @@ class Functional# r where
lam# :: forall (a :: Type# r) {s :: Repr} (b :: Type# s). (Lev a -> b) -> (a -> b)
app# :: forall (a :: Type# r) {s :: Repr} (b :: Type# s). (a -> b) -> (Lev a -> b)
+($#) :: forall (r :: Repr) (a :: Type# r) (s :: Repr) (b :: Type# s). (Functional# r) => (a -> b) -> (Lev a -> b)
+($#) = app#
+infixl 1 $#
+
lam2#
:: forall {r0 :: Repr} (a0 :: Type# r0) {r1 :: Repr} (a1 :: Type# r1) {s :: Repr} (b :: Type# s)
. (Functional# r0, Functional# r1) => (Lev a0 -> Lev a1 -> b) -> (a0 -> a1 -> b)