@@ -1240,7 +1240,7 @@ toDeclarationsReport source decl =
1240 toSpaceReport source space row col
1240 toSpaceReport source space row col
1242 Port port_ row col ->
1242 Port port_ row col ->
1243− error "TODO Port" port_ row col
1243+ toPortReport source port_ row col
1245 DeclType declType row col ->
1245 DeclType declType row col ->
1246 toDeclTypeReport source declType row col
1246 toDeclTypeReport source declType row col
@@ -1256,6 +1256,164 @@ toDeclarationsReport source decl =
1262+toPortReport :: Code.Source -> Port -> Row -> Col -> Report.Report
1263+toPortReport source port_ startRow startCol =
1265+ PortSpace space row col ->
1266+ toSpaceReport source space row col
1268+ PortName row col ->
1269+ case Code.whatIsNext source row col of
1270+ Code.Keyword keyword ->
1272+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1273+ region = toKeywordRegion row col keyword
1275+ Report.Report "RESERVED WORD" region [] $
1276+ Code.toSnippet source surroundings (Just region)
1279+ "I cannot handle ports with names like this:"
1282+ "You are trying to make a port named `" ++ keyword
1283+ ++ "` but that is a reserved word. Try using some other name?"
1288+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1289+ region = toRegion row col
1291+ Report.Report "PORT PROBLEM" region [] $
1292+ Code.toSnippet source surroundings (Just region)
1295+ "I just saw the start of a `port` declaration, but then I got stuck here:"
1299+ ["I","was","expecting","to","see","a","name","like"
1300+ ,D.dullyellow "send","or",D.dullyellow "receive","next."
1301+ ,"Something","that","starts","with","a","lower-case","letter."
1307+ PortColon row col ->
1309+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1310+ region = toRegion row col
1312+ Report.Report "PORT PROBLEM" region [] $
1313+ Code.toSnippet source surroundings (Just region)
1316+ "I just saw the start of a `port` declaration, but then I got stuck here:"
1320+ "I was expecting to see a colon next. And then a type that tells me\
1321+ \ what type of values are going to flow through."
1326+ PortType tipe row col ->
1327+ toTypeReport source tipe row col
1329+ PortIndentName row col ->
1331+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1332+ region = toRegion row col
1334+ Report.Report "UNFINISHED PORT" region [] $
1335+ Code.toSnippet source surroundings (Just region)
1338+ "I just saw the start of a `port` declaration, but then I got stuck here:"
1342+ ["I","was","expecting","to","see","a","name","like"
1343+ ,D.dullyellow "send","or",D.dullyellow "receive","next."
1344+ ,"Something","that","starts","with","a","lower-case","letter."
1350+ PortIndentColon row col ->
1352+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1353+ region = toRegion row col
1355+ Report.Report "UNFINISHED PORT" region [] $
1356+ Code.toSnippet source surroundings (Just region)
1359+ "I just saw the start of a `port` declaration, but then I got stuck here:"
1363+ "I was expecting to see a colon next. And then a type that tells me\
1364+ \ what type of values are going to flow through."
1369+ PortIndentType row col ->
1371+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1372+ region = toRegion row col
1374+ Report.Report "UNFINISHED PORT" region [] $
1375+ Code.toSnippet source surroundings (Just region)
1378+ "I just saw the start of a `port` declaration, but then I got stuck here:"
1382+ "I was expecting to see a type next. Here are examples of outgoing and\
1383+ \ incoming ports for reference:"
1385+ [ D.fillSep [D.cyan "port","send",":","String -> Cmd msg"]
1386+ , D.fillSep [D.cyan "port","receive",":","(String -> msg) -> Sub msg"]
1389+ "The first line defines a `send` port so you can send strings out to JavaScript.\
1390+ \ Maybe you send them on a WebSocket or put them into IndexedDB. The second line\
1391+ \ defines a `receive` port so you can receive strings from JavaScript. Maybe you\
1392+ \ get receive messages when new WebSocket messages come in or when an entry in\
1393+ \ IndexedDB changes for some external reason."
1402+ "Here are some example `port` declarations for reference:"
1404+ [ D.fillSep [D.cyan "port","send",":","String -> Cmd msg"]
1405+ , D.fillSep [D.cyan "port","receive",":","(String -> msg) -> Sub msg"]
1408+ "The first line defines a `send` port so you can send strings out to JavaScript.\
1409+ \ Maybe you send them on a WebSocket or put them into IndexedDB. The second line\
1410+ \ defines a `receive` port so you can receive strings from JavaScript. Maybe you\
1411+ \ get receive messages when new WebSocket messages come in or when the IndexedDB\
1412+ \ is changed for some external reason."
1259-- DECL TYPE
1417-- DECL TYPE