lude

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

commit dff6da1a5d97c948f8ea1ed43a9b92232ab2fde4
parent e9e58113e990affacef44e78376bcd6977fbc7a7
Author: Robert Russell <robert@rr3.xyz>
Date:   Tue, 10 Mar 2026 18:48:52 -0700

Add Pair and Either

Diffstat:
Asrc/Lude/Either.hs | 13+++++++++++++
Asrc/Lude/Pair.hs | 21+++++++++++++++++++++
2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/src/Lude/Either.hs b/src/Lude/Either.hs @@ -0,0 +1,13 @@ +module Lude.Either ( + Either (..), + type (+), +) where + +-- TODO: It's probably not worth defining our own type here. + +-------------------------------------------------------------------------------- + +data Either a b = L a | R b + +type (+) = Either +infixl 6 + diff --git a/src/Lude/Pair.hs b/src/Lude/Pair.hs @@ -0,0 +1,21 @@ +module Lude.Pair ( + Pair, + type (×), + Fst, + Snd, +) where + +-------------------------------------------------------------------------------- + +type Pair = (,) + +type (×) = Pair +infixl 7 × + +-------------------------------------------------------------------------------- + +type family Fst (x :: i × j) :: i where + Fst '(a, b) = a + +type family Snd (x :: i × j) :: j where + Snd '(a, b) = b