Add 'Arbitrary' instance for records#82
Merged
Merged
Conversation
34e8522 to
85430e7
Compare
Member
|
Very cool 👍 |
paf31
reviewed
Sep 2, 2017
| arbitraryRecord _ = do | ||
| value <- arbitrary | ||
| previous <- arbitraryRecord (RLProxy :: RLProxy listRest) | ||
| pure $ insert (SProxy :: SProxy key) value previous |
Contributor
There was a problem hiding this comment.
This makes me think we should add ST support to purescript-records, so we can build the record in place.
Contributor
There was a problem hiding this comment.
That said, I'm not sure what type we'd give to in-place insertion of a new field :/
Contributor
|
Thanks, looks great! I'll think a bit about the |
Contributor
|
Here's something I put together for building records efficiently in place: http://try.purescript.org/?backend=core&gist=27a137278caa203b3ebbd42f7386a0db I might add this to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds an
Arbitraryinstance for general records:Example
Note: This is the first time that I'm using the new (and awesome) typelevel-programming features of PureScript, so I'm not sure if I'm doing this correctly 😄