lude

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

commit a1a564cdf8ef2e9df59cbe9bc2f308695481e95b
parent 6a6bc2fced739398e38609dd0639600aae6ae5c4
Author: Robert Russell <robert@rr3.xyz>
Date:   Mon, 14 Sep 2026 15:59:45 -0700

Add tentative Pair module

Diffstat:
Msrc/Lude.hs | 1+
Msrc/Lude/Pair.hs | 49+++++++++----------------------------------------
2 files changed, 10 insertions(+), 40 deletions(-)

diff --git a/src/Lude.hs b/src/Lude.hs @@ -11,6 +11,7 @@ import Lude.IO as X import Lude.List as X import Lude.Maybe as X import Lude.Natural as X +import Lude.Pair as X import Lude.Text as X import Lude.Unit as X import Lude.Void as X diff --git a/src/Lude/Pair.hs b/src/Lude/Pair.hs @@ -1,17 +1,9 @@ module Lude.Pair ( Pair, - pattern Pair, - type (×), + pattern MkPair, + type (*), fst, snd, - -- - Pair1 (..), - type (×^), - fst1, - snd1, - -- - Fst, - Snd, ) where import Lude.Haskell @@ -26,38 +18,15 @@ type Pair :: Type -> Type -> Type type Pair = GHC.Tuple2 -- For consistency -pattern Pair :: a -> b -> Pair a b -pattern Pair a b = (a, b) -{-# COMPLETE Pair #-} +pattern MkPair :: a -> b -> Pair a b +pattern MkPair a b = (a, b) +{-# COMPLETE MkPair #-} -type (×) = Pair -infixl 7 × +type (*) = Pair +infixl 7 * fst :: Pair a b -> a -fst (Pair x _) = x +fst (MkPair x _) = x snd :: Pair a b -> b -snd (Pair _ y) = y - --------------------------------------------------------------------------------- - -type Pair1 :: forall i j. Type1 i -> Type1 j -> Type1 (i × j) -data Pair1 f g a where - Pair1 :: f a0 -> g a1 -> Pair1 f g (a0, a1) - -type (×^) = Pair1 -infixl 7 ×^ - -fst1 :: Pair1 p q (i, j) -> p i -fst1 (Pair1 x _) = x - -snd1 :: Pair1 p q (i, j) -> q j -snd1 (Pair1 _ y) = y - --------------------------------------------------------------------------------- - -type family Fst (x :: i × j) :: i where - Fst (a, b) = a - -type family Snd (x :: i × j) :: j where - Snd (a, b) = b +snd (MkPair _ y) = y