Skip to content

Commit d47d18b

Browse files
committed
feat: add language ocaml
1 parent 3cc50d1 commit d47d18b

11 files changed

Lines changed: 99 additions & 4 deletions

File tree

LANGUAGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@
8080
- [x] Jupyter Notebook (`jupyter-notebook`)
8181
- [x] Elixir (`elixir`)
8282
- [x] Haskell (`haskell`)
83+
- [x] OCaml (`ocaml`)
8384

8485
## Pending
8586

86-
- [ ] OCaml (`ocaml`)
8787
- [ ] Protocol Buffers (`protobuf`)
8888
- [ ] Racket (`racket`)
8989
- [ ] Rego (`rego`)

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ import { meson } from "code-languages/meson";
9191
import { metal } from "code-languages/metal";
9292
import { nginx } from "code-languages/nginx";
9393
import { nix } from "code-languages/nix";
94+
import { ocaml } from "code-languages/ocaml";
9495
import { objectiveC } from "code-languages/objective-c";
9596
import { pascal } from "code-languages/pascal";
9697
import { perl } from "code-languages/perl";
@@ -244,6 +245,7 @@ import {
244245
metal,
245246
nginx,
246247
nix,
248+
ocaml,
247249
objectiveC,
248250
pascal,
249251
perl,
@@ -316,6 +318,7 @@ console.log(localizeLanguage(meson, "es").description);
316318
console.log(localizeLanguage(metal).description);
317319
console.log(localizeLanguage(nginx, "es").description);
318320
console.log(localizeLanguage(nix, "es").description);
321+
console.log(localizeLanguage(ocaml, "es").description);
319322
console.log(objectiveC.extensions);
320323
console.log(localizeLanguage(pascal, "es").description);
321324
console.log(localizeLanguage(perl).description);
@@ -483,6 +486,7 @@ console.log(detectLanguages("include/config.h").map((language) => language.slug)
483486
| <img src="https://developer.apple.com/assets/elements/icons/metal/metal-256x256_2x.png" alt="Metal logo" width="24" height="24"> | Metal | `metal` | `.metal` | `Metal 4` | `code-languages/metal` |
484487
| <img src="https://upload.wikimedia.org/wikipedia/commons/c/c5/Nginx_logo.svg" alt="nginx logo" width="24" height="24"> | nginx | `nginx` | `nginx.conf`, `.nginx`, `.conf` | `1.30.1` | `code-languages/nginx` |
485488
| <img src="https://cdn.simpleicons.org/nixos/5277C3" alt="Nix logo" width="24" height="24"> | Nix | `nix` | `.nix` | `2.28` | `code-languages/nix` |
489+
| <img src="https://cdn.simpleicons.org/ocaml/EC6813" alt="OCaml logo" width="24" height="24"> | OCaml | `ocaml` | `.ml`, `.mli`, `.mll`, `.mly`, `.mlt`, `.eliom`, `.eliomi` | `5.6.0` | `code-languages/ocaml` |
486490
| <img src="https://upload.wikimedia.org/wikipedia/commons/1/1b/Apple_logo_grey.svg" alt="Objective-C logo" width="24" height="24"> | Objective-C | `objective-c` | `.m`, `.mm` | `2.0` | `code-languages/objective-c` |
487491
| <img src="https://cdn.simpleicons.org/lazarus/000000" alt="Pascal logo" width="24" height="24"> | Pascal | `pascal` | `.pas`, `.pp`, `.inc`, `.lpr`, `.dpr`, `.dfm` | `3.2.2` | `code-languages/pascal` |
488492
| <img src="https://cdn.simpleicons.org/perl/39457E" alt="Perl logo" width="24" height="24"> | Perl | `perl` | `.pl`, `.pm`, `.pod`, `.t`, `.psgi` | `5.42.2` | `code-languages/perl` |

docs/data/languages.json

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"generatedAt": "2026-05-15T21:24:08.622Z",
3-
"total": 78,
4-
"extensions": 230,
2+
"generatedAt": "2026-05-15T21:31:45.506Z",
3+
"total": 79,
4+
"extensions": 237,
55
"locales": ["en", "es"],
66
"languages": [
77
{
@@ -1054,6 +1054,27 @@
10541054
"version": "2.0",
10551055
"logo": "https://upload.wikimedia.org/wikipedia/commons/1/1b/Apple_logo_grey.svg"
10561056
},
1057+
{
1058+
"slug": "ocaml",
1059+
"name": "OCaml",
1060+
"description": "A statically typed ML-family language with modules, inference, and native compilation.",
1061+
"longDescription": "OCaml combines functional, imperative, and object-oriented programming with Hindley-Milner type inference, algebraic data types, pattern matching, functors, and a powerful module system.\n\nIt is used for compilers, theorem provers, static analysis, developer tools, financial systems, systems software, and production services where strong types, performance, and maintainability matter.",
1062+
"esName": "OCaml",
1063+
"esDescription": "Un lenguaje de la familia ML con tipado estatico, modulos, inferencia y compilacion nativa.",
1064+
"esLongDescription": "OCaml combina programacion funcional, imperativa y orientada a objetos con inferencia de tipos Hindley-Milner, tipos algebraicos, pattern matching, functors y un sistema de modulos potente.\n\nSe usa en compiladores, demostradores de teoremas, analisis estatico, herramientas de desarrollo, sistemas financieros, software de sistemas y servicios de produccion donde importan los tipos fuertes, el rendimiento y la mantenibilidad.",
1065+
"publishedDate": "1996-01-01",
1066+
"extensions": [".ml", ".mli", ".mll", ".mly", ".mlt", ".eliom", ".eliomi"],
1067+
"author": "Xavier Leroy, Jerome Vouillon, Damien Doligez, Didier Remy, Ascander Suarez",
1068+
"website": "https://ocaml.org",
1069+
"paradigms": ["functional", "imperative", "object-oriented", "modular"],
1070+
"tooling": {
1071+
"runtimes": ["OCaml Runtime", "Native Code Compiler", "Bytecode Interpreter"],
1072+
"packageManagers": ["opam", "Dune"],
1073+
"ecosystems": ["Compilers", "Formal Methods", "Systems Programming", "Web"]
1074+
},
1075+
"version": "5.6.0",
1076+
"logo": "https://cdn.simpleicons.org/ocaml/EC6813"
1077+
},
10571078
{
10581079
"slug": "pascal",
10591080
"name": "Pascal",

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,11 @@
391391
"import": "./dist/languages/markdown.js",
392392
"require": "./dist/languages/markdown.cjs"
393393
},
394+
"./ocaml": {
395+
"types": "./dist/languages/ocaml.d.ts",
396+
"import": "./dist/languages/ocaml.js",
397+
"require": "./dist/languages/ocaml.cjs"
398+
},
394399
"./objective-c": {
395400
"types": "./dist/languages/objective-c.d.ts",
396401
"import": "./dist/languages/objective-c.js",

scripts/check-language-versions.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,15 @@ const checkers = {
284284
sourceUrl: "https://www.lua.org/download.html",
285285
};
286286
},
287+
async ocaml() {
288+
const html = await fetchText("https://ocaml.org/p/ocaml/latest/versions");
289+
const versions = [...html.matchAll(/>\s*(\d+\.\d+\.\d+)\s*<\/a>/g)].map((match) => match[1]);
290+
291+
return {
292+
latestVersion: latestSemver(versions),
293+
sourceUrl: "https://ocaml.org/p/ocaml/latest/versions",
294+
};
295+
},
287296
async makefile() {
288297
const html = await fetchText("https://ftp.gnu.org/gnu/make/");
289298
const versions = [...html.matchAll(/make-(\d+\.\d+(?:\.\d+)?)\.tar\.gz/g)].map(

src/catalog.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import { metal } from "./languages/metal";
4848
import { nginx } from "./languages/nginx";
4949
import { nix } from "./languages/nix";
5050
import { objectiveC } from "./languages/objective-c";
51+
import { ocaml } from "./languages/ocaml";
5152
import { pascal } from "./languages/pascal";
5253
import { perl } from "./languages/perl";
5354
import { php } from "./languages/php";
@@ -129,6 +130,7 @@ export const languages = [
129130
svn,
130131
nginx,
131132
nix,
133+
ocaml,
132134
objectiveC,
133135
pascal,
134136
perl,

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export { meson } from "./languages/meson";
6060
export { metal } from "./languages/metal";
6161
export { nginx } from "./languages/nginx";
6262
export { nix } from "./languages/nix";
63+
export { ocaml } from "./languages/ocaml";
6364
export { objectiveC } from "./languages/objective-c";
6465
export { pascal } from "./languages/pascal";
6566
export { perl } from "./languages/perl";

src/language-registry.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export const languageIndex = [
6969
{ slug: "svn", extensions: [".svn", "svnserve.conf"] },
7070
{ slug: "nginx", extensions: ["nginx.conf", ".nginx", ".conf"] },
7171
{ slug: "nix", extensions: [".nix"] },
72+
{ slug: "ocaml", extensions: [".ml", ".mli", ".mll", ".mly", ".mlt", ".eliom", ".eliomi"] },
7273
{ slug: "objective-c", extensions: [".m", ".mm"] },
7374
{ slug: "pascal", extensions: [".pas", ".pp", ".inc", ".lpr", ".dpr", ".dfm"] },
7475
{ slug: "perl", extensions: [".pl", ".pm", ".pod", ".t", ".psgi"] },
@@ -158,6 +159,7 @@ export const languageLoaders = {
158159
svn: () => import("./languages/svn").then((module) => module.svn),
159160
nginx: () => import("./languages/nginx").then((module) => module.nginx),
160161
nix: () => import("./languages/nix").then((module) => module.nix),
162+
ocaml: () => import("./languages/ocaml").then((module) => module.ocaml),
161163
"objective-c": () => import("./languages/objective-c").then((module) => module.objectiveC),
162164
pascal: () => import("./languages/pascal").then((module) => module.pascal),
163165
perl: () => import("./languages/perl").then((module) => module.perl),

src/languages/ocaml.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type { Language } from "../types";
2+
3+
export const ocaml = {
4+
slug: "ocaml",
5+
publishedDate: "1996-01-01",
6+
extensions: [".ml", ".mli", ".mll", ".mly", ".mlt", ".eliom", ".eliomi"],
7+
author: "Xavier Leroy, Jerome Vouillon, Damien Doligez, Didier Remy, Ascander Suarez",
8+
website: "https://ocaml.org",
9+
paradigms: ["functional", "imperative", "object-oriented", "modular"],
10+
tooling: {
11+
runtimes: ["OCaml Runtime", "Native Code Compiler", "Bytecode Interpreter"],
12+
packageManagers: ["opam", "Dune"],
13+
ecosystems: ["Compilers", "Formal Methods", "Systems Programming", "Web"],
14+
},
15+
version: "5.6.0",
16+
logo: "https://cdn.simpleicons.org/ocaml/EC6813",
17+
i18n: {
18+
en: {
19+
name: "OCaml",
20+
description:
21+
"A statically typed ML-family language with modules, inference, and native compilation.",
22+
longDescription:
23+
"OCaml combines functional, imperative, and object-oriented programming with Hindley-Milner type inference, algebraic data types, pattern matching, functors, and a powerful module system.\n\nIt is used for compilers, theorem provers, static analysis, developer tools, financial systems, systems software, and production services where strong types, performance, and maintainability matter.",
24+
},
25+
es: {
26+
name: "OCaml",
27+
description:
28+
"Un lenguaje de la familia ML con tipado estatico, modulos, inferencia y compilacion nativa.",
29+
longDescription:
30+
"OCaml combina programacion funcional, imperativa y orientada a objetos con inferencia de tipos Hindley-Milner, tipos algebraicos, pattern matching, functors y un sistema de modulos potente.\n\nSe usa en compiladores, demostradores de teoremas, analisis estatico, herramientas de desarrollo, sistemas financieros, software de sistemas y servicios de produccion donde importan los tipos fuertes, el rendimiento y la mantenibilidad.",
31+
},
32+
},
33+
} satisfies Language;

tests/detect.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
lua,
2525
meson,
2626
metal,
27+
ocaml,
2728
perl,
2829
razor,
2930
ruby,
@@ -74,6 +75,14 @@ describe("detectLanguage", () => {
7475
expect(detectLanguage("package/example.cabal")).toBe(haskell);
7576
});
7677

78+
it("detects OCaml source, interface, lexer, parser, and Eliom files", () => {
79+
expect(detectLanguage("lib/main.ml")).toBe(ocaml);
80+
expect(detectLanguage("lib/main.mli")).toBe(ocaml);
81+
expect(detectLanguage("lexer.mll")).toBe(ocaml);
82+
expect(detectLanguage("parser.mly")).toBe(ocaml);
83+
expect(detectLanguage("app/page.eliom")).toBe(ocaml);
84+
});
85+
7786
it("detects Erlang source and project files", () => {
7887
expect(detectLanguage("src/chat_server.erl")).toBe(erlang);
7988
expect(detectLanguage("include/chat_server.hrl")).toBe(erlang);

0 commit comments

Comments
 (0)