Int. Creating literal nodes is as simple as opening the Explorer and typing in the desired value.
Ints are just numbers without a decimal point,
Reals are those numbers that do contain a decimal point.
Texts are arbitrary series of characters, delimited by quotes.
Int, representing integers of arbitrary size and
Real, for floating point numbers.
[info] Changes ahead!Currently, the type of a numeric literal is decided based on the presence of decimal point. This means, that
1has the type
1.0has the type
Real. In the future releases of Luna, the numeric literals will be polymorphic, allowing to write expressions like
1.7 + 2.
Text. Luna supports two kinds of text literals: interpreted and uninterpreted. The interpreted texts are wrapped in single quotes. They provide the capabilities to insert escaped character sequences such as
\netc. The uninterpreted strings are wrapped in double quotes and do not provide any such facilities. The only character that can be escaped in an uninterpreted text is
\"itself. It is usually sufficient and more handy to use single–quoted (interpreted) texts by default, unless you need to type in a text containing many special characters.
[info] Changes ahead!In the future releases of Luna the interpreted texts will also allow to insert arbitrary expressions, results of which will be then inserted into the resulting text. For example
'Adding 2 and 2 gives `2 + 2` in result'will be evaluated to
'Adding 2 and 2 gives 4 in result'.
Boolclass. It has two constructors:
False. They support basic logical combinators such as
if_then_else. It can be used in this form (i.e.
if_then_else condition valueWhenTrue valueWhenFalse) or, more elegantly, in its mixfix form:
[3, 4, 5]of type
['first', 'second', 'third']of type
List Text. There are also some interesting functions and methods in the standard library, that return lists of desired shape – make sure to go through the available methods using the Explorer. Some examples are:
[info] Changes ahead!In the future versions of Luna, lists and tuples will be merged into one type – a list which fully understands its structure and allows to encode information about its length and different element types on type level. Thus you may expect code like
["Hello", 32, False]to be valid Luna soon.
nullvalue. That means, if you have a value of type
Int, there will always be a number, there is no way to have an "invalid" number. If there is a possibility of a value not being there, it needs to be encoded in a type-safe manner. This is where
Maybeenters the stage. A value of class
Maybecan either be
None. You can check which of the possibilities happened using pattern matching. Suppose you have a value
Maybe Int. You can use it like so:
getWithDefault, which are handy to replace the pattern match in most cases. Consult Explorer for more details.