lude

Haskell prelude alternative
git clone git://git.rr3.xyz/lude | git clone gits://git.rr3.xyz/lude
Log | Files | Refs | README | LICENSE

commit cf79187724b1c45985f94a29c038a00876cda1f8
parent 8a08a6d4c56c291103896cf699e62298eb2bb59b
Author: Robert Russell <robert@rr3.xyz>
Date:   Fri,  9 Oct 2026 18:12:34 -0700

Move fixity declarations

I put them at the top previously because fourmolu puts a space between a declaration with a doc comment and fixity declarations, but that's a stupid reason.

Diffstat:
Msrc/Lude/Algebra/Category/Bifunctor.hs | 5+----
Msrc/Lude/Algebra/Category/Core.hs | 9+++------
Msrc/Lude/Algebra/Category/Monad.hs | 9++++-----
Msrc/Lude/Constraint/Core.hs | 6++----
Msrc/Lude/Equivalence.hs | 13++++++-------
Msrc/Lude/Function.hs | 16+++++++++-------
Msrc/Lude/Haskell/Category.hs | 21++++++++++++++++-----
Msrc/Lude/Order/Partial.hs | 14++++++++------
Msrc/Lude/Order/Total.hs | 5++++-
Msrc/Lude/Pair.hs | 5+----
10 files changed, 54 insertions(+), 49 deletions(-)

diff --git a/src/Lude/Algebra/Category/Bifunctor.hs b/src/Lude/Algebra/Category/Bifunctor.hs @@ -29,10 +29,6 @@ import Lude.Pair -------------------------------------------------------------------------------- -infixl 1 $^^ - --------------------------------------------------------------------------------- - -- NOTE: We ought not need to assume that BidomR p and Bicod p are categorical, -- because the Categorical (NT _ _) instance assumes it, but maybe there's -- some reason the constraint solver can't safely deduce that. @@ -123,6 +119,7 @@ bicomp m = comp (comp m) ($^^) :: forall {i} {j} (p :: Cat i) (q :: Cat j) (f :: i -> j -> Type) (g :: i -> j -> Type) (x :: i) (y :: j). (Obj p x, Obj q y) => NT p (q ==> Function) f g -> f x y -> g x y ($^^) h = bicomp h +infixl 1 $^^ -------------------------------------------------------------------------------- diff --git a/src/Lude/Algebra/Category/Core.hs b/src/Lude/Algebra/Category/Core.hs @@ -41,12 +41,6 @@ import Lude.List -------------------------------------------------------------------------------- -infixr 9 . -infixr 1 ==> -infixl 1 $^ - --------------------------------------------------------------------------------- - type DefaultCat :: forall i -> Cat i type family DefaultCat i type instance DefaultCat (Type# r) = Function# r @@ -81,6 +75,7 @@ instance (Obj p a, Obj p b, Obj p c) => Obj3 p a b c (.) :: forall {i} (p :: Cat i) (a :: i) (b :: i) (c :: i). (Categorical p) => b `p` c -> a `p` b -> a `p` c (.) = compose +infixr 9 . -- TODO: Flipped composition operator? More composition operators for CCCs? @@ -171,6 +166,7 @@ data NT p q f g = (FunctorialOn p q f, FunctorialOn p q g) => Naturally {comp :: type (==>) :: forall i j. Cat i -> Cat j -> Cat (i -> j) type (==>) = NT +infixr 1 ==> type NTDom :: forall i j. Cat (i -> j) -> Cat i type family NTDom _ where @@ -201,6 +197,7 @@ instance (Categorical p, Categorical q) => Functorial (NT p q) where ($^) :: forall {i} (p :: Cat i) (f :: i -> Type) (g :: i -> Type) (x :: i). (Obj p x) => NT p Function f g -> f x -> g x ($^) h = comp h +infixl 1 $^ -------------------------------------------------------------------------------- -- Haskell diff --git a/src/Lude/Algebra/Category/Monad.hs b/src/Lude/Algebra/Category/Monad.hs @@ -25,11 +25,6 @@ import Lude.List -------------------------------------------------------------------------------- -infixl 1 >>=, >> -infixr 1 =<<, << - --------------------------------------------------------------------------------- - type Monadic :: forall {i}. Endo i -> Constraint class (Endofunctorial f) => Monadic (f :: Endo i) where {-# MINIMAL pure, (join | bind) #-} @@ -60,15 +55,19 @@ instance Monadic ((->) r) where (>>=) :: forall f a b. (MonadicOn Function f) => f a -> (a -> f b) -> f b (>>=) = flip bind +infixl 1 >>= (=<<) :: forall f a b. (MonadicOn Function f) => (a -> f b) -> f a -> f b (=<<) = bind +infixr 1 =<< (>>) :: forall f a b. (MonadicOn Function f) => f a -> f b -> f b fa >> fb = bind (const fb) fa +infixl 1 >> (<<) :: forall f a b. (MonadicOn Function f) => f a -> f b -> f a fa << fb = bind (\a -> fb >> pure a) fa +infixr 1 << -------------------------------------------------------------------------------- -- Interop diff --git a/src/Lude/Constraint/Core.hs b/src/Lude/Constraint/Core.hs @@ -13,15 +13,12 @@ import Lude.Haskell -------------------------------------------------------------------------------- -infixl 7 & - --------------------------------------------------------------------------------- - type And :: Biendo Constraint type And = GHC.CTuple2 type (&) :: Biendo Constraint type (&) = And +infixl 7 & type And' :: forall {k}. Biendo (Predicate k) class (a x, b x) => And' a b x @@ -29,3 +26,4 @@ instance (a x, b x) => And' a b x type (:&:) :: forall {k}. Biendo (Predicate k) type (:&:) = And' +infixl 7 :&: diff --git a/src/Lude/Equivalence.hs b/src/Lude/Equivalence.hs @@ -3,7 +3,8 @@ module Lude.Equivalence ( Equivalential (..), (==), - (<>), + (/=), + (≠), ) where import Data.Coerce @@ -15,10 +16,6 @@ import Lude.Haskell -------------------------------------------------------------------------------- -infix 4 ==, <> - --------------------------------------------------------------------------------- - type Equivalential :: forall {r :: Repr}. Type# r -> Constraint class Equivalential (a :: Type# r) where {-# MINIMAL eq | ne #-} @@ -33,9 +30,11 @@ class Equivalential (a :: Type# r) where ne = lam2# \x y -> not (app2# eq x y) {-# INLINE ne #-} -(==), (<>) :: forall {r :: Repr} (a :: Type# r). (Equivalential a) => a -> a -> Bool +(==), (/=), (≠) :: forall {r :: Repr} (a :: Type# r). (Equivalential a) => a -> a -> Bool (==) = eq -(<>) = ne +(/=) = ne +(≠) = ne +infix 4 ==, /=, ≠ -------------------------------------------------------------------------------- -- Generics diff --git a/src/Lude/Function.hs b/src/Lude/Function.hs @@ -32,24 +32,19 @@ import Lude.Haskell -------------------------------------------------------------------------------- -infixl 1 $ -infixl 0 & -infixr 9 .*, *., *.* -infixr 9 .#, .*#, *.#, *.*# - --------------------------------------------------------------------------------- - app, ($) :: forall {r :: Repr} (a :: Type# r) {s :: Repr} (b :: Type# s). (a -> b) -> (a -> b) app f = f ($) = app {-# INLINE app #-} {-# INLINE ($) #-} +infixl 1 $ rapp, (&) :: forall {r :: Repr} (a :: Type# r) {s :: Repr} (b :: Type# s). (Functional# r) => a -> (a -> b) -> b rapp = lam# \x f -> app# f x (&) = rapp {-# INLINE rapp #-} {-# INLINE (&) #-} +infixl 0 & const :: forall {r :: Repr} (a :: Type# r) {s :: Repr} (b :: Type# s) @@ -80,6 +75,7 @@ compose00# = composeFunction (.#) = compose00# {-# INLINE compose00# #-} {-# INLINE (.#) #-} +infixr 9 .# compose00 :: forall (a0 :: Type) (b :: Type) (c :: Type) @@ -95,6 +91,7 @@ compose01# g f = lam# \x0 -> compose00# g (f `app#` x0) (.*#) = compose01# {-# INLINE compose01# #-} {-# INLINE (.*#) #-} +infixr 9 .*# compose01, (.*) @@ -104,6 +101,7 @@ compose01 = compose01# (.*) = compose01 {-# INLINE compose01 #-} {-# INLINE (.*) #-} +infixr 9 .* compose10#, (*.#) @@ -113,6 +111,7 @@ compose10# g f = lam# \y -> compose00# (g `app#` y) f (*.#) = compose10# {-# INLINE compose10# #-} {-# INLINE (*.#) #-} +infixr 9 *.# compose10, (*.) @@ -122,6 +121,7 @@ compose10 = compose10# (*.) = compose10 {-# INLINE compose10 #-} {-# INLINE (*.) #-} +infixr 9 *. compose11#, (*.*#) @@ -131,6 +131,7 @@ compose11# g f = lam# \y -> compose01# (g `app#` y) f (*.*#) = compose11# {-# INLINE compose11# #-} {-# INLINE (*.*#) #-} +infixr 9 *.*# compose11, (*.*) @@ -140,3 +141,4 @@ compose11 = compose11# (*.*) = compose11 {-# INLINE compose11 #-} {-# INLINE (*.*) #-} +infixr 9 *.* diff --git a/src/Lude/Haskell/Category.hs b/src/Lude/Haskell/Category.hs @@ -62,11 +62,6 @@ import Lude.Haskell.Type -- NOTE: `Entailment`/`:-` is to `Constraint` what `Function`/`->` is to `Type`. -------------------------------------------------------------------------------- - -infixr 1 ~>, ~~>, :-, :~, :~~, :|=, :|- -infixl 1 \\ - --------------------------------------------------------------------------------- -- The Function and Entailment categories -- | The kind of categories @@ -85,10 +80,14 @@ type Function = Function# Repr.BoxL type (~>) :: forall i (r :: Repr) (s :: Repr). (i -> Type# r) -> (i -> Type# s) -> Type type f ~> g = forall x. f x -> g x +infixr 1 ~> + -- | Binatural transformations to `Function`/`->` type (~~>) :: forall i j (r :: Repr) (s :: Repr). (i -> j -> Type# r) -> (i -> j -> Type# s) -> Type type f ~~> g = forall x y. f x y -> g x y +infixr 1 ~~> + identityFunction :: forall {r :: Repr} (a :: Type# r). (Functional# r) => a -> a identityFunction = lam# \x -> x {-# INLINE identityFunction #-} @@ -107,14 +106,20 @@ newtype Entailment a b = Entail {unEntail :: (a) => Evidence b} type (:-) :: Cat Constraint type (:-) = Entailment +infixr 1 :- + -- | Natural transformations to `Entailment`/`:-` type (:~) :: forall i. Cat (i -> Constraint) type f :~ g = forall x. f x :- g x +infixr 1 :~ + -- | Binatural transformations to `Entailment`/`:-` type (:~~) :: forall i j. Cat (i -> j -> Constraint) type f :~~ g = forall x y. f x y :- g x y +infixr 1 :~~ + identityEntailment :: forall a. a :- a identityEntailment = Entail MkEvidence @@ -251,6 +256,8 @@ class Witnesses a b | a -> b where -- | Alias for `Witnesses` type (:|=) = Witnesses +infixr 1 :|= + instance forall a. Evidence a `Witnesses` a where witness = identityFunction instance forall a b. (a) => (a :- b) `Witnesses` b where @@ -272,6 +279,8 @@ class Provisions a b | a -> b where -- | Alias for `Provisions` type (:|-) = Provisions +infixr 1 :|- + instance forall a. Given a `Provisions` a where provision = identityEntailment @@ -287,5 +296,7 @@ because, (\\) :: forall a c b. (a :|= b) => ((b) => c) -> a -> c because bc = MkCowitness bc `composeFunction` witness (\\) = because +infixl 1 \\ + tautology :: forall a b. (b) => a :- b tautology = Entail MkEvidence diff --git a/src/Lude/Order/Partial.hs b/src/Lude/Order/Partial.hs @@ -1,12 +1,15 @@ module Lude.Order.Partial ( Ordering (..), (==), - (<>), + (/=), + (≠), -- PartiallyOrdered (..), (<), (<=), + (≤), (>=), + (≥), (>), ) where @@ -22,10 +25,6 @@ import Lude.Order.Ordering -------------------------------------------------------------------------------- -infix 4 <, <=, >=, > - --------------------------------------------------------------------------------- - type PartiallyOrdered :: forall {r :: Repr}. Type# r -> Constraint class (Equivalential a) => PartiallyOrdered (a :: Type# r) where {-# MINIMAL pcmp #-} @@ -48,11 +47,14 @@ class (Equivalential a) => PartiallyOrdered (a :: Type# r) where default gt :: (Functional# r) => a -> a -> Bool gt = lam2# \x y -> case app2# pcmp x y of Just GT -> True; _ -> False -(<), (<=), (>=), (>) :: forall {r :: Repr} (a :: Type# r). (PartiallyOrdered a) => a -> a -> Bool +(<), (<=), (≤), (>=), (≥), (>) :: forall {r :: Repr} (a :: Type# r). (PartiallyOrdered a) => a -> a -> Bool (<) = lt (<=) = le +(≤) = le (>=) = ge +(≥) = ge (>) = gt +infix 4 <, <=, ≤, >=, ≥, > -------------------------------------------------------------------------------- -- Generics diff --git a/src/Lude/Order/Total.hs b/src/Lude/Order/Total.hs @@ -1,10 +1,13 @@ module Lude.Order.Total ( Ordering (..), (==), - (<>), + (/=), + (≠), (<), (<=), + (≤), (>=), + (≥), (>), -- TotallyOrdered (..), diff --git a/src/Lude/Pair.hs b/src/Lude/Pair.hs @@ -32,13 +32,10 @@ import Lude.Haskell -------------------------------------------------------------------------------- -infixl 7 *, × - --------------------------------------------------------------------------------- - type Pair = Tuple2 type (*) = Tuple2 type (×) = Tuple2 +infixl 7 *, × -- For consistency type MkPair :: a -> b -> a × b