Rule 59sm-topdec-portin
Top-level Declarations
(59)
Comments
The variable occurs in both places, so port recv : (Int -> a) -> Sub b does not elaborate. As for an outgoing port, port recv : (Json.Decode.Value -> msg) -> Sub msg elaborates, and port recv : (Result String Int -> msg) -> Sub msg does not.
TeX source
\defnrule[r:sm-topdec-portin]
{U \text{ is new for } \ty \text{ in } C \premsep \jdg{C + U}{\ty}{\tau} \\ \tau = (\tau' \rightarrow \alpha) \rightarrow \alpha\,\sbtSub \premsep \Port(\tau')}
{\jdg{C}{\kw{port}\ \var\ \kw{:}\ \ty}{\{\var \mapsto (\Clos_C \tau, \isv)\}\ \text{in}\ \Env,\ \{\var \mapsto (\smdirin, \tau')\}}}Tests (10)
- elm / CovPortIncomingArrayTestA port module declaring an incoming port whose values are `Array Int`.
- elm / CovPortIncomingJSONValueTestA port module declaring an incoming port whose values are `Json.Encode.Value`.
- elm / CovPortIncomingTripleTestA port module declaring an incoming port whose values are an `( Int, String, Bool )` triple.
- elm / CovPortIncomingUnitTestA port module declaring an incoming port whose values are `()`.
- elm / PortEchoTestAn `Int` sent out through an outgoing port comes back unchanged through an incoming port.
- elm / PortEncodingDecodeFloatTestA port module declaring an incoming port that carries `Float` compiles and runs.
- elm / PortEncodingDecodeListIntTestA port module declaring an incoming port that carries `List Int` compiles and runs.
- elm / PortEncodingDecodeMaybeIntTestA port module declaring an incoming port that carries `Maybe Int` compiles and runs.
- elm / PortEncodingDecodeTuple2TestA port module declaring an incoming port that carries `( Int, String )` compiles and runs.
- elm / StandardA92BytesPortDeclarationTestA port module may declare an outgoing and an incoming port whose payload type is `Bytes`.
Discussions
Discuss this rule·Search the discussions on GitHub
Discussions are on GitHub; one about this rule has [r:sm-topdec-portin] 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.