Elm Exactly
Results / elm-core /

StringConsDynamicTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`String.cons` rebuilds a string from the `Char` and rest that `String.uncons` split it into.

`String.uncons "ab"` gives `Just ( 'a', "b" )`, and `String.cons 'a' "b"` is
`"ab"` again. The `Char` passed to `String.cons` is computed at run time, not
written as a literal.

Results

elm-0.19.1

passran in 39 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
out: "ab"

elm-0.19.2

passran in 36 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
out: "ab"

elm-0.19.3

passran in 35 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
out: "ab"

lamdera-1.5.0

passran in 38 ms
Output
out: "ab"

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module StringConsDynamicTest exposing (main)
{-| `String.cons` rebuilds a string from the `Char` and rest that `String.uncons` split it into.
`String.uncons "ab"` gives `Just ( 'a', "b" )`, and `String.cons 'a' "b"` is
`"ab"` again. The `Char` passed to `String.cons` is computed at run time, not
written as a literal.
-}
-- CHECK: out: "ab"
import Html exposing (text)
main =
let
src =
"ab"
rebuilt =
case String.uncons src of
Just ( c, rest ) ->
String.cons c rest
Nothing ->
""
_ =
Debug.log "out" rebuilt
in
text "done"