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.
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.
'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:
["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.