Learn ML with Real Code Examples
Updated Nov 20, 2025
Installation Setup
Install an ML implementation (e.g., Standard ML of New Jersey, OCaml)
Verify installation with REPL (interactive environment)
Set up a source code directory
Write sample .ml files
Compile and run using ML compiler or REPL
Environment Setup
Install SML/NJ or OCaml
Set environment variables if needed
Verify REPL runs
Organize source directories
Test sample programs
Config Files
.ml source files
.mli signature files
Build scripts or makefiles
Module dependencies
Test scripts
Cli Commands
sml
ocaml
mlton program.ml
use REPL to evaluate expressions
compile with smlnj compiler
Internationalization
Supports Unicode in OCaml variants
ML syntax is ASCII-based
Localization handled externally
Date/time and number formatting managed externally
Text processing possible with libraries
Accessibility
REPL provides interactive access
Editors support ML syntax highlighting
Extensive documentation for learning
Community examples in academia
Accessible on Windows, Linux, Mac via SML/NJ or OCaml
Ui Styling
ML is text-based; no direct UI
Integration possible with bindings for GUI libraries
Primarily used in REPL or console
Output via standard printing functions
Visualization via external tools if needed
State Management
Immutable variables hold state
Recursion replaces iterative state changes
Modules encapsulate functionality
References used sparingly for mutable state
Garbage collection manages memory
Data Management
Lists, tuples, records, and algebraic types
Immutable by default
Pattern matching for deconstruction
Optional arrays or refs for mutable data
Functional pipelines for transformations