Skip to content

Instantly share code, notes, and snippets.

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",
View weird_stuff_with_let.ml
module X = struct
type record = { field: int }
let value = { field = 1 }
end
(* this works *)
let field =
match X.value with
| {field; _} -> field
(* this fails *)
let { field; _ } = X.value
View elaboration_mrmr.ml
(* this is an elaboration for:
let test (f : ((module S) [@ident M]) -> 'a M.t) =
let x : (module M) = M in
f x;;
which is a variant of the example at https://github.com/ocaml/ocaml/pull/9187#issuecomment-778476951
The goal here is to show that is posssible to describe the same code as above using FCM
View example_infinite_recursive_md_type.ml
type ('a, 'b) eq = Eq : ('a, 'a) eq
module type X = sig
module type T'
module type T = sig
module T : T'
end
type a
View elaboration_hkt.re
[@ocaml.ppx.context
{
tool_name: "ppxlib_driver",
include_dirs: [],
load_path: [
"",
"/home/eduardo/.esy/3_________________________________________________________________/i/ocaml-4.10.2000-76cdf1b9/lib/ocaml",
],
open_modules: [],
for_package: None,
View ocaml-improvements.md
  • remove caml_exn_Division_by_zero when it cannot happen, like a / (a * a)
  • perhaps generalize it to knowing that a number is positive not operating on it
  • do simple math inside of big functions
  • try to optimize x |> map() |> map()
  • search module String on https://ocaml.janestreet.com/ocaml-core/latest/doc/base/Base/
  • check to see if it inlines | x when is(x) and is is another pattern matching
  • typechecker should try to ensure value when dealing with records, there is no need to open a module for that
  • remove inner closures without any reference
  • let.some (_, _, name, received_value_type, index) =List.nth_opt(variable_table, table_index); no warning even if not used on index
@EduardoRFS
EduardoRFS / arch-tutorial.md
Last active Feb 26, 2021
Adicionado set-locale
View arch-tutorial.md

Resumo

  • criar partições
  • montar partições
  • instalar sistema
  • configurar hora
  • configurar rede
  • configurar localização
  • configurar usuario e sudo
  • configurar grub
View encode_gadt.ml
type _ ty = Int_t : int ty | List_t : 'a ty -> 'a list ty
type ex_ty = Ex_ty : _ ty -> ex_ty
type ex_value = Ex_value : 'a ty * 'a -> ex_value
let rec encode_ty : type a. a ty -> string = function
| Int_t -> "Int_t"
| List_t ty -> Format.sprintf "List_t(%s)" (encode_ty ty)