lude

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

commit c7d572c46f5c458a5a6a079db41f0bf6fdabca1e
parent b514c9d4029467a239fcd945223a0995b53fe7f2
Author: Robert Russell <robert@rr3.xyz>
Date:   Tue, 22 Sep 2026 14:41:22 -0700

Haskell: make Repr arguments explicit

This makes representations visible in diagnostic messages. Previously, you'd just get something like `forall {r :: Repr}. Type`, when really it was `forall {r
:: Repr}. Type @r`.

Diffstat:
Msrc/Lude/Algebra/Category/Core.hs | 2+-
Msrc/Lude/Equivalence.hs | 6+++---
Msrc/Lude/Function.hs | 30+++++++++++++++---------------
Msrc/Lude/Haskell/Category.hs | 10+++++-----
Msrc/Lude/Haskell/Constraint.hs | 29+++++++++++++++++++----------
Msrc/Lude/Haskell/Functional.hs | 10+++++-----
Msrc/Lude/Haskell/Generic.hs | 8++++----
Msrc/Lude/Haskell/Kind.hs | 25++++++++++++++++---------
Msrc/Lude/Haskell/Type.hs | 18+++++++++++-------
Msrc/Lude/Order/Bound.hs | 6+++---
Msrc/Lude/Order/Lattice.hs | 12++++++------
Msrc/Lude/Order/Partial.hs | 6+++---
Msrc/Lude/Order/Total.hs | 6+++---
13 files changed, 94 insertions(+), 74 deletions(-)

diff --git a/src/Lude/Algebra/Category/Core.hs b/src/Lude/Algebra/Category/Core.hs @@ -201,7 +201,7 @@ instance forall (r :: Repr). (Functional# r) => Categorical (Function @r) where identity = identityFunction compose = composeFunction -instance forall (r :: Repr) (a :: Type @r). (Functional# r) => Functorial (Function @r a) where +instance forall (r :: Repr) (a :: Type# r). (Functional# r) => Functorial (Function @r a) where type Dom (Function a) = Function type Cod (Function a) = Function map = compose diff --git a/src/Lude/Equivalence.hs b/src/Lude/Equivalence.hs @@ -19,8 +19,8 @@ infix 4 ==, <> -------------------------------------------------------------------------------- -type Equivalential :: forall {r :: Repr}. Type @r -> Constraint -class Equivalential (a :: Type @r) where +type Equivalential :: forall {r :: Repr}. Type# r -> Constraint +class Equivalential (a :: Type# r) where {-# MINIMAL eq | ne #-} eq :: a -> a -> Bool @@ -33,7 +33,7 @@ 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 diff --git a/src/Lude/Function.hs b/src/Lude/Function.hs @@ -31,36 +31,36 @@ import Lude.Haskell -------------------------------------------------------------------------------- -app :: forall {r :: Repr} (a :: Type @r) {s :: Repr} (b :: Type @s). (a -> b) -> (a -> b) +app :: forall {r :: Repr} (a :: Type# r) {s :: Repr} (b :: Type# s). (a -> b) -> (a -> b) app = ($) {-# INLINE app #-} -rapp, (&) :: forall {r :: Repr} (a :: Type @r) {s :: Repr} (b :: Type @s). (Functional# r) => a -> (a -> b) -> b +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 (&) #-} const - :: forall {r :: Repr} (a :: Type @r) {s :: Repr} (b :: Type @s) + :: forall {r :: Repr} (a :: Type# r) {s :: Repr} (b :: Type# s) . (Functional# r, Functional# s) => a -> (b -> a) const = lam2# \x _ -> x {-# INLINE const #-} flip - :: forall {r :: Repr} (a :: Type @r) {s :: Repr} (b :: Type @s) {t :: Repr} (c :: Type @t) + :: forall {r :: Repr} (a :: Type# r) {s :: Repr} (b :: Type# s) {t :: Repr} (c :: Type# t) . (Functional# r, Functional# s) => (a -> b -> c) -> (b -> a -> c) flip f = lam2# \y x -> app2# f x y {-# INLINE flip #-} on - :: forall {r :: Repr} (a :: Type @r) {s :: Repr} (b :: Type @s) {t :: Repr} (c :: Type @t) + :: forall {r :: Repr} (a :: Type# r) {s :: Repr} (b :: Type# s) {t :: Repr} (c :: Type# t) . (Functional# r, Functional# s) => (b -> b -> c) -> (a -> b) -> (a -> a -> c) 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) + :: 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 #-} @@ -70,7 +70,7 @@ fork f g h = lam# \x -> app2# f (app# g x) (app# h x) compose00, (.) - :: forall {r0 :: Repr} (a0 :: Type @r0) {s :: Repr} (b :: Type @s) {t :: Repr} (c :: Type @t) + :: 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 @@ -79,7 +79,7 @@ compose00 = composeFunction compose01, (.*) - :: forall {r0 :: Repr} (a0 :: Type @r0) {r1 :: Repr} (a1 :: Type @r1) {s :: Repr} (b :: Type @s) {t :: Repr} (c :: Type @t) + :: 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 @@ -88,7 +88,7 @@ compose01 g f = lam# \x0 -> compose00 g (f `app#` x0) compose10, (*.) - :: forall {r0 :: Repr} (a0 :: Type @r0) {s0 :: Repr} (b0 :: Type @s0) {s :: Repr} (b :: Type @s) {t :: Repr} (c :: Type @t) + :: 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 @@ -97,7 +97,7 @@ compose10 g f = lam# \y -> compose00 (g `app#` y) f 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) + :: 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 @@ -106,7 +106,7 @@ compose11 g f = lam# \y -> compose01 (g `app#` y) f -- compose02, -- (.**) --- :: forall {r0 :: Repr} (a0 :: Type @r0) {r1 :: Repr} (a1 :: Type @r1) {r2 :: Repr} (a2 :: Type @r2) {s :: Repr} (b :: Type @s) {t :: Repr} (c :: Type @t) +-- :: forall {r0 :: Repr} (a0 :: Type# r0) {r1 :: Repr} (a1 :: Type# r1) {r2 :: Repr} (a2 :: Type# r2) {s :: Repr} (b :: Type# s) {t :: Repr} (c :: Type# t) -- . (Functional# r0, Functional# r1, Functional# r2, Functional# s) => (b -> c) -> (a0 -> a1 -> a2 -> b) -> (a0 -> a1 -> a2 -> c) -- compose02 g f = lam# \x -> compose01 g (f `app#` x) -- (.**) = compose02 @@ -115,7 +115,7 @@ compose11 g f = lam# \y -> compose01 (g `app#` y) f -- compose12, -- (*.**) --- :: forall {r0 :: Repr} (a0 :: Type @r0) {r1 :: Repr} (a1 :: Type @r1) {r2 :: Repr} (a2 :: Type @r2) {s0 :: Repr} (b0 :: Type @s0) {s :: Repr} (b :: Type @s) {t :: Repr} (c :: Type @t) +-- :: forall {r0 :: Repr} (a0 :: Type# r0) {r1 :: Repr} (a1 :: Type# r1) {r2 :: Repr} (a2 :: Type# r2) {s0 :: Repr} (b0 :: Type# s0) {s :: Repr} (b :: Type# s) {t :: Repr} (c :: Type# t) -- . (Functional# r0, Functional# r1, Functional# r2, Functional# s0, Functional# s) => (b0 -> b -> c) -> (a0 -> a1 -> a2 -> b) -> (b0 -> a0 -> a1 -> a2 -> c) -- compose12 g f = lam# \y -> compose02 (g `app#` y) f -- (*.**) = compose12 @@ -124,7 +124,7 @@ compose11 g f = lam# \y -> compose01 (g `app#` y) f -- compose20, -- (**.) --- :: forall {r0 :: Repr} (a0 :: Type @r0) {s0 :: Repr} (b0 :: Type @s0) {s1 :: Repr} (b1 :: Type @s1) {s :: Repr} (b :: Type @s) {t :: Repr} (c :: Type @t) +-- :: forall {r0 :: Repr} (a0 :: Type# r0) {s0 :: Repr} (b0 :: Type# s0) {s1 :: Repr} (b1 :: Type# s1) {s :: Repr} (b :: Type# s) {t :: Repr} (c :: Type# t) -- . (Functional# r0, Functional# s0, Functional# s1, Functional# s) => (b0 -> b1 -> b -> c) -> (a0 -> b) -> (b0 -> b1 -> a0 -> c) -- compose20 g f = lam# \y -> compose10 (g `app#` y) f -- (**.) = compose20 @@ -133,7 +133,7 @@ compose11 g f = lam# \y -> compose01 (g `app#` y) f -- compose21, -- (**.*) --- :: forall {r0 :: Repr} (a0 :: Type @r0) {r1 :: Repr} (a1 :: Type @r1) {s0 :: Repr} (b0 :: Type @s0) {s1 :: Repr} (b1 :: Type @s1) {s :: Repr} (b :: Type @s) {t :: Repr} (c :: Type @t) +-- :: forall {r0 :: Repr} (a0 :: Type# r0) {r1 :: Repr} (a1 :: Type# r1) {s0 :: Repr} (b0 :: Type# s0) {s1 :: Repr} (b1 :: Type# s1) {s :: Repr} (b :: Type# s) {t :: Repr} (c :: Type# t) -- . (Functional# r0, Functional# r1, Functional# s0, Functional# s1, Functional# s) => (b0 -> b1 -> b -> c) -> (a0 -> a1 -> b) -> (b0 -> b1 -> a0 -> a1 -> c) -- compose21 g f = lam# \y -> compose11 (g `app#` y) f -- (**.*) = compose21 @@ -142,7 +142,7 @@ compose11 g f = lam# \y -> compose01 (g `app#` y) f -- compose22, -- (**.**) --- :: forall {r0 :: Repr} (a0 :: Type @r0) {r1 :: Repr} (a1 :: Type @r1) {r2 :: Repr} (a2 :: Type @r2) {s0 :: Repr} (b0 :: Type @s0) {s1 :: Repr} (b1 :: Type @s1) {s :: Repr} (b :: Type @s) {t :: Repr} (c :: Type @t) +-- :: forall {r0 :: Repr} (a0 :: Type# r0) {r1 :: Repr} (a1 :: Type# r1) {r2 :: Repr} (a2 :: Type# r2) {s0 :: Repr} (b0 :: Type# s0) {s1 :: Repr} (b1 :: Type# s1) {s :: Repr} (b :: Type# s) {t :: Repr} (c :: Type# t) -- . (Functional# r0, Functional# r1, Functional# r2, Functional# s0, Functional# s1, Functional# s) => (b0 -> b1 -> b -> c) -> (a0 -> a1 -> a2 -> b) -> (b0 -> b1 -> a0 -> a1 -> a2 -> c) -- compose22 g f = lam# \y -> compose12 (g `app#` y) f -- (**.**) = compose22 diff --git a/src/Lude/Haskell/Category.hs b/src/Lude/Haskell/Category.hs @@ -73,23 +73,23 @@ type Cat :: Kind -> Kind type Cat i = i -> i -> Type -- | Functions between two types (which form a category) -type Function :: forall (r :: Repr). Cat (Type @r) +type Function :: forall (r :: Repr). Cat (Type# r) type Function @r = (->) -- | Natural transformations to `Function`/`->` -type (~>) :: forall i r. Cat (i -> Type @r) +type (~>) :: forall i (r :: Repr). Cat (i -> Type# r) type f ~> g = forall x. f x -> g x -- | Binatural transformations to `Function`/`->` -type (~~>) :: forall i j r. Cat (i -> j -> Type @r) +type (~~>) :: forall i j (r :: Repr). Cat (i -> j -> Type# r) type f ~~> g = forall x y. f x y -> g x y -identityFunction :: forall {r :: Repr} (a :: Type @r). (Functional# r) => a -> a +identityFunction :: forall {r :: Repr} (a :: Type# r). (Functional# r) => a -> a identityFunction = lam# \x -> x {-# INLINE identityFunction #-} composeFunction - :: forall {r :: Repr} (a :: Type @r) {s :: Repr} (b :: Type @s) {t :: Repr} (c :: Type @t) + :: 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) {-# INLINE composeFunction #-} diff --git a/src/Lude/Haskell/Constraint.hs b/src/Lude/Haskell/Constraint.hs @@ -1,6 +1,7 @@ module Lude.Haskell.Constraint ( Constraint, Constraint1, + Constraint2, Predicate, Relation, All, @@ -10,23 +11,31 @@ import Data.Tuple.Experimental qualified as GHC import GHC.Exts qualified as GHC import Lude.Haskell.Kind +import Lude.Haskell.Repr (Repr) +import Lude.Haskell.Repr qualified as Repr --- TODO: Delete Constraint1 in favor of Predicate? We'd also need a replacement --- name for Type1. Maybe "Family"? +-- TODO: Delete Constraint1/Constraint2 in favor of Predicate/Relation? +-- We'd also need a replacement name for Type1. Maybe "Family"? -------------------------------------------------------------------------------- -type Constraint :: KindR -type Constraint @r = GHC.CONSTRAINT r +type Constraint# :: Repr -> Kind +type Constraint# = GHC.CONSTRAINT -type Constraint1 :: Kind -> KindR -type Constraint1 i @r = Predicate i @r +type Constraint :: Kind +type Constraint = Constraint# Repr.BoxL -type Predicate :: Kind -> KindR -type Predicate i @r = i -> Constraint @r +type Constraint1 :: Kind -> Kind +type Constraint1 i = i -> Constraint -type Relation :: Kind -> Kind -> KindR -type Relation i j @r = i -> j -> Constraint @r +type Constraint2 :: Kind -> Kind -> Kind +type Constraint2 i j = i -> j -> Constraint + +type Predicate :: Kind -> Kind +type Predicate i = Constraint1 i + +type Relation :: Kind -> Kind -> Kind +type Relation i j = Constraint2 i j -------------------------------------------------------------------------------- diff --git a/src/Lude/Haskell/Functional.hs b/src/Lude/Haskell/Functional.hs @@ -22,21 +22,21 @@ import Lude.Haskell.Type -- foo :: Lev A -- foo = bar -- @ -type Lev :: forall {r}. Type @r -> Type +type Lev :: forall {r :: Repr}. Type# r -> Type type Lev a = (GHC.CTuple0) => a type Functional# :: Repr -> Constraint class Functional# r where - lam# :: forall (a :: Type @r) {s} (b :: Type @s). (Lev a -> b) -> (a -> b) - app# :: forall (a :: Type @r) {s} (b :: Type @s). (a -> b) -> (Lev a -> b) + 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) lam2# - :: forall {r0 :: Repr} (a0 :: Type @r0) {r1 :: Repr} (a1 :: Type @r1) {s} (b :: Type @s) + :: 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) lam2# f = lam# \x -> lam# (f x) app2# - :: forall {r0 :: Repr} (a0 :: Type @r0) {r1 :: Repr} (a1 :: Type @r1) {s} (b :: Type @s) + :: forall {r0 :: Repr} (a0 :: Type# r0) {r1 :: Repr} (a1 :: Type# r1) {s :: Repr} (b :: Type# s) . (Functional# r0, Functional# r1) => (a0 -> a1 -> b) -> (Lev a0 -> Lev a1 -> b) app2# f x y = f `app#` x `app#` y diff --git a/src/Lude/Haskell/Generic.hs b/src/Lude/Haskell/Generic.hs @@ -67,7 +67,7 @@ instance (Generic1 f, c (G.Rep1 f)) => Generically1 c f type GVoid = G.V1 -elimGVoid :: forall {k} (p :: k) {r} (b :: Type @r). GVoid p -> b +elimGVoid :: forall {k} (p :: k) {r :: Repr} (b :: Type# r). GVoid p -> b elimGVoid = \case {} {-# INLINE elimGVoid #-} @@ -79,7 +79,7 @@ pattern MkGUnit :: forall {k} (p :: k). GUnit p pattern MkGUnit = G.U1 {-# COMPLETE MkGUnit #-} -elimGUnit :: forall {k} (p :: k) {r} (b :: Type @r). Lev b -> (GUnit p -> b) +elimGUnit :: forall {k} (p :: k) {r :: Repr} (b :: Type# r). Lev b -> (GUnit p -> b) elimGUnit unit = \MkGUnit -> unit {-# INLINE elimGUnit #-} @@ -116,7 +116,7 @@ pattern GRight y = G.R1 y {-# COMPLETE GLeft, GRight #-} elimGSum - :: forall {k} (f :: k -> Type) (g :: k -> Type) (p :: k) {r :: Repr} (b :: Type @r) + :: forall {k} (f :: k -> Type) (g :: k -> Type) (p :: k) {r :: Repr} (b :: Type# r) . (f p -> b) -> (g p -> b) -> (GSum f g p -> b) elimGSum left right = \case GLeft x -> left x @@ -132,7 +132,7 @@ pattern GPair x y = x G.:*: y {-# COMPLETE GPair #-} elimGProd - :: forall {k} (f :: k -> Type) (g :: k -> Type) (p :: k) {r :: Repr} (b :: Type @r) + :: forall {k} (f :: k -> Type) (g :: k -> Type) (p :: k) {r :: Repr} (b :: Type# r) . (f p -> g p -> b) -> (GProd f g p -> b) elimGProd pair = \(GPair x y) -> pair x y {-# INLINE elimGProd #-} diff --git a/src/Lude/Haskell/Kind.hs b/src/Lude/Haskell/Kind.hs @@ -1,6 +1,7 @@ module Lude.Haskell.Kind ( + KindOrType#, + KindOrType, Kind, - KindR, Endo, Biendo, ) where @@ -12,18 +13,24 @@ import Lude.Haskell.Repr qualified as Repr -------------------------------------------------------------------------------- -type Kind = GHC.TYPE Repr.BoxL +-- This is just so @Kind@ itself receives a non-confusing kind in GHC +-- diagnostic messages +type KIND = GHC.TYPE Repr.BoxL --- NOTE: We typically avoid conflating types and kinds, +-- NOTE: We typically avoid conflating types and kinds for clarity, -- but when we do conflate them, we use KindOrType. -type KindOrType r = GHC.TYPE r --- | The kind of "invisibly" `Repr`-generic types and constraints -type KindR :: Kind -type KindR = forall (r :: Repr). Kind +type KindOrType# :: Repr -> KIND +type KindOrType# = GHC.TYPE -type Endo :: forall (r :: Repr). KindOrType r -> Kind +type KindOrType :: KIND +type KindOrType = KindOrType# Repr.BoxL + +type Kind :: KIND +type Kind = KindOrType + +type Endo :: forall (r :: Repr). KindOrType# r -> KindOrType type Endo i = i -> i -type Biendo :: forall (r :: Repr). KindOrType r -> Kind +type Biendo :: forall (r :: Repr). KindOrType# r -> KindOrType type Biendo i = i -> i -> i diff --git a/src/Lude/Haskell/Type.hs b/src/Lude/Haskell/Type.hs @@ -1,4 +1,5 @@ module Lude.Haskell.Type ( + Type#, Type, Type1, Tuple#, @@ -14,18 +15,21 @@ import Lude.Haskell.Repr qualified as Repr -------------------------------------------------------------------------------- -type Type :: KindR -type Type @r = GHC.TYPE r +type Type# :: Repr -> Kind +type Type# = GHC.TYPE -type Type1 :: Kind -> KindR -type Type1 i @r = i -> Type @r +type Type :: Kind +type Type = Type# Repr.BoxL + +type Type1 :: Kind -> Kind +type Type1 i = i -> Type -------------------------------------------------------------------------------- -- Tuples -type R :: forall {r}. Type @r -> Repr +type R :: forall {r :: Repr}. Type# r -> Repr type family R _ where - R (_ :: Type @r) = r + R (_ :: Type# r) = r type TupleRepr :: forall {k}. k -> Repr type family TupleRepr _ where @@ -42,7 +46,7 @@ type family TupleRepr _ where TupleRepr (GHC.MkSolo a) = Repr.Tuple [R a] -- TODO: Rename so that it doesn't have a # in the name. -type Tuple# :: forall {k}. forall (a :: k) -> Type @(TupleRepr a) +type Tuple# :: forall {k}. forall (a :: k) -> Type# (TupleRepr a) type family Tuple# _ where Tuple# () = GHC.Tuple0# Tuple# (a) = GHC.Tuple1# a diff --git a/src/Lude/Order/Bound.hs b/src/Lude/Order/Bound.hs @@ -12,15 +12,15 @@ import Lude.Order.Partial -------------------------------------------------------------------------------- -type BoundedBelow :: forall {r :: Repr}. Type @r -> Constraint +type BoundedBelow :: forall {r :: Repr}. Type# r -> Constraint class (PartiallyOrdered a) => BoundedBelow a where bot :: Lev a -type BoundedAbove :: forall {r :: Repr}. Type @r -> Constraint +type BoundedAbove :: forall {r :: Repr}. Type# r -> Constraint class (PartiallyOrdered a) => BoundedAbove a where top :: Lev a -type Bounded :: forall {r :: Repr}. Type @r -> Constraint +type Bounded :: forall {r :: Repr}. Type# r -> Constraint class (BoundedBelow a, BoundedAbove a) => Bounded a instance (BoundedBelow a, BoundedAbove a) => Bounded a diff --git a/src/Lude/Order/Lattice.hs b/src/Lude/Order/Lattice.hs @@ -18,27 +18,27 @@ import Lude.Order.Partial -------------------------------------------------------------------------------- -type GlbLatticed :: forall {r :: Repr}. Type @r -> Constraint +type GlbLatticed :: forall {r :: Repr}. Type# r -> Constraint class (PartiallyOrdered a) => GlbLatticed a where glb :: Biendo a -type LubLatticed :: forall {r :: Repr}. Type @r -> Constraint +type LubLatticed :: forall {r :: Repr}. Type# r -> Constraint class (PartiallyOrdered a) => LubLatticed a where lub :: Biendo a -type Latticed :: forall {r :: Repr}. Type @r -> Constraint +type Latticed :: forall {r :: Repr}. Type# r -> Constraint class (GlbLatticed a, LubLatticed a) => Latticed a instance (GlbLatticed a, LubLatticed a) => Latticed a -type BoundedGlbLatticed :: forall {r :: Repr}. Type @r -> Constraint +type BoundedGlbLatticed :: forall {r :: Repr}. Type# r -> Constraint class (BoundedAbove a, GlbLatticed a) => BoundedGlbLatticed a instance (BoundedAbove a, GlbLatticed a) => BoundedGlbLatticed a -type BoundedLubLatticed :: forall {r :: Repr}. Type @r -> Constraint +type BoundedLubLatticed :: forall {r :: Repr}. Type# r -> Constraint class (BoundedBelow a, LubLatticed a) => BoundedLubLatticed a instance (BoundedBelow a, LubLatticed a) => BoundedLubLatticed a -type BoundedLatticed :: forall {r :: Repr}. Type @r -> Constraint +type BoundedLatticed :: forall {r :: Repr}. Type# r -> Constraint class (BoundedGlbLatticed a, BoundedLubLatticed a) => BoundedLatticed a instance (BoundedGlbLatticed a, BoundedLubLatticed a) => BoundedLatticed a diff --git a/src/Lude/Order/Partial.hs b/src/Lude/Order/Partial.hs @@ -26,8 +26,8 @@ infix 4 <, <=, >=, > -------------------------------------------------------------------------------- -type PartiallyOrdered :: forall {r :: Repr}. Type @r -> Constraint -class (Equivalential a) => PartiallyOrdered (a :: Type @r) where +type PartiallyOrdered :: forall {r :: Repr}. Type# r -> Constraint +class (Equivalential a) => PartiallyOrdered (a :: Type# r) where {-# MINIMAL pcmp #-} pcmp :: a -> a -> Maybe Ordering @@ -48,7 +48,7 @@ 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 (>=) = ge diff --git a/src/Lude/Order/Total.hs b/src/Lude/Order/Total.hs @@ -24,15 +24,15 @@ import Lude.Order.Partial -------------------------------------------------------------------------------- -type TotallyOrdered :: forall {r :: Repr}. Type @r -> Constraint -class (Latticed a) => TotallyOrdered (a :: Type @r) where +type TotallyOrdered :: forall {r :: Repr}. Type# r -> Constraint +class (Latticed a) => TotallyOrdered (a :: Type# r) where {-# MINIMAL #-} cmp :: a -> a -> Ordering default cmp :: (Functional# r) => a -> a -> Ordering cmp = unsafeFromJust .* pcmp -min, max :: forall {r :: Repr} (a :: Type @r). (TotallyOrdered a) => Biendo a +min, max :: forall {r :: Repr} (a :: Type# r). (TotallyOrdered a) => Biendo a min = glb max = lub