Add section on record puns and type synonyms for records#330
Add section on record puns and type synonyms for records#330milesfrain wants to merge 4 commits intopurescript:masterfrom
Conversation
| Type synonyms for record types are created with the `type` keyword: | ||
|
|
||
| ```purs | ||
| type Point = | ||
| { x :: Number | ||
| , y :: Number | ||
| } | ||
| ``` | ||
|
|
There was a problem hiding this comment.
This is covered later in this documentation, but I suppose it's information worth stating right away. Why not stick with the existing example in this section, though?
It is common to use type synonyms to for records via the
typekeyword:type Author = { name :: String, interests :: Array String } author :: Author author = { name: "Phil", interests: ["Functional Programming", "JavaScript"] }
There was a problem hiding this comment.
I wanted to define Point, since it's used in later examples.
| _ { fieldName = newValue } | ||
| ``` | ||
|
|
||
| ## Record Puns |
There was a problem hiding this comment.
I like this section, but there's some overlap with the language syntax documentation:
https://github.com/purescript/documentation/blob/837ec4ff3a956cdeda31997bf5f697ee738295b6/language/Syntax.md#additional-forms-with-records
I think we should merge that content into this file and then update the language syntax file to link here. It makes more sense for that content to be in this section and just a link be in that file.
There was a problem hiding this comment.
I think that file has good content and it could be used to inform what you've written here.
There was a problem hiding this comment.
there's some overlap with the language syntax
I'm not seeing any "Record Pun" examples in Syntax.md, but I agree that there are duplicated themes across Records.md, Syntax,md, and Pattern-Matching.md.
Whether this should be reorganized seems like a bigger discussion. Maybe something to tackle as part of #344
So for now, I'm thinking we should hold-off on making changes across multiple files.
|
As a side note, I think the
-- these types are equivalent
type Language = { language :: String }
type Language' = Record ( language :: String )A Because type LanguageRow = ( language :: String ) -- has kind # Type
-- these are equivalent
type Language = Record LanguageRow
type Language' = { | LanguageRow } |
|
Applied all suggestions except for moving content from |
|
This PR hasn't been merged because this is likely useful, but has a few additions that are undesirable / repetitive |
No description provided.