Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

format

format is a module that provides functions for converting other types to strings.

Functions


integer: integer -> string

Returns the passed integer as a string.

Example

<span class='hljs-keyword'>do</span> <span class='hljs-title class_'>format</span><span class='hljs-punctuation'>::</span><span class='hljs-title function_'>integer</span> <span class='hljs-variable constant_'>5</span>
    <span class='hljs-operator'>|&gt;</span> <span class='hljs-title class_'>string</span><span class='hljs-punctuation'>::</span><span class='hljs-title function_'>print</span>
<span class='hljs-comment'>(* prints "5" *)</span>

real: real -> string

Returns the passed real as a string.

Example

<span class='hljs-keyword'>do</span> <span class='hljs-title class_'>format</span><span class='hljs-punctuation'>::</span><span class='hljs-title function_'>real</span> <span class='hljs-variable constant_'>5.4</span>
    <span class='hljs-operator'>|&gt;</span> <span class='hljs-title class_'>string</span><span class='hljs-punctuation'>::</span><span class='hljs-title function_'>print</span>
<span class='hljs-comment'>(* prints "5.4" *)</span>

boolean: boolean -> string

Returns the passed boolean as a string.

Example

<span class='hljs-keyword'>do</span> <span class='hljs-title class_'>format</span><span class='hljs-punctuation'>::</span><span class='hljs-title function_'>boolean</span> <span class='hljs-built_in'>true</span>
    <span class='hljs-operator'>|&gt;</span> <span class='hljs-title class_'>string</span><span class='hljs-punctuation'>::</span><span class='hljs-title function_'>print</span>
<span class='hljs-comment'>(* prints "true" *)</span>

unit: unit -> string

Returns unit as a string.

Example

<span class='hljs-keyword'>do</span> <span class='hljs-title class_'>format</span><span class='hljs-punctuation'>::</span><span class='hljs-title function_'>unit</span> <span class='hljs-punctuation'>(</span><span class='hljs-punctuation'>)</span>
    <span class='hljs-operator'>|&gt;</span> <span class='hljs-title class_'>string</span><span class='hljs-punctuation'>::</span><span class='hljs-title function_'>print</span>
<span class='hljs-comment'>(* prints "()" *)</span>