-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathBasicTypeClasses.wurst
More file actions
38 lines (31 loc) · 942 Bytes
/
BasicTypeClasses.wurst
File metadata and controls
38 lines (31 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package BasicTypeClasses
import NoWurst
/**
T is a type that can be converted to an integer.
The toIndex function must be injective.
*/
public interface ToIndex<T:>
function toIndex(T x) returns int
/**
T is a type that can be created from an integer T.
*/
public interface FromIndex<T:>
function fromIndex(int index) returns T
public interface ConvertIndex<T:> extends ToIndex<T>, FromIndex<T>
/**
T is a type with a default value.
*/
public interface Default<T:>
function defaultValue() returns T
/**
AnyRef is the type class for all reference types (interfaces and classes).
*/
public interface AnyRef<T:> extends ConvertIndex<T>, Default<T>
/**
T is a type that can be converted to a string.
*/
public interface Show<T:>
function toString(T t) returns string
/** returns a string representation */
public function T.toString<T: Show>() returns string
return T.toString(this)