lude

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

commit 132a8f28c8603554788ec3291eb5fbeab3962434
parent 7a371999dffd83c8c9cd4ae28cd12d5a792f516f
Author: Robert Russell <robert@rr3.xyz>
Date:   Wed, 16 Sep 2026 22:11:46 -0700

Consolidate interop newtypes

Diffstat:
Msrc/Lude/Algebra/Category/Core.hs | 22+++++-----------------
Msrc/Lude/Algebra/Category/Monad.hs | 8++++----
Msrc/Lude/Equivalence.hs | 8++------
Msrc/Lude/Haskell.hs | 1+
Asrc/Lude/Haskell/BaseInterop.hs | 15+++++++++++++++
5 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/src/Lude/Algebra/Category/Core.hs b/src/Lude/Algebra/Category/Core.hs @@ -25,8 +25,6 @@ module Lude.Algebra.Category.Core ( type (==>), NTDom, NTCod, - -- - InteropFunctor (..), ) where import Data.Coerce @@ -240,20 +238,10 @@ instance Functorial Given where -------------------------------------------------------------------------------- -- Interop --- type InteropCategory :: forall {i}. Endo (Cat i) --- newtype InteropCategory p a b = MkInteropCategory {unInteropCategory :: p a b} - --- instance (Control.Category.Category p) => Categorical (InteropCategory p) where --- identity = coerce Control.Category.id --- compose = coerce (Control.Category..) - -type InteropFunctor :: Endo (Endo Type) -newtype InteropFunctor f a = MkInteropFunctor {unInteropFunctor :: f a} - -instance (Base.Functor f) => Functorial (InteropFunctor f) where - type Dom (InteropFunctor f) = Function - type Cod (InteropFunctor f) = Function +instance (Base.Functor f) => Functorial (BaseInterop1 f) where + type Dom (BaseInterop1 f) = Function + type Cod (BaseInterop1 f) = Function map = coerce Base.fmap -deriving via InteropFunctor IO instance Functorial IO -deriving via InteropFunctor List instance Functorial List +deriving via BaseInterop1 IO instance Functorial IO +deriving via BaseInterop1 List instance Functorial List diff --git a/src/Lude/Algebra/Category/Monad.hs b/src/Lude/Algebra/Category/Monad.hs @@ -73,10 +73,10 @@ fa << fb = bind (\a -> fb >> pure a) fa -------------------------------------------------------------------------------- -- Interop -instance (Base.Monad f) => Monadic (InteropFunctor f) where +instance (Base.Monad f) => Monadic (BaseInterop1 f) where pure = coerce Base.return - join = coerce (Base.>>= unInteropFunctor) + join = coerce (Base.>>= unBaseInterop1) bind = coerce (Base.=<<) -deriving via InteropFunctor IO instance Monadic IO -deriving via InteropFunctor List instance Monadic List +deriving via BaseInterop1 IO instance Monadic IO +deriving via BaseInterop1 List instance Monadic List diff --git a/src/Lude/Equivalence.hs b/src/Lude/Equivalence.hs @@ -4,7 +4,6 @@ module Lude.Equivalence ( Equivalential (..), (==), (<>), - InteropEq (..), ) where import Data.Coerce @@ -80,11 +79,8 @@ instance (Generically Equivalential a) => Equivalential (Genericity a) where -------------------------------------------------------------------------------- -- Interop -type InteropEq :: Endo Type -newtype InteropEq a = MkInteropEq {unInteropEq :: a} - -instance (Base.Eq a) => Equivalential (InteropEq a) where +instance (Base.Eq a) => Equivalential (BaseInterop a) where eq = coerce (Base.==) ne = coerce (Base./=) -deriving via InteropEq Base.Ordering instance Equivalential Base.Ordering +deriving via BaseInterop Base.Ordering instance Equivalential Base.Ordering diff --git a/src/Lude/Haskell.hs b/src/Lude/Haskell.hs @@ -4,6 +4,7 @@ module Lude.Haskell ( import GHC.Exts as X (IsList (..), IsString (..)) +import Lude.Haskell.BaseInterop as X import Lude.Haskell.Category as X -- TODO: Probably hide some stuff from here. import Lude.Haskell.Constraint as X import Lude.Haskell.Equality as X diff --git a/src/Lude/Haskell/BaseInterop.hs b/src/Lude/Haskell/BaseInterop.hs @@ -0,0 +1,15 @@ +module Lude.Haskell.BaseInterop ( + BaseInterop (..), + BaseInterop1 (..), +) where + +import Lude.Haskell.Kind +import Lude.Haskell.Type + +-------------------------------------------------------------------------------- + +type BaseInterop :: Endo Type +newtype BaseInterop a = MkBaseInterop {unBaseInterop :: a} + +type BaseInterop1 :: forall {i}. Endo (i -> Type) +newtype BaseInterop1 f a = MkBaseInterop1 {unBaseInterop1 :: f a}