1///|
2type Point
3
4///|
5pub impl 
trait Show {
  output(Self, &Logger) -> Unit
  to_string(Self) -> String
}
Show
for
type Point
Point
with
(self : Point, logger : &Logger) -> Unit
output
(
Point
self
:
type Point
Point
,
&Logger
logger
: &
trait Logger {
  write_string(Self, String) -> Unit
  write_substring(Self, String, Int, Int) -> Unit
  write_char(Self, Char) -> Unit
}

Trait for a logger, where debug logs can be written into

@builtin.Logger
) ->
Unit
Unit
{
6
&Logger
logger
.
(&Logger, String) -> Unit
write_string
("(")
7
&Logger
logger
.
(&Logger, String) -> Unit
write_string
(
Point
self
.
(self : Point) -> Int
row
().
(self : Int, radix~ : Int = ..) -> String
to_string
())
8
&Logger
logger
.
(&Logger, String) -> Unit
write_string
(", ")
9
&Logger
logger
.
(&Logger, String) -> Unit
write_string
(
Point
self
.
(self : Point) -> Int
column
().
(self : Int, radix~ : Int = ..) -> String
to_string
())
10
&Logger
logger
.
(&Logger, String) -> Unit
write_string
(")")
11} 12 13///| 14impl
trait ToJson {
  to_json(Self) -> Json
}
ToJson
for
type Point
Point
with
(self : Point) -> Json
to_json
(
Point
self
:
type Point
Point
) ->
enum Json {
  Null
  True
  False
  Number(Double)
  String(String)
  Array(Array[Json])
  Object(Map[String, Json])
}
Json
{
15 { "row":
Point
self
.
(self : Point) -> Int
row
().
(self : Int) -> Json
to_json
(), "column":
Point
self
.
(self : Point) -> Int
column
().
(self : Int) -> Json
to_json
() }
16} 17 18///| 19extern "js" fn ts_point_new(row :
UInt
UInt
, column :
UInt
UInt
) ->
type Point
Point
=
20 #|(row, column) => { 21 #| return { row: row, column: column }; 22 #|} 23 24///| 25pub fn
type Point
Point
::
(row : Int, column : Int) -> Point
new
(
Int
row
:
Int
Int
,
Int
column
:
Int
Int
) ->
type Point
Point
{
26
(row : UInt, column : UInt) -> Point
ts_point_new
(
(value : Int) -> UInt
int_to_uint
(
Int
row
),
(value : Int) -> UInt
int_to_uint
(
Int
column
))
27} 28 29///| 30extern "js" fn ts_point_row(self :
type Point
Point
) ->
UInt
UInt
=
31 #|(point) => { 32 #| return point.row; 33 #|} 34 35///| 36pub fn
type Point
Point
::
(self : Point) -> Int
row
(
Point
self
:
type Point
Point
) ->
Int
Int
{
37
(value : UInt) -> Int
uint_to_int
(
(self : Point) -> UInt
ts_point_row
(
Point
self
))
38} 39 40///| 41extern "js" fn ts_point_column(self :
type Point
Point
) ->
UInt
UInt
=
42 #|(point) => { 43 #| return point.column; 44 #|} 45 46///| 47pub fn
type Point
Point
::
(self : Point) -> Int
column
(
Point
self
:
type Point
Point
) ->
Int
Int
{
48
(value : UInt) -> Int
uint_to_int
(
(self : Point) -> UInt
ts_point_column
(
Point
self
))
49} 50