Skip to content

Instantly share code, notes, and snippets.

Avatar
♥️
Laughing at the abysm

Eduardo Rafael EduardoRFS

♥️
Laughing at the abysm
View GitHub Profile
View talk-foton.md

Tipos nominais

  • Duas funções com mesmo nome e tipo

Simplicidade

Inferencia de tipos

Invariantes

View bad.mligo
type blake2b = bytes
(* store hash *)
module Root_hash = struct
type validator = key
type validators = validator list
type storage = {
(* TODO: is having current_block_hash even useful? *)
(* consensus proof *)
View good.mligo
type blake2b = bytes
(* store hash *)
type validator = key
type validators = validator list
type storage = {
(* TODO: is having current_block_hash even useful? *)
(* consensus proof *)
current_block_hash: blake2b;
View funcional-tipado.md

Por que eu deveria ligar para funcional tipado?

Soundness

  • Garante o treco ser rápido, sem checar se valor é null ou não, apenas mov
View fcm_are_cool.ml
module type S1 = sig
val row_a : int
val row_b : float
end
module type S2 = sig
val row_b : float
val row_a : int
end
module type V = sig
val row_a : int
View php_like_array.re
/* this miss all the casts in PHP, it's more of a low level implementation
on how you could commit such crime while still being relatively fast */
// TODO: use vectors instead of Array
module Array: {
module Key: {
type t =
| Int(int)
| String(string);
let compare: (t, t) => int;
};
View js_sucks.js
const tests = [
[
"for",
(array) => {
const new_array = new Array(3);
for (let index = 0; index < array.length; index++) {
new_array[index] = array[index] + 1;
}
return new_array;
},
View ocaml-elaboration.ml
module type Monad = sig
type 'a t
val return : 'a -> 'a t
val bind : 'a t -> ('a -> 'b t) -> 'b t
end
include struct
module type HKT_Magic_0 = sig
View is_this_fcm.ml
module type Show = sig
type t
val show: t -> string
end
let show (module S: Show) v = S.show v
module Show_option (S: Show) = struct
type t = S.t option
let show v =
View tree-sitter.json
{
"dependencies": {
"ocaml": "4.12.x",
"@opam/tree-sitter": "*"
},
"resolutions": {
"@opam/tree-sitter": {
"source": "github:returntocorp/ocaml-tree-sitter:tree-sitter.opam#bee63d6c4ac7b6d24539f9f2c8cf5ba57ecce91d",
"override": {
"build": "dune build -p tree-sitter",