rename some things

This commit is contained in:
Joeri Exelmans 2025-04-20 21:09:51 +02:00
parent e04cac4f7d
commit 8a4bd44f04
16 changed files with 92 additions and 60 deletions

View file

@ -3,7 +3,7 @@
import { compareNumbers } from "./primitives.js"
import { get, length as lengthLs } from "../structures/list.js";
import { read, length as lengthSet } from "../structures/set.js";
import { constructorProduct, getLeft, getRight } from "../structures/product.js";
import { newProduct, getLeft, getRight } from "../structures/product.js";
import { match } from "../structures/sum.js";
// (a -> a -> Int) -> [a] -> [a] -> Int
@ -28,12 +28,12 @@ export const compareProducts = compareLeft => compareRight => x => y => {
// (a -> a -> Int) -> (b -> b -> Int) -> (a | b) -> (a | b) -> Int
export const compareSums = compareLeft => compareRight => x => y => {
return match(x)(constructorProduct
(leftValueX => match(y)(constructorProduct
return match(x)(newProduct
(leftValueX => match(y)(newProduct
(leftValueY => compareLeft(leftValueX)(leftValueY))
((rightValueY) => -1) // x is 'left' and y is 'right' => x < y
))
(rightValueX => match(y)(constructorProduct
(rightValueX => match(y)(newProduct
(leftValueY => 1) // x is 'right' and y is 'left' => x > y
(rightValueY => compareRight(rightValueX)(rightValueY))
))