Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'NFDataX.ensureSpine` #803

Merged
merged 1 commit into from
Oct 1, 2019
Merged

Add 'NFDataX.ensureSpine` #803

merged 1 commit into from
Oct 1, 2019

Conversation

martijnbastiaan
Copy link
Member

@martijnbastiaan martijnbastiaan commented Sep 17, 2019

Wanted: a new name for spinify! Feel free to comment below ensureSpine it is!


Consider the following example:

>>> x = undefined :: Vec 3 Char
>>> y = map (\_ -> 3) x
>>> y
<error>

Currently, this would fail, as map tries to pattern match on the constructor of vector Cons. This constructor doesn't exist however, and resolves to undefined. In this specific instance we could use lazyV to create the "spine" of Vec for us:

>>> z = map (\_ -> 3) (lazyV x)
>>> z
<3,3,3>

spinify generalizes this behavior to all data structures having an instance for NFDataX.


Fixes #748

@christiaanb
Copy link
Member

christiaanb commented Sep 17, 2019

Some other suggestions (I "hate" the name spinify):

  • defineSpine
  • forceSpice
  • deepseqSpine
  • lazyLeaf
  • @leonschoorl says: lazy (generalization of lazyV) <- but it's not lazy for sum-types

@gergoerdi
Copy link
Contributor

ensureSpine? ensureShape?

@basile-henry
Copy link
Collaborator

deepDefine

@rowanG077
Copy link
Member

I like ensureSpine the best.

@masterdezign
Copy link

proto?

@martijnbastiaan
Copy link
Member Author

Thanks everyone :). Seems like ensureSpine is the most popular. Leave a comment if you strongly disagree! If no one does, I'll change the name and merge this PR next week.

@martijnbastiaan martijnbastiaan force-pushed the feature-spinify branch 3 times, most recently from 1e729e0 to 804fb9f Compare September 30, 2019 14:57
@martijnbastiaan martijnbastiaan changed the title Add 'NFDataX.spinify` Add 'NFDataX.ensureSpine` Sep 30, 2019
@martijnbastiaan
Copy link
Member Author

@christiaanb This is ready for review. I don't believe it's possible to deprecate "custom" implementations of type class functions (in this case deepErrorX), is it?

Copy link
Member

@christiaanb christiaanb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the method implementations of deepErrorX; it probably saves on compile time, and maybe even run-time efficiency during simulation.

@martijnbastiaan
Copy link
Member Author

My original idea was to deprecate "custom" implementations of deepErrorX, as deepErrorX ~ ensureSpine . errorX. As we discussed online, that's not really possible, so I'll revert the deletion of custom implementations.

@martijnbastiaan martijnbastiaan force-pushed the feature-spinify branch 2 times, most recently from 6a4f27f to 54d7e99 Compare October 1, 2019 09:17
@martijnbastiaan
Copy link
Member Author

@christiaanb I've readded withFrozenStack too. I'll merge it if it passed the tests!

@christiaanb christiaanb merged commit 2c46c6c into master Oct 1, 2019
@christiaanb christiaanb deleted the feature-spinify branch October 1, 2019 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generalize Undefined to work with non-errors too
6 participants