-
Notifications
You must be signed in to change notification settings - Fork 15
ADT
Eric Yang edited this page Jun 27, 2021
·
2 revisions
ADT(Algebraic Data Type,代数数据类型)是复合类型,即由其他类型的组合形成的类型。
type Show {
show: This -> string
}
type List [
Nil,
Cons(head: i32, tail: List)
]
type Person (
age: i32,
name: string
) impl Show {
fun show(this: This) -> string {
return "Hello Deeplang"
}
}
// desugar
type Person [
Person(age: i32, name: string)
] impl Show {
fun show(this: This) -> string {
return "Hello Deeplang"
}
}