Types in ML

This is a simplification and unification of the basic concepts of ML types.

General Tips

 * At first, assume all things are of an arbitrary type, val (short for "value".)
 * ML is heavily typed. Remember this. If types conflict, your code won't work.

Numbers
Ints


 * Lonely souls without decimals.


 * 1)   - gives you output of
 * 2)   - gives you output of   and saves the number for later use by functions, other values, etc.

​Reals

 * Numbers with decimals.


 * To create a real:


 * 1) 5.0;
 * 2) val five = 5.0;

Characters

 * Known and referenced by their street name, "char"s, characters are single letters or symbols.


 * To make a char:


 * 1)  gives you
 * 2)   gives you   and saves the value for future use
 * Some chars must be escaped before they can function like a normal character within double quotations.

Strings

 * A string is a sequence of characters. In Java, strings of characters are represented as Objects. However, since there are no objects in ML, strings of characters are represented instead as their own built-in datatype. This is a very important distinction: although, as you can see in the table below, some of the methods dealing with strings begin in much the same way as a Java object function


 * To make a string:


 * 1) "Strings!";
 * 2) val exclaimation = "Strings!";

Converting Between Two Basic Types
Where n is some previously defined value or a number value you type directly into the line.

Creating Your Own Datatypes
Here's the formula for creating your own, unique, one of kind, and IMMUTABLE datatypes:

datatype identifier1 = identifier2 of type | identifier2 of type ....;

Ex: