roussillon-type-system 0.4.3

A type system for a programming language
Documentation
@startuml
interface Any {
    --
    type_id: &Self -> arch
    size_of: &Self -> arch
}
interface Copy {
    --
    copy: &Self -> Self
}
interface Displayable {
    --
    to_string: &Self -> String
}

Any <.. Primitive
Copy <.. Primitive
Displayable <.. Primitive
abstract Primitive

interface Boolean {
    --
    and (&) : (&bool, &bool) -> bool
    or (|) : (&bool, &bool) -> bool
    xor (^) : (&bool, &bool) -> bool
    eqv (|<>|): (&bool, &bool) -> bool
    not (!): &bool -> bool
    nand (!&) : (&bool, &bool) -> bool
    nor (!|) : (&bool, &bool) -> bool
    imp  (|>) : (&bool, &bool) -> bool
    nimp (|!>) : (&bool, &bool) -> bool
    rimp (<|) : (&bool, &bool) -> bool
    rnimp (<!|) : (&bool, &bool) -> bool
    ternary<L,R> (?,:) : (&bool, L, R) -> L:R
}
Primitive <-- bool
Boolean <.. bool
class bool

interface Bitwise {
    --
    and (&) : (&Self, &Self) -> Self
    or (|) : (&Self, &Self) -> Self
    xor (^) : (&Self, &Self) -> Self
    eqv (|<>|) : (&Self, &Self) -> Self
    nand (!&) : (&Self, &Self) -> Self
    nor (!|) : (&Self, &Self) -> Self
    imp (|>) : (&Self, &Self) -> Self
    nimp (|!>) : (&Self, &Self) -> Self
    rimp (<|) : (&Self, &Self) -> Self
    rnimp (<!|) : (&Self, &Self) -> Self
}
interface Equal {
    --
    eq (==) : (&Self, &Self) -> bool
    ne (!=) : (&Self, &Self) -> bool
}
interface Compare {
    --
    gt (>) : (&Self, &Self) -> bool
    ge (>=) : (&Self, &Self) -> bool
    ge (<=) : (&Self, &Self) -> bool
    lt (<) : (&Self, &Self) -> bool
    min : (&Self, &Self) -> Self,
    max : (&Self, &Self) -> Self
}
interface SignedArithmetic {
    --
    add (+) : (&Self, &Self) -> (Self, Self)
    sub (-) : (&Self, &Self) -> (Self, Self)
    mul (*) : (&Self, &Self) -> (Self, Self)
    div (/) : (&Self, &Self) -> (Self, Self)
    mod (%) : (&Self, &Self) -> (Self, Self)
}
Primitive <----- Native
Bitwise <.. Native
Equal <.. Native
Compare <.. Native
SignedArithmetic <.. Native
interface Bitset {
    bit : (&word, byte) -> bool
    set : (&mut word, byte, bool) -> ()
}
Bitset <.. Native
abstract Native
Native <-- byte
class byte

interface Byteset {
    merge : (&Self, &bytes< u >) -> bytes< s + u >
    split : (&bytes< s + u >, arch) -> (bytes< s >, bytes< u >)
    to_bytes : (&Self) -> &[byte]
}
Byteset <.. bytes
Native <-- bytes
class bytes< s: arch >

bytes <-- word
class word {
    s = 2
}
bytes <-- quad
class quad {
    s = 4
}
bytes <-- long
class long {
    s = 8
}
bytes <-- wide
class wide {
    s = 16
}

Native <-- arch
class arch

interface Arithmetic {
    --
    add (+) : (&Self, &Self) -> Self
    sub (-) : (&Self, &Self) -> Self
    mul (*) : (&Self, &Self) -> Self
    div (/) : (&Self, &Self) -> Self
    mod (%) : (&Self, &Self) -> Self
}
Compare <.. Number
Primitive <-- Number
Arithmetic <.. Number
abstract Number

Equal <.. int
Number <-- int
class int

Number <-- float
class float

interface Borrowable {
    --
    deref (*$) : (Self) -> T
    borrow : (&Self) -> &T
    borrow_mut<T> : (&mut T) -> &mut T
}
Primitive <-- "&T"
Borrowable <.. "&T"
class "&T"< T > {
    mutable: bool
}

interface Collection< T > {
    --
    item ($[$]) : (&Self, arch) -> &T,
    item_mut (mut $[$]) : (&mut Self, arch) -> &mut T,
    length : &Self -> arch,
}
interface Iterator< T > {
    --
    iterate : &mut Self -> ?&T
    iterate_mut : &mut Self -> ?&mut T
    reset : &mut Self -> ()
}
interface Enumerator< T > {
    --
    enumerate: &mut Self -> ?(&K, &T)
    enumerate_mut: &mut Self -> ?(&K, &mut T)
    reset: &mut Self -> ()
}

Primitive <--- Array
Collection <.. Array
Iterator <.. Array
Enumerator <.. Array
abstract Array

Array <-- "[T; s]"
class "[[T; s]]"< T > {
    --
    get_slice: &Self -> &[T]
}


Array <-- "&[T]"
Borrowable <.. "&[T]"
class "&[T]"< T >

Any <.... Composite
abstract Composite

interface Structured {
    member: (&Self, arch) -> any
}
Structured <.. "(T, U)"
Composite <-- "(T, U)"
class "((T, U))"< T, U > {
    types: &[any]
}

Composite <-- Algebraic
abstract Algebraic

Algebraic <-- "T & U"
class "T & U"< T, U >
Structured <.... struct
"T & U" <-- struct

Algebraic <-- "T | U"
class "T | U"< T, U >
"T | U" <-- enum

Algebraic <-- gadt
class gadt

Any <... "I -> O"
interface Callable< Args, R > {
    call: (&Self, Args) -> R
}
Callable <.. "I -> O"
class "I -> O"< I, O >

Any <... dyn
class dyn< T >
Any <... "."
class "."< T >
Any <... unit
class unit
class never
@enduml