Elm Exactly
Results / elm-core /

CharToCodeFromStringTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`Char.toCode` of a character obtained at run time from `String.uncons`, rather
than written as a literal, gives that character's code point.

The first character of `"type"` is `'t'`, whose code is 116.

Results

elm-0.19.1

passran in 91 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
code: 116

elm-0.19.2

passran in 62 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
code: 116

elm-0.19.3

passran in 87 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
code: 116

lamdera-1.5.0

passran in 73 ms
Output
code: 116

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm-core/CharToCodeFromStringTest] in its title.

Source

The -- CHECK: lines give the expected output.

module CharToCodeFromStringTest exposing (main)
{-| `Char.toCode` of a character obtained at run time from `String.uncons`, rather
than written as a literal, gives that character's code point.
The first character of `"type"` is `'t'`, whose code is 116.
-}
-- CHECK: code: 116
import Char
import Html exposing (text)
main =
let
src =
"type"
code =
case String.uncons src of
Just ( c, _ ) ->
Char.toCode c
Nothing ->
-1
_ =
Debug.log "code" code
in
text "done"