Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-base

Source of release 0.45.0

0.45.0 / src / std / luce.lucb

#==============================================================================================
#
#   luce - The derived interface bounds
#
#   DESCRIPTION:
#       The derived bounds of §14.4: every type with `==` is Equatable, every hashable one
#       Hashable, every ordered one Comparable. Nothing implements them by hand.
#
#==============================================================================================

import io

## Implemented by every type with `==`.
pub interface Equatable:
    func equals(other: void*) -> bool

## Implemented by every hashable type: `value.hash()` (§7.4).
pub interface Hashable:
    func hash() -> u64

## Implemented by every ordered type.
pub interface Comparable:
    func compare(other: void*) -> i64

## The protocols `for` consumes (§8.3, §14.4): a value iterator answers each element
## until `none`; an iterable answers a fresh iterator of its own concrete type.
pub interface Iterator[T]:
    func next() -> T?

## A type a `for` loop can walk: it yields an iterator of `T` (§13.3).
pub interface Iterable[T, I: Iterator[T]]:
    func iterator() -> I

## A value that writes itself to a sink (§14.4); formatted strings call it for each field.
pub interface Display:
    func display(sink: io.Writer) -> !

## The source file of the use site; the backend replaces it (§9.1).
pub let file: str = ""
## The source line of the use site; the backend replaces it (§9.1).
pub let line: u32 = 0
## The enclosing function of the use site; the backend replaces it (§9.1).
pub let function: str = ""
## The use site's file, line and function together (§9.1).
pub let location: io.Location = io.Location(file = "", line = 0, function = "")