Elm Exactly
Results / elm /

PortProblemCharPayloadTest

Tags:elm19-compile-errorelm-spec

Checks, in A Standard Definition of Elm?:rule sm-topdec-portout

Not translated into Lean for the mechanisation of the book: see why.

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
A port whose payload type is `Char` is rejected with a PORT ERROR naming the port and the `Char` type.

Ports can carry `Int`, `Float`, `Bool`, `String`, `Json.Encode.Value`, `()`, and
`List`, `Maybe`, `Array`, tuples and records built from those, but not `Char`. Here the
outgoing port `charOut : Char -> Cmd msg` is declared.

Results

elm-0.19.1

pass
Output
Compiling ...-- PORT ERROR ------------------------------- src/PortProblemCharPayloadTest.elm

The `charOut` port is trying to transmit a `Char` value:

20| port charOut : Char -> Cmd msg
         ^^^^^^^
I cannot handle that. The types that CAN flow in and out of Elm include:

    Ints, Floats, Bools, Strings, Maybes, Lists, Arrays, tuples, records, and
    JSON values.

Since JSON values can flow through, you can use JSON encoders and decoders to
allow other types through as well. More advanced users often just do everything
with encoders and decoders for more control and better errors.

Hint: Ports are not a traditional FFI, so if you have tons of annoying ports,
definitely read <https://elm-lang.org/0.19.1/ports> to learn how they are meant
to work. They require a different mindset!

Detected problems in 1 module.

elm-0.19.2

pass
Output
Compiling ...-- PORT ERROR ------------------------------- src/PortProblemCharPayloadTest.elm

The `charOut` port is trying to transmit a `Char` value:

20| port charOut : Char -> Cmd msg
         ^^^^^^^
I cannot handle that. The types that CAN flow in and out of Elm include:

    Ints, Floats, Bools, Strings, Maybes, Lists, Arrays, tuples, records, and
    JSON values.

Since JSON values can flow through, you can use JSON encoders and decoders to
allow other types through as well. More advanced users often just do everything
with encoders and decoders for more control and better errors.

Hint: Ports are not a traditional FFI, so if you have tons of annoying ports,
definitely read <https://elm-lang.org/0.19.2/ports> to learn how they are meant
to work. They require a different mindset!

Detected problems in 1 module.

elm-0.19.3

pass
Output
Compiling ...-- PORT ERROR ------------------------------- src/PortProblemCharPayloadTest.elm

The `charOut` port is trying to transmit a `Char` value:

20| port charOut : Char -> Cmd msg
         ^^^^^^^
I cannot handle that. The types that CAN flow in and out of Elm include:

    Ints, Floats, Bools, Strings, Maybes, Lists, Arrays, tuples, records, and
    JSON values.

Since JSON values can flow through, you can use JSON encoders and decoders to
allow other types through as well. More advanced users often just do everything
with encoders and decoders for more control and better errors.

Hint: Ports are not a traditional FFI, so if you have tons of annoying ports,
definitely read <https://elm-lang.org/0.19.3/ports> to learn how they are meant
to work. They require a different mindset!

Detected problems in 1 module.

lamdera-1.5.0

pass
Output
Detected problems in 1 module.
-- PORT ERROR ------------------------------- src/PortProblemCharPayloadTest.elm

The `charOut` port is trying to transmit a `Char` value:

20| port charOut : Char -> Cmd msg
         ^^^^^^^
I cannot handle that. The types that CAN flow in and out of Elm include:

    Ints, Floats, Bools, Strings, Maybes, Lists, Arrays, tuples, records, and
    JSON values.

Since JSON values can flow through, you can use JSON encoders and decoders to
allow other types through as well. More advanced users often just do everything
with encoders and decoders for more control and better errors.

Hint: Ports are not a traditional FFI, so if you have tons of annoying ports,
definitely read <https://elm-lang.org/0.19.3/ports> to learn how they are meant
to work. They require a different mindset!

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

port module PortProblemCharPayloadTest exposing (..)
{-| A port whose payload type is `Char` is rejected with a PORT ERROR naming the port and the `Char` type.
Ports can carry `Int`, `Float`, `Bool`, `String`, `Json.Encode.Value`, `()`, and
`List`, `Maybe`, `Array`, tuples and records built from those, but not `Char`. Here the
outgoing port `charOut : Char -> Cmd msg` is declared.
-}
-- TAGS: elm19-compile-error
-- TAGS: elm-spec, sm-topdec-portout
-- COMPILE-ERROR: PORT ERROR
-- CHECK: -- PORT ERROR -
-- CHECK: The `charOut` port is trying to transmit a `Char` value:
import Platform
port charOut : Char -> Cmd msg

Lean translation

No reduced program for Lean's evaluator: the test expects a compile error, so it has no meaning to evaluate. Lean has the program as written, in source syntax, and proves what the static semantics says of it (below). See the Lean mechanisation for which tests are in Lean, and why.

Static semantics: Lean proves that the program as written is not legal, so a compiler must reject it (refuse_elm_PortProblemCharPayloadTest, in StandardElmMech/Certs/). Some type expression of the program (an alias, a constructor's argument, an annotation, a port) elaborates in no derivation (Stat.not_legal_of_typesFailB). It holds for every derivation, with no hypothesis about principality.