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

Consider introducing holes and undefined #233

Open
razcore-rad opened this issue Nov 4, 2020 · 4 comments
Open

Consider introducing holes and undefined #233

razcore-rad opened this issue Nov 4, 2020 · 4 comments

Comments

@razcore-rad
Copy link

I remember when I first started working with Purescript and getting more serious about it that one of the most frustrating parts was that I couldn't get to test or get the compiler to help me figure things out as I first had to reason the entire implementation of the function.

I think the idea of typed holes and undefined should be introduced fairly early with examples. Using these features greatly increases both development and lowers the stress of not figuring out functions "from the first try".

@milesfrain
Copy link
Member

Maybe we could add an "extra credit" or "recommended reading" section to the end of some chapters (along with some related exercises).

I don't want to duplicate any typed holes or type-directed search documentation, but I could envision some exercises to accompany a link to that article.

This is my first exposure to undefined in PS. Can't think of any exercises for that at the moment.

What chapter do you think would be a good time to learn about these concepts?

@razcore-rad
Copy link
Author

razcore-rad commented Nov 5, 2020

A recommended reading section would be a great way to introduce some of these concepts as well.

undefined in PS is basically the same thing as undefined in Haskell, it's the "bottom" element.

See docs and the link to the issue included there for an example usage.

It's not so much that it should have an accompanying exercise, but rather it should be explained how it's useful to suppress complier errors. Perhaps undefined isn't as useful as typed holes, cause at the end of the day, as they discuss in the linked issue, undefined can be dangerous if you don't use it sparingly.


I'd see typed holes introduced either in the functions chapter (Ch3) or at the very least before the type class chapter (Ch6). Because Ch6 is where stuff gets exponentially difficult for a beginner to understand really new concepts that could get in the way when solving the exercises. And typed holes could be very handy with the more complex exercises.

@hdgarrood
Copy link

We actually deliberately omitted undefined from the core libraries, because it's a liability. I don't think we should encourage its use in the book for the same reason.

@razcore-rad
Copy link
Author

Yeah, I agree with that after some more thought. But typed holes should definitely be covered somewhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants