mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-05 22:48:42 +00:00
36 lines
825 B
Text
36 lines
825 B
Text
typeclass #Copy =
|
|
& copy : #Copy -> #Copy
|
|
|
|
typeclass (#Ord : #Eq) =
|
|
& ( < ) : #Ord -> #Ord -> Bool
|
|
& ( > ) : #Ord -> #Ord -> Bool
|
|
& ( <= ) : #Ord -> #Ord -> Bool
|
|
& ( >= ) : #Ord -> #Ord -> Bool
|
|
|
|
typeclass (#D : #A #B #C) 'A 'B =
|
|
& do_something : Unit -> (& 'A & 'B)
|
|
|
|
typeclass #E 'A =
|
|
& do_something : Unit -> 'A
|
|
|
|
namespace const ord : #Ord {
|
|
def ( <= ) : a b = (a < b) || (a == b)
|
|
def ( > ) : a b = !(a <= b)
|
|
def ( >= ) : a b = !(a < b)
|
|
}
|
|
|
|
// === ?? dependent types ?? ===
|
|
//
|
|
// typeclass #F : (a : Int) (b : Int) =
|
|
// & do_something Int -> Int
|
|
//
|
|
// namespace (f : #F a b c) {
|
|
// require do_sometihng a = b
|
|
// }
|
|
//
|
|
// ===
|
|
|
|
// ?? operators over functions (without arguments, like "def <= = < || ==;") ??
|
|
// ?? define operators like OCaml ??
|
|
// ?? denote moved type ??
|
|
// ?? "trait" VS "typeclass" ??
|