Skip to content

Added definition, exercise, and solution for Nat to Section 6.1#89

Merged
stefan-hoeck merged 3 commits into
stefan-hoeck:mainfrom
Liable5607:nat-exposition-in-section-6.1
Jul 22, 2025
Merged

Added definition, exercise, and solution for Nat to Section 6.1#89
stefan-hoeck merged 3 commits into
stefan-hoeck:mainfrom
Liable5607:nat-exposition-in-section-6.1

Conversation

@Liable5607

@Liable5607 Liable5607 commented Jul 22, 2025

Copy link
Copy Markdown
Contributor

I believe that the structure of Nat isn't explained. However it is used in Section 6.1 for the definition of the dependent type example Vect and for many of the exercises in Chapter 6. So I added it and a small exercise using it (calculating the length of a List).

I'm very sorry if it was explained in the tutorial and I missed it. I checked a few times to make sure and didn't see it but I could have missed it.

@Liable5607

Copy link
Copy Markdown
Contributor Author

I'm not sure what do about the build failure. It seems that it wasn't triggered by the code I wrote, e.g.

Error: While processing right hand side of ex4. Undefined name zipWith.

Error: While processing right hand side of replicate'. Undefined name replicate.

Perhaps I'm misintepreting the build messages though!

@stefan-hoeck

Copy link
Copy Markdown
Owner

By redefining Nat in this module, you create a lot of ambiguity that the compiler has no chance of resolving. All types mentioning Nat such as Vect but also (transitively) zipWith or replicate' can no longer be elaborated without ambiguity. The best solution would be to give Nat and its constructors a different name and inform readers about the correct names from the Prelude in the text.

@Liable5607

Copy link
Copy Markdown
Contributor Author

Thank you for explaining my mistake!

@stefan-hoeck stefan-hoeck merged commit 7e3f55d into stefan-hoeck:main Jul 22, 2025
2 checks passed
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.

2 participants