OCaml Cookbook Recipes

The OCaml Cookbook is a place where OCaml developers share how to solve common tasks using packages from the ecosystem.

A task is something that needs to be done inside a project. A recipe is a code sample and explanations on how to perform a task using a combination of open source libraries. Some tasks can be performed using different combination of libraries, each is a different recipe. Tasks don't describe how to use the standard library or language features.

OCaml developers are warmly invited to contribute categories, tasks, and recipes. See the Cookbook section of the CONTRIBUTING.md file in our GitHub repo.

The OCaml guides are recommend reading, for instance recipes handle errors as described in the Error Handling guide.

Command Line

Task
Opam Packages Used
Parse Command Line Arguments

This task has no recipes yet, maybe you want to contribute a recipe!

Using the ANSI Terminal

This task has no recipes yet, maybe you want to contribute a recipe!

Compilation & Linking

Task
Opam Packages Used
Compile and Link to a Bundled C Library

This task has no recipes yet, maybe you want to contribute a recipe!

Generate OCaml Bindings for a C Library

This task has no recipes yet, maybe you want to contribute a recipe!

Concurrency & Parallelism

Parallelism & Multi-Threading

Task
Opam Packages Used
Spawn a Thread and Receive a Response

This task has no recipes yet, maybe you want to contribute a recipe!

Pass Data Between Parallel Threads

This task has no recipes yet, maybe you want to contribute a recipe!

Data Structures & Algorithms

Hash Tables

Task
Opam Packages Used
Use a Hash Table With Given Key and Value Types

This task has no recipes yet, maybe you want to contribute a recipe!

Database

PostgreSQL

Task
Opam Packages Used
PostgreSQL CREATE, INSERT, SELECT

This task has no recipes yet, maybe you want to contribute a recipe!

PostgreSQL Aggregate Query

This task has no recipes yet, maybe you want to contribute a recipe!

PostgreSQL Full Text Search

This task has no recipes yet, maybe you want to contribute a recipe!

Date and Time

Task
Opam Packages Used
Measure Elapsed Time

This task has no recipes yet, maybe you want to contribute a recipe!

Convert a Local Time to Another Time Zone

This task has no recipes yet, maybe you want to contribute a recipe!

Convert Between Date and Unix Timestamp

This task has no recipes yet, maybe you want to contribute a recipe!

Display Formatted Date and Time

This task has no recipes yet, maybe you want to contribute a recipe!

Parse Date and Time from String

This task has no recipes yet, maybe you want to contribute a recipe!

Debugging

Task
Opam Packages Used
Debug Print a Value

This task has no recipes yet, maybe you want to contribute a recipe!

Log a Debug / Error Message to Stdout / Stderr

This task has no recipes yet, maybe you want to contribute a recipe!

Log to the Unix Syslog

This task has no recipes yet, maybe you want to contribute a recipe!

Encoding

Task
Opam Packages Used

File System

Task
Opam Packages Used
File Size

This task has no recipes yet, maybe you want to contribute a recipe!

Change File Permissions

This task has no recipes yet, maybe you want to contribute a recipe!

Walk File Tree

This task has no recipes yet, maybe you want to contribute a recipe!

Find Files Matching a Pattern

This task has no recipes yet, maybe you want to contribute a recipe!

Graphical User Interfaces

There's nothing in this category yet.

Text Processing

Unicode / UTF-8

Task
Opam Packages Used

Web Programming

Media Types (MIME)

Task
Opam Packages Used
Get MIME Type From String

This task has no recipes yet, maybe you want to contribute a recipe!

Get MIME Type From Filename

This task has no recipes yet, maybe you want to contribute a recipe!

Parse MIME Type of an HTTP Response

This task has no recipes yet, maybe you want to contribute a recipe!

Running a Web Server

Task
Opam Packages Used
Start a Web Server With a 'Hello World' Endpoint

This task has no recipes yet, maybe you want to contribute a recipe!

Start a Web Server That Serves an HTML Template

This task has no recipes yet, maybe you want to contribute a recipe!

Use Basic Authentication to Secure a Route

This task has no recipes yet, maybe you want to contribute a recipe!

Dealing with HTML

OCaml

Innovation. Community. Security.