prelude

Contains base types, functions and constants.
This module imported in any others by default.

true

Logical value of type Bool.
let true = Bool.True

false

Logical value of type Bool.
let false = Bool.False

inf

Infinity value of type Number.
let inf = Number.Inf

nan

Not-a-number value of type Number.
let nan = Number.NaN

pi

PI constant of type Number.
let pi = ...

e

E number.
let e = ...

nl

New line string, depends on environment ("\r\n" or "\n").
let enl = ...

print

Print value into standart output.
x value to print.
let print x =
    ...

println

Print value into standart output and put Text.NL at the end.
x value to print.
let print x =
    print x
    print Text.NL

readln

Read string from standart output.
let readln () =
    ...

readlnWith

Print prompt string and read string from standart output.
prompt value to print.
let readlnWith prompt =
    print prompt
    readln ()

functionIsNotImplementedForType

Raise system exception.
fName function name.
t type.
never
This function raises system exception.
Use it to mark that class function need to be implemented in some type.
let functionIsNotImplementedForType fName t =
    ...

Exception

Base class for any Lumen exception.
type Exception = class
    ...

message

Required function to implement Exception class
self 'T exception object
Text a string representation of an error
let message (self: 'T) =
    "exception raised"

Cloneable

Class for cloneable values.
type Cloneable = class
    ...

clone

Required function to implement Cloneable class. Make a non-deep copy of a value.
self 'T cloneable value
'T non-deep copy of a given value.
let clone (self: 'T) =
    functionIsNotImplementedForType "Cloneable.clone" 'T

Functor

Functor class.
type Functor = class
    ...

map

Required function to implement Functor class. Apply given function to each element of given container and returns new container value with the same structure.
fn Function function to apply
fc 'T container value
'T new container value with saved structure.
let map (fn: Function) (fc: 'T) =
    functionIsNotImplementedForType "Functor.map" 'T

>>

Alias for Functor.map, but with flip argument position
fc 'T container value
fn Function function to apply
'T new container value with saved structure.
let >>- (fc: 'T) (fn: Function) =
     'T.fmap fn fc

<<

Alias for Functor.map
fn Function function to apply
fc 'T container value
'T new container value with saved structure.
let -<< (fn: Function) (fc: 'T) =
     'T.map

Applicative

Applicative functor.
type Applicative = class
    ...

lift

Required function to implement Applicative class.
fn Function function to apply
fc 'T container value
'T new container value.
let lift (fn: Function) (fc: 'T) =
    functionIsNotImplementedForType "Applicative.lift" 'T

>>-

Alias for Applicative.lift, but with flip argument position
fc 'T container value
fn Function function to apply
'T new container.
let >>- (fc: 'T) (fn: Function) =
     'T.lift fn fc

Format

Format class uses to represent an value string interpolation
type Format = class
    ...

format

Required function to implement Format class. Takes an object to represent and string, that describes required format.
self 'T an object to represent
fstr Text describes required format
Text formatted string.
let format (self: 'T') (fstr: Text) =
    functionIsNotImplementedForType "Functor.fmap" 'T

Ord

This class contains functions for comparsion.
type Ord = class
    ...
type NumWrap = NumWrap a
    implements Ord
    // Implementation of Ord class
    let compare y x =
        if x.a < y.a:
            return -1
        if x.a > y.a:
            return 1
        return 0

let w1 = NumWrap 0
let w2 = NumWrap 7

println (w1 < w2)               //-> true
println (w1 > w2)              //-> false
println (w1 >= w2)            //-> false
println (Ord.min w1 w2)          //-> 0
println (Ord.max w1 w2)         //-> 7
println (NumWrap.compare w1 w2) //-> -1

compare

Required function to implement Ord class. Takes two objects, return -1, 0 or 1.
x 'T first object
y 'Y second object
Number returns zero if objects are equal, -1 if first object less than second, and 1 otherwise
let compare (x: 'T) (y: 'Y) =
    functionIsNotImplementedForType "Ord.compare" 'T

<=>

Alias for Ord.compare.
x 'T first object
y 'Y second object
Number returns zero if objects are equal, -1 if first object less than second, and 1 otherwise
let <=> = compare

<

Compare two values.
x 'T first object
y 'Y second object
Bool return true when x < y and false otherwise
let < x y =
    x.compare y < 0

>

Compare two values.
x 'T first object
y 'Y second object
Bool return true when x > y and false otherwise
let > x y =
    x.compare y > 0

<=

Compare two values.
x 'T first object
y 'Y second object
Bool return true when x <= y and false otherwise
let <= x y =
    x.compare y <= 0

>=

Compare two values.
x 'T first object
y 'Y second object
Bool return true when x >= y and false otherwise
let >= x y =
    x.compare y >= 0

min

Returns minimum of two values.
x 'T first value
y 'Y second value
'T | 'Y y when x > y, x otherwise
let min x y =
    ...

max

Returns maximum of two values.
x 'T first value
y 'Y second value
'T | 'Y x when x > y, y otherwise
let max x y =
    ...

between

Returns true if first parameter >= second and <= third.
x 'X first value
y 'Y second value
z 'Z thrid value
Bool true if first parameter >= second and <= third, false otherwise
let between x y z =
    ...

betweenInEx

Returns true if first parameter >= second and < third.
x 'X first value
y 'Y second value
z 'Z thrid value
Bool true if first parameter >= second and < third, false otherwise
let betweenInEx x y z =
    ...

betweenExIn

Returns true if first parameter > second and <= third.
x 'X first value
y 'Y second value
z 'Z thrid value
Bool true if first parameter > second and <= third, false otherwise
let betweenExIn x y z =
    ...

betweenExEx

Returns true if first parameter > second and < third.
x 'X first value
y 'Y second value
z 'Z thrid value
Bool true if first parameter > second and < third, false otherwise
let betweenExEx x y z =
    ...

Collection

Collection class.
type Collection = class
    implements Functor
    ...

toStream

Required function to implement Collection class. Make Stream value from 'T value.
self 'T self value
Stream new stream
let toStream (self: 'T) =
    functionIsNotImplementedForType "Collection.toStream" 'T

fromStream

Required function to implement Collection class. Make value of type 'T from Stream.
stream Stream stream to convert
'T
let toStream (stream: Stream) =
    functionIsNotImplementedForType "Collection.toStream" 'T

*

Returns length of stream.
This function iterate over each element of collection. Do not call this function on infinity collections.
self Stream
Number length of stream.
let * (self: Stream) =
    ...

/

Alias for Collection.foldl.
This function iterate over each element of collection. Do not call this function on infinity collections.
self Collection collection to fold
foldf Function folder function
'Y folded value
let / (self: Collection) (foldf: Function) = Collection.foldl

*

Alias for Collection.join.
This function iterate over each element of collection. Do not call this function on infinity collections.
self Collection collection to fold
sep Text separator
Text concatenated string.
let * (self: Collection) (foldf: Text) = Collection.join

*

Alias for Collection.repeat.
You can call this function with infinity collection, but it is meaningless.
self Collection collection to fold
count Int count of times to repeat
Collection repeated collection.
let * (self: Collection) (foldf: Int) = Collection.repeat

Text

Represent a text values.
type Text = ...
    implements Ord
    implements Cloneable
    implements Collection
    ...

*

Returns length of text.
self Text
Number length of text.
let * (self: Text) =
    ...

+

Concatenates two text values.
self Text left part of result.
other Text right part of result.
Text concatenated text.
let + (self: Text) (other: Text) =
    ...

*

Repeat text.
self Text text value to repeat.
other Number how many times repeat.
Text repeated text.
let * (self: Text) (times: Number) =
    ...

/

Split text by a separator.
self Text text value to repeat.
other Text separator.
Array parts of original text.
let / (self: Text) (other: Text) =
    ...

/

Split text on a parts with equal length.
self Text text value to repeat.
other Number maximum length of the part.
Array parts of original text.
let / (self: Text) (other: Number) =
    ...