Reference
min includes a small but powerful standard library organized into the following modules:
- global Module
- Defines the basic language constructs, such as control flow, type conversions, symbol definition and binding, exception handling, etc. This module is automatically imported (no need to prepend global. . to reference its symbols).
- crypto Module
- Provides operators to compute hashes (MD4, MD5, SHA1, SHA224, SHA256, SHA384, sha512), base64 encoding/decoding, and AES encryption/decryption.
- dict Module
- Defines operators for dictionaries, like dict.get, dict.dup, dict.set, etc.
- fs Module
- Provides operators for reading and writing files, and accessing file information and properties.
- http Module
- Provides operators to perform HTTP requests, download files and create basic HTTP servers.
- io Module
- Provides operators for writing to STDOUT, reading from STDIN, capturing key presses, etc.
- math Module
- Provides many mathematical operators and constants such as trigonometric functions, square root, logarithms, etc.
- net Module
- Provides basic supports for sockets (some features are not supported on Windows systems).
- stack Module
- Defines combinators and stack-shufflers like stack.pop, stack.dup, stack.swap, stack.cons, etc.
- store Module
- Provides support for simple, persistent, in-memory JSON stores.
- sys Module
- Provides operators to use as basic shell commands, access environment variables, and execute external commands.
- time Module
- Provides a few basic operators to manage dates, times, and timestamps.
- xml Module
- Provides operators for parsing, creating and querying XML/HTML code using CSS selectors.
Notation
The following notation is used in the signature of all min operators:
Types and Values
- ∅
- No value.
- null
- null value
- a
- A value of any type.
- bool
- A boolean value
- int
- An integer value.
- flt
- A float value.
- num
- A numeric (integer or float) value.
- str
- A string value.
- 'sym
- A string-like value (string or quoted symbol).
- quot
- A quotation (also expressed as parenthesis enclosing other values).
- dict
- A dictionary value.
- dict:help
A help dictionary:
{ "puts" :name "symbol" :kind "a ==>" :signature "Prints a and a new line to STDOUT." :description ;help }- dict:url
An URL dictionary:
{ "http" :scheme "h3rald" :hostname "" :port "" :username "" :password "/min" :path "" :anchor "" :query ;url }- dict:timeinfo
A timeinfo dictionary:
{ 2017 :year 7 :month 8 :day 6 :weekday 188 :yearday 15 :hour 16 :minute 25 :second true :dst -3600 :timezone ;UTC offset ;timeinfo }- dict:error
An error dictionary:
{ "MyError" :error "An error occurred" :message "symbol1" :symbol "dir1/file1.min" :filename 3 :line 13 :column ;error }- dict:socket
A socket dictionary that must be created through the net.socket operator:
{ "ipv4" :domain "stream" :type "tcp" :protocol ;socket }- dict:rawval
A raw value dictionary obtained via the seq.get-raw or dict.dget-raw operators:
{ "sym" :type "my-symbol" :str my-symbol :val ;rawval }- dict:datastore
A datastore dictionary that must be created through the store.init or store.read operator:
{ {} :data "path/to/file.json" :path ;datastore }- dict:http-request
A request dictionary, representing an HTTP request to be performed through the operators exposed by the http Module:
{ "http://httpbin.org/put" :url "PUT" :method "1.1" :version ;optional "h3rald.com" :hostname ;optional { "it-id" :Accept-Language "httpbin.org" :Host } :headers ;optional "test body" :body ;optional ;http-request }- dict:http-response
A response dictionary, representing an HTTP response returned by some of the operators exposed by the http Module:
{ "1.1" :version ;optional 200 :status ;optional { "application/json" :Content-Type } :headers ;optional "{\"test\": \"This is a test\"}" :body ;http-response }- dict:xml-element
A dictionary representing an XML or HTML element, exposed by the xml Module
{ {"https://min-lang.org" :href} :attributes ({"min web site" :text}) :children "a" :tag ;xml-element }- dict:xml-comment
A dictionary representing an XML comment.
{ "This is a comment" :text ;xml-comment }- dict:xml-cdata
A dictionary representing XML CDATA text.
{ "This is some text" :text ;xml-cdata }- dict:xml-entity
A dictionary representing an XML entity.
{ "amp" :text ;xml-entity }- dict:xml-text
A dictionary representing XML text.
{ "This is some text" :text ;xml-text }- xml-node
A typealias to identify all XML dictionary types.
dict:xml-element||dict:xml-text||dict:xml-comment||dict:xml-entity||dict:xml-cdata
Suffixes
The following suffixes can be placed at the end of a value or type to indicate ordering or quantities.
- 1
- The first value of the specified type.
- 2
- The second value of the specified type.
- 3
- The third value of the specified type.
- 4
- The fourth value of the specified type.
- ?
- Zero or one.
- *
- Zero or more.
- +
- One or more