Catalog / ML Programming Language Cheatsheet
ML Programming Language Cheatsheet
A concise cheat sheet covering the essential syntax, features, and concepts of the ML programming language family (Standard ML, OCaml, F#). Useful for quick reference and learning.
Core Syntax and Types
Basic Syntax
Variable Binding |
|
Function Definition |
|
Comments |
(* SML comment ) (SML) |
Sequential Execution |
|
Unit Type |
|
String Concatenation |
|
Data Types
Integer |
|
Real/Float |
|
Boolean |
|
String |
|
Character |
|
Unit |
|
Operators
Arithmetic |
|
Comparison |
|
Boolean |
|
Floating-point Arithmetic |
|
Integer division |
|
Modulus |
|
Control Flow and Data Structures
Conditional Statements
If-Then-Else |
|
Case/Match Statements |
|
Boolean Conditionals |
|
String Conditionals |
|
Lists
List Creation |
|
Cons Operator |
|
Head and Tail |
|
List Length |
|
Appending Lists |
|
Map Function |
|
Tuples
Tuple Creation |
|
Accessing Elements |
|
Deconstruction |
|
Example Tuple |
|
Functions and Modules
Function Definitions
Basic Function |
|
Recursive Function |
|
Anonymous Function (Lambda) |
|
Curried Function |
|
Higher-Order Function |
|
Modules
Module Definition |
|
Module Signature (Interface) |
|
Module Implementation |
|
Accessing Module Members |
|
Opening a Module |
|
Advanced Features
Exceptions
Exception Declaration |
|
Raising an Exception |
|
Exception Handling |
|
Standard Exceptions |
|
References (Mutable State)
Creating a Reference |
|
Accessing a Reference |
|
Updating a Reference |
|
Example Usage |
|
Records (Structs)
Record Definition |
|
Accessing Record Fields |
|
Record Update (Functional) |
|