{"action":"created","issue":{"url":"https://api.github.com/repos/keean/zenscript/issues/11","repository_url":"https://api.github.com/repos/keean/zenscript","labels_url":"https://api.github.com/repos/keean/zenscript/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/keean/zenscript/issues/11/comments","events_url":"https://api.github.com/repos/keean/zenscript/issues/11/events","html_url":"https://github.com/keean/zenscript/issues/11","id":178798168,"number":11,"title":"Syntax summary","user":{"login":"shelby3","id":247731,"avatar_url":"https://avatars.githubusercontent.com/u/247731?v=3","gravatar_id":"","url":"https://api.github.com/users/shelby3","html_url":"https://github.com/shelby3","followers_url":"https://api.github.com/users/shelby3/followers","following_url":"https://api.github.com/users/shelby3/following{/other_user}","gists_url":"https://api.github.com/users/shelby3/gists{/gist_id}","starred_url":"https://api.github.com/users/shelby3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shelby3/subscriptions","organizations_url":"https://api.github.com/users/shelby3/orgs","repos_url":"https://api.github.com/users/shelby3/repos","events_url":"https://api.github.com/users/shelby3/events{/privacy}","received_events_url":"https://api.github.com/users/shelby3/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":752,"created_at":"2016-09-23T06:47:56Z","updated_at":"2016-10-26T10:29:31Z","closed_at":null,"body":"I will maintain in this OP a summary of current proposed syntax as I understand it to be. Note this is not authoritative, subject to change, and it may be inaccurate. Please make comments to discuss.\r\n\r\n`: Type` is always optional.\r\n\r\n1. [Sum, Recursive](http://stackoverflow.com/questions/5911267/what-are-sums-and-products-data-structures), [Record](https://github.com/keean/zenscript/issues/1#issuecomment-249349283), and [Product](https://github.com/keean/zenscript/issues/1#issuecomment-249348936) parametrized data type with optional Record member names and optional Record (e.g. `Cons`) and Product (e.g. `MetaData`) names:\r\n\r\n   `data List<T> = MetaData(Nil | Cons{head: T, tail: List<T>}, {meta: Meta<T>})`\r\n\r\n2. Typeclass interface and implementation:\r\n\r\n   ```\r\n   typeclass Name<A<B>, ...>   // or 'pluggable'?; optional <B> for higher-kinds¹?\r\n      method(B): A<B>           // TODO: add default arguments, named arguments?\r\n\r\n   List<A> implements Name\r\n      method(x) => ...\r\n   ```\r\n\r\n3. References:\r\n\r\n   ```\r\n   let x:Type = ...      // final assignment, not re-assignable (same as const in ES5/6)\r\n   var x:Type = ...      // (same as let in ES5/6)\r\n   ```\r\n\r\n4. Functions:\r\n\r\n   Type parameters [do not require declaration](https://github.com/keean/zenscript/issues/6#issuecomment-248742773) `<A,B>`.\r\n\r\n   ```\r\n   someCallback(x:Type y:Type(:Type) => x + y)     //            also  ():Type => x + y\r\n   var f = x:Type y:Type(:Type) => x + y           // not named, also  ():Type => x + y\r\n   f = x:Type y:Type(:Type) => x + y               // not named, also  ():Type => x + y\r\n   let f(x:Type, y:Type):Type => x + y             // named f,   also f():Type => x + y\r\n   let parametrized(x: A, y: B):A|B => x || y\r\n   let parametrizedWhere(x: A, y: B):A|B where ... => x || y\r\n   ```\r\n\r\n   Note that iterator types can be specified for the return value to return a lazy list as a generalized way of implementing generators. The optional `(:Type)` is necessited for [generator functions](https://github.com/keean/zenscript/issues/17). Note the `(x: Type y: Type): Type => x + y` form [is unavailable](https://github.com/keean/zenscript/issues/11#issuecomment-249770741).\r\n\r\n5. [Assignment-as-expression](https://github.com/keean/zenscript/issues/6#issuecomment-248744745):\r\n\r\n   ```\r\n   if ((x = 0))      // force extra parenthesis where expected type is Boolean\r\n   ```\r\n\r\n† Not yet included in the syntax, as would be a premature optimization. May or may not be added.\r\n¹ https://github.com/keean/zenscript/issues/10"},"comment":{"url":"https://api.github.com/repos/keean/zenscript/issues/comments/256309093","html_url":"https://github.com/keean/zenscript/issues/11#issuecomment-256309093","issue_url":"https://api.github.com/repos/keean/zenscript/issues/11","id":256309093,"user":{"login":"keean","id":508384,"avatar_url":"https://avatars.githubusercontent.com/u/508384?v=3","gravatar_id":"","url":"https://api.github.com/users/keean","html_url":"https://github.com/keean","followers_url":"https://api.github.com/users/keean/followers","following_url":"https://api.github.com/users/keean/following{/other_user}","gists_url":"https://api.github.com/users/keean/gists{/gist_id}","starred_url":"https://api.github.com/users/keean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keean/subscriptions","organizations_url":"https://api.github.com/users/keean/orgs","repos_url":"https://api.github.com/users/keean/repos","events_url":"https://api.github.com/users/keean/events{/privacy}","received_events_url":"https://api.github.com/users/keean/received_events","type":"User","site_admin":false},"created_at":"2016-10-26T10:29:30Z","updated_at":"2016-10-26T10:29:30Z","body":">There is no need to give the constructor another name, when it is the only item in the sum type (i.e. it is a unary sum type). So it is the only way to DNRY.\r\n\r\nThere is only the constructor name, functions as types do not have names. So you would write:\r\n```\r\ndata Thing<A, B, C> = Thing((x: C, y: C = x) => Type where A:..., B:...))\r\n```\r\nIf you want to have an additional name you can use a record:\r\n```\r\ndata Thing<A, B, C> = Thing(name : (x: C, y: C = x) => Type where A:..., B:...))\r\n```\r\nThe interesting thing here are the types:\r\n```\r\nThing<A, B> :  (x: C, y: C = x) => Type where A:..., B:...) => Thing<A, B, C>\r\nname : Thing<A, B, C> => (x: C, y: C = x) => Type where A:..., B:...)\r\n```\r\nNote that `name` as a record field name acts as a de-constructor of the object to access the field. This means the following:\r\n```\r\nname(Thing(...))\r\n```\r\nIs the identity function, but only for objects with the type ` (x: C, y: C = x) => Type where A:..., B:...`\r\n"}}
{"actor":{"display_login":"keean"}}