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

Ch 7 - Review tree show instance and solutions #232

Closed
razcore-rad opened this issue Nov 4, 2020 · 3 comments · Fixed by #235
Closed

Ch 7 - Review tree show instance and solutions #232

razcore-rad opened this issue Nov 4, 2020 · 3 comments · Fixed by #235

Comments

@razcore-rad
Copy link

The exercise is:

  1. (Easy) Write Eq and Show instances for the following binary tree data structure:
data Tree a = Leaf | Branch (Tree a) a (Tree a)

The solution is implemented using generics. By this point derive isn't discussed not to mention generics. There's discussion to include at least derive in Ch6 #149, but not generics. Thus the solutions should be "manual" solutions.

Also the implementation of the show instance is pretty subjective so the reader needs a bit more details on how the solution should look like otherwise he's forced to look at the test suite. Including an output example would do the trick, something like: (Branch (Branch Leaf 5 Leaf) 4 (Branch Leaf 6 Leaf)) or something like that maybe.

@milesfrain
Copy link
Member

I'll make a PR to fix this.

I'm thinking of including a hint that this can be done with generic (along with a link to the guide) to make this optionally more interesting, since this exercise is really just a repeat of content from the previous chapter. The generic solution will be shown commented-out next to the hand-written solution.

I agree about the ambiguity of show output, but I think this is straightforward to correct by just looking at the test output in the terminal (so no need to dig through the test suite). A downside of making a note is that it's more material that needs to be kept in sync.

@razcore-rad
Copy link
Author

Yeah I see what you mean, but the problem is that if the exercise is ambiguous to begin with and you first have to "fail" to get it right, as a beginner that's not a great experience. I think this should be solved with a hint of the expected output still.

Say you correctly implement the show instance, but it isn't acceptable because it doesn't match perfectly with the test suite. As a beginner you really start wondering where you went wrong instead and doubt yourself. Maybe it's just me, but I start questioning if I screwed up instead of realizing "oh yea, it's cause the test is just for an arbitrary implementation".

I guess what I'm saying is the first thing you notice is the failed status, not why the failure happened and that's just not good beginner experience.

@milesfrain
Copy link
Member

@razcore-art, let me know what you think of #235

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

Successfully merging a pull request may close this issue.

2 participants