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.
- stack Module
- Defines combinators and stack-shufflers like dip, dup, swap, cons, etc.
- seq Module
- Defines operators for quotations, like map, filter, reduce, etc.
- dict Module
- Defines operators for dictionaries, like dget, ddup, dset, etc.
- dstore Module
- Provides support for simple, persistent, in-memory JSON stores.
- io Module
- Provides operators for reading and writing files as well as printing to STDOUT and reading from STDIN.
- fs Module
- Provides operators for accessing file information and properties.
- logic Module
- Provides comparison operators for all min data types and other boolean logic operators.
- str Module
- Provides operators to perform operations on strings, use regular expressions, interpolation, etc.
- sys Module
- Provides operators to use as basic shell commands, access environment variables, and execute external commands.
- num Module
- Provides operators to perform simple mathematical operations on integer and floating point numbers.
- time Module
- Provides a few basic operators to manage dates, times, and timestamps.
- crypto Module
- Provides operators to compute hashes (MD4, MD5, SHA1, SHA224, SHA256, SHA384, sha512), base64 encoding/decoding, and AES encryption/decryption.
- 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).
- http Module
- Provides operators to perform HTTP requests, download files and create basic HTTP servers.
- 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 socket operator:
{ "ipv4" :domain "stream" :type "tcp" :protocol ;socket }- dict:rawval
A raw value dictionary obtained via the get-raw or dget-raw operators:
{ "sym" :type "my-symbol" :str my-symbol :val ;rawval }- dict:datastore
A datastore dictionary that must be created through the dsinit or dsread 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