import type { Comparison } from "__BUILTINS__"
import { LT, EQ, GT, gt, ge, lt, le } from "__BUILTINS__"

export type Comparison
export LT
export EQ
export GT


/**
 * The interface comparable allows a type to be compared. It contains only one method
 * compare that can return one of 3 values:
 *   - 1 if the first parameter is greater than the second
 *   - -1 if the first parameter is less than the second
 *   - 0 if the two parameters are equal
 * For convenience, the 3 values above have corresponding constants:
 *   - MORE
 *   - LESS
 *   - EQUAL
 *
 * @since 0.8.0
 * @example
 * compare(1, 2) // -1
 * compare(2, 1) // 1
 * compare(2, 2) // 0
 */
// interface Eq a => Comparable a {
//   compare :: a -> a -> ComparisonResult
// }


/**
 * Returns true if two comparable values are equal
 *
 * @since 0.13.0
 * @example
 * eq(1, 3) // false
 * eq(3, 3) // true
 */
eq :: Comparable a => a -> a -> Boolean
export eq = (a, b) => compare(a, b) == EQ


/**
 * Returns true if two comparable values aren't equal
 *
 * @since 0.13.0
 * @example
 * notEq(1, 3) // true
 * notEq(3, 3) // false
 */
notEq :: Comparable a => a -> a -> Boolean
export notEq = (a, b) => compare(a, b) != EQ


/**
 * Takes two comparable values of the same type that implements Comparable and
 * return true if the first parameter is strictly greater than the second.
 *
 * @since 0.8.0
 * @example
 * gt(3, 2) // true
 * gt(3, 3) // false
 */
export gt


/**
 * Takes two comparable values of the same type that implements Comparable and
 * return true if the first parameter is greater than the second or if they are
 * equal.
 *
 * @since 0.8.0
 * @example
 * gt(3, 2) // true
 * gt(3, 3) // true
 */
export ge


/**
 * Takes two comparable values of the same type that implements Comparable and
 * return true if the first parameter is strictly less than the second.
 *
 * @since 0.8.0
 * @example
 * lt(3, 2) // false
 * lt(3, 4) // true
 * lt(3, 3) // false
 */
export lt


/**
 * Takes two comparable values of the same type that implements Comparable and
 * return true if the first parameter is less than the second or if they are
 * equal.
 *
 * @since 0.8.0
 * @example
 * le(3, 2) // false
 * le(3, 4) // true
 * le(3, 3) // true
 */
export le
