{"action":"created","issue":{"url":"https://api.github.com/repos/gkz/LiveScript/issues/999","repository_url":"https://api.github.com/repos/gkz/LiveScript","labels_url":"https://api.github.com/repos/gkz/LiveScript/issues/999/labels{/name}","comments_url":"https://api.github.com/repos/gkz/LiveScript/issues/999/comments","events_url":"https://api.github.com/repos/gkz/LiveScript/issues/999/events","html_url":"https://github.com/gkz/LiveScript/issues/999","id":288335308,"number":999,"title":"Typings bikeshedding","user":{"login":"vendethiel","id":199499,"avatar_url":"https://avatars3.githubusercontent.com/u/199499?v=4","gravatar_id":"","url":"https://api.github.com/users/vendethiel","html_url":"https://github.com/vendethiel","followers_url":"https://api.github.com/users/vendethiel/followers","following_url":"https://api.github.com/users/vendethiel/following{/other_user}","gists_url":"https://api.github.com/users/vendethiel/gists{/gist_id}","starred_url":"https://api.github.com/users/vendethiel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vendethiel/subscriptions","organizations_url":"https://api.github.com/users/vendethiel/orgs","repos_url":"https://api.github.com/users/vendethiel/repos","events_url":"https://api.github.com/users/vendethiel/events{/privacy}","received_events_url":"https://api.github.com/users/vendethiel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":20,"created_at":"2018-01-13T15:02:08Z","updated_at":"2018-02-06T08:58:48Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Some time ago (#803) I had started working on a PR to add type hints to the language.\r\n\r\nThat's still something I miss to this day, so I want to bring it back up.\r\nThere were a lot of discussions, so I think we should try to discuss it beforehand.\r\n\r\n# Typing symbol\r\n\r\nI suggested the symbol `@:` to add a type annotation. Someone suggested `^`. @gkz suggested `::`.\r\n\r\nThe reason I want(ed) not to use `::` is because it's rewritten to `ID:prototype` when it's parsed directly, at which point we have no info on whether it's going to be part of a signature of just a Parens (we only tag `()` as `PARAM(` and `PARAM)` after seeing `->`).\r\nWe'd need to go through the tokens to mark `ID:prototype` as `ASCR` (or whatever else). We'd also need to be careful not to tag in \"defaults\" – that is, `(x = -> ::) ->`, `(x ? ::) ->`, `(x and ::) ->`, etc...\r\n\r\n# where to allow typings\r\n\r\nI'd suggest we only allow type annotations in:\r\n - function declarations (`function` and `->`/`<-`/...)\r\n - `var`\r\n - `let`\r\n\r\n# generics\r\n\r\nI have one suggestion: `[T](xs @: Array[T]) ->`. The reason I suggest `[]` rather than `<>` is mostly for parse-ability (and because I'm used to Scala...). Tagging `[]() ->` is easier than the ambiguities with `<>`, we just have to look for a `]` when re-tagging a `(` as a `PARAM(`, and cycle back to `[` from there (since an array is never callable anyway).\r\n(since `[T]() ->` and `xs[T]() ->` make no sense anyway)\r\n\r\nParsing the `@: Array[T]` part is harder, but still simpler than `@: Array<T>`, where the `>` would be parsed as a BIOP because it's directly followed by a `)`...\r\n\r\n--------------\r\n\r\n@rhendric I'm interested in your PoV, because it's a sensible topic, considering all the ambiguities to keep in mind :-)."},"comment":{"url":"https://api.github.com/repos/gkz/LiveScript/issues/comments/363354550","html_url":"https://github.com/gkz/LiveScript/issues/999#issuecomment-363354550","issue_url":"https://api.github.com/repos/gkz/LiveScript/issues/999","id":363354550,"user":{"login":"vendethiel","id":199499,"avatar_url":"https://avatars3.githubusercontent.com/u/199499?v=4","gravatar_id":"","url":"https://api.github.com/users/vendethiel","html_url":"https://github.com/vendethiel","followers_url":"https://api.github.com/users/vendethiel/followers","following_url":"https://api.github.com/users/vendethiel/following{/other_user}","gists_url":"https://api.github.com/users/vendethiel/gists{/gist_id}","starred_url":"https://api.github.com/users/vendethiel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vendethiel/subscriptions","organizations_url":"https://api.github.com/users/vendethiel/orgs","repos_url":"https://api.github.com/users/vendethiel/repos","events_url":"https://api.github.com/users/vendethiel/events{/privacy}","received_events_url":"https://api.github.com/users/vendethiel/received_events","type":"User","site_admin":false},"created_at":"2018-02-06T08:58:48Z","updated_at":"2018-02-06T08:58:48Z","author_association":"CONTRIBUTOR","body":"> I'm not at all sure this is a good idea, but continuing in the vein of my proof-of-concept, the below comes remarkably close to compiling:\r\n\r\nIf anything, I think I'd prefer it if we had a `Type`-like class that'd be basically a pattern matcher where your AST hack were extracted to, that'd recursively rewrite calls and al to types."}}
{"actor":{"display_login":"vendethiel"}}