elm / compiler

Compiler for Elm, a functional language for reliable webapps.
https://elm-lang.org/
BSD 3-Clause "New" or "Revised" License
7.55k stars 662 forks source link

Built-in Ports aren't TypeChecked #475

Closed maxsnew closed 9 years ago

maxsnew commented 10 years ago

The built-in ports are not typechecked. This breaks stuff at runtime:

port stdout : Int
port stdout = 3

main = asText "sup"

crashes with TypeError: ports.stdout.subscribe is not a function since it tries to subscribe to something that's not a Signal.

evancz commented 10 years ago

Do you think there should be an ad-hoc check for the built-in ports? Is there a general way to address this problem? Anyone who writes a port handler may create this issue.

maxsnew commented 10 years ago

The idea I had was to treat built-in ports as a generalization of main. I.e., if I write port stdout : Int I should get an error that says something like "stdout is a reserved port and is expected to have type Signal String"

evancz commented 9 years ago

I am trying to clean up the issues on these repos. My goal is for issues on repos like elm-compiler and elm-repl are about specific bugs. It is not working to manage proposals and stuff that requires changes to the language here, so I am devising a way of keeping track of all this stuff in a transparent way.

The idea is that it doesn't super matter where the proposal is opened, but we should collect related ideas in certain places so we can look at them as a collection of issues and find a coherent solution that addresses them all as much as possible. So I'm gonna close this and reference https://github.com/elm-lang/elm-plans/issues/17 which is collecting a bunch of port problems.

If there is more to say about this idea, we should continue on this thread. The fact that is closed is more about decluttering stuff!