mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2026-01-02 12:18:16 +00:00
debug
This commit is contained in:
parent
582ad5668e
commit
0d62ae0814
29 changed files with 99479 additions and 1166 deletions
36
tests/typeclasses.lang
Normal file
36
tests/typeclasses.lang
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
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" ??
|
||||
Loading…
Add table
Add a link
Reference in a new issue