OCaml

63 readers
1 users here now

A community for the OCaml programming language https://ocaml.org/

Looking for mods, if you want to mod the community feel free to dm Ategon

Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient

founded 10 months ago
MODERATORS
1
2
 
 

There is more to Hindley-Milner type inference than the Algorithm W. In 1988, Didier Rémy was looking to speed up the type inference in Caml and discovered an elegant method of type generalization. Not only it is fast, avoiding scanning the type environment. It smoothly extends to catching of locally-declared types about to escape, to type-checking of universals and existentials, and even to MLF.

Alas, both the algorithm and its implementation in the OCaml type checker are little known and little documented. This page is to explain and popularize Rémy's algorithm, and to decipher a part of the OCaml type checker. The page also aims to preserve the history of Rémy's algorithm.

Read How OCaml type checker works

3
4
 
 

Jun 28, 2024

Matt Walker writes:

This is an extremely early stage of development, but basically at this point it is possible to:

  • Call any builtin Godot utility function or method (static, virtual, or otherwise) from OCaml easily, and with documentation comments for the original function intact an available through your favourite OCaml LSP implementation.
  • Use Godot (binary) operators in a natural way from OCaml. (Unary operators are currently broken, which I will be investigating!)
  • Construct Godot values from OCaml easily, and from OCaml analogues if they exist (e.g. I incur a dependency on Gg for low-dimensional vector math)
  • Marshalling in and out of all these functions to/from the OCaml analogues. That is, a method that is in Godot on an object of type ClassyClass taking an int parameter and returning an int will appear in Godotcaml as int64 -> ClassyClass.t structure ptr -> int64, where the ClassyClass.t structure ptr is the “pointer to the Godot object”, commonly called self. (Note that this is always the last argument, to facilitate pipeline-style programming when GDScript programmers have a method-chaining interface.)
  • Naturally define a new Godot class in OCaml that inherits from an existing Godot-registered class. (Currently NOT tested with classes defined in GDScript and/or externally.)
  • Most of the code-gen for custom engines that define new stock/builtin types and classes, etc.
  • Simulated inheritence for stock (and easily extendable to user-defined) classes using module inclusion: That is if Derived inherits from Base, then simply include Base in the module representing Derived, and you get access to all the methods from Base without explicit casting (or in the case of Rust’s gdext, object composition).
  • Naturally define a new Godot method in OCaml and have it called from GDScript or another Godot-bound language. (ergonomics still WIP).

Read Announcing Godotcaml for Godot 4.2

See also: Setting Up a Godotcaml Project (Today)

5
6
7
8
9
10
11
12
13
14
15
 
 

I had been meaning to try OCaml for a long time, and saw the opportunity.

My daughter's school schedule was sent in an inconvenient format (screenshot), so I decided to type it in manually in sexps, which I am a fan of.

These are used as a source for my program to generate icalendar with recurrences, exceptions for the holidays, and so on. Someone might find it useful as reference too.

16
17
18
19
20
21
22
23
24