Elm Exactly

Basis entryChar.fromCode

A value of Char. Its type is in Section C.4 Further Data Types.

Static basis

fromCode ↦ (Int→Char,v)\begin{array}{|rcl|}\hline \href{/standard/basis/Char/fromCode}{\kw{fromCode}} {\ }& \mapsto {\ }& (\tInt \rightarrow \tChar, \isv)\\\hline\end{array}
Figure 41: Static Interfaces of Maybe, Result, String, Char, Array and Bytes

Dynamic basis

var or con ↦ varitytoCode, fromCode ↦ basic value1\begin{array}{|rclc|}\hline \var\ \text{or}\ \con {\ }& \mapsto {\ }& v {\qquad}& \arity\\\hline \href{/standard/basis/Char/toCode}{\kw{toCode}},\ \href{/standard/basis/Char/fromCode}{\kw{fromCode}} {\ }& \mapsto {\ }& \text{basic value} {\qquad}& 1\\\hline\end{array}
Figure 47: Dynamic VE\VE of the Other Modules of ME0\ME_0

Its APPLY

APPLY(Char.fromCode,n) = {ch}if n is a Unicode scalar value  and code(ch)=n = {other(n)}otherwise\begin{array}{rcll} \APPLY(\kw{Char.fromCode},n) {\ }& = {\ }& \{\dbch\} {\quad}& \text{if}\ n\ \text{is a Unicode scalar value}\\ {\ }& {\ }& {\quad}& \text{and}\ \dbcode(\dbch)=n\\ {\ }& = {\ }& \{\mathit{other}(n)\} {\quad}& \text{otherwise}\end{array}
Figure 53: APPLY\APPLY on Conversions
Read it in its chapter·Permanent address: /standard/basis/Char/fromCode

Tests (3)

  • elm-core / CharAstralCodeTest
    `Char.fromCode` and `Char.toCode` round-trip Unicode code points, including astral ones (above 0xFFFF) and the largest, 0x10FFFF.
  • elm-core / CharFromCodeTest
    `Char.fromCode` turns the code points 65, 97 and 48 into `'A'`, `'a'` and `'0'`.
  • elm-core / CoreIssue1150CharToCodeLoneSurrogateTest
    `Char.toCode` returns NaN, typed as `Int`, for a lone surrogate.

Discussions

Discuss this basis entry·Search the discussions on GitHub

Discussions are on GitHub; one about this basis entry has [b:Char.fromCode] in its title.

A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.