arregla el puto ssh elisiei subnormal cómo voy a adivinar que el puerto ssh es el puto 22222? Acaso soy adivino?
(* Primitive types *)
byte bits32 bits64 bits128
ubyte ubits32 ubits64 ubits128
float32 float64 bool
int (* alias to 'bits64' *)
float (* alias to 'float64' *)
number (* arbitrary length *)
string (* same as `u8 array` *)
(* Product types *)
type vec3 = { x: float; y: float; z: float }(* mutability *)
let counter : int ref = ref 1
(* syntax sugar *)
let add a b = a+b
(* de-sugared *)
let add = fun a b -> a+b
(* even more de-sugared *)
let add = fun b -> fun b -> a+btype 'a some = { value : 'a }
type none = { }union option = {
some : 'a some
none : none
}type 'a adt_option =
| 'a some
| nonedata 'a option =
| Some of 'a
| Nonetype person = {
age : int
name : u8 array
}
let my_person = person 16 "yuzu"
let my_tuple = (16, "yuzu")external read_file (path : string) : string = "read_file"
external print (s : string) : unit = "puts"
let greet () =
let name = read_file "name.txt" in
print ("Hello, " .. name)type particle = {
position : vec3
velocity : vec3
}
(* gets the alignment of particle *)
alignof particle
(* gets the typeof particle *)
typeof particle
(* may also be packed *)
@packed
type particle = {
position : vec3
velocity : vec3
}
(* stack-only allocation *)
@stack
type particle = {
position : vec3
velocity : vec3
}(* optimizes it as a struct of arrays layout *)
@soa
type entity = {
position: vec3;
velocity: vec3;
health: float;
}
(* effectively it becomes: *)
type entity {
cap : int
len : int
positions : vec3 ptr
velocities : vec3 ptr
healths : float ptr (* TODO: this is only possible with void pointers LOL *)
}
(* works with bare unions *)
(* it is a way more effective design than allocating ADTs *)
@soa
union animal = {
koala : Koala
jiraffe : Jiraffe
}
(* effectively it becomes *)
enum animal_type = {
koala
jiraffe
}
union animal_data = {
koala : Koala
jiraffe : Jiraffe
}
type animals = {
data : animal_data array
types : animal_type array
}let area s =
match s with
| Circle { radius } -> Math.pi *. radius *. radius
| Rect { width; height } -> width *. heightmodule Physics = struct
@private (* everything is public by default *)
let gravity = 9.81
let apply_force mass acceleration =
mass *. acceleration
endjust as OCaml
just as OCaml
no need, everything is public
with custom allocators if possible