Small ML Language
  • Small ML language
  • Installation
  • Hello World
  • Basics
    • Literals
    • Types
    • Type casting
    • Variables
    • Operators
    • Functions
    • Function chaining
    • Conditionals
    • Match
    • Arrays
    • Structs
    • Structure field Access
    • Enums
    • Enum Specialization
    • Object Destructuring
    • Modules
  • Compiler internals
    • SMLL to JAVA
Powered by GitBook
On this page
  1. Basics

Modules

Modular, like the 80s

Modules are important because they allow us to store and structure code as folders in the filesystem. They are mostly useful fo sparating different implementations of data and functions. SMLL moduls are inspired by Java Packages. They are just nested folders.

import System::Io

Some where there is a modules path which the standard library is located. Inside that modules directory there is a directory named System with the Io file.

<ROOTDIR> 
    └─ System 
        └─── Io.sml
        └─── Result.sml
        └─── Io
             └─── StdIo.sml

Importing modules simply works like this.

import System::Io::Stdio
import System::Io
import System::Result

These simply translate to the following.

imports System/Io/Stdio.sml
imports System/Io.sml
imports System/Result.sml
PreviousObject DestructuringNextSMLL to JAVA

Last updated 10 months ago