Skip to content

exercise with Distance, foldMap and Maybe for Section 4.3 #86

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Liable5607
Copy link
Contributor

When I was trying to get a handle on Monoids, I spent a lot of time playing with the Distance example. Personally I found that really helpful. One of those practice problems (calculating the Euclidean distance) also involved foldMap and Maybe so I thought it might make a nice exercise.

@Liable5607 Liable5607 changed the title exercise with Distance foldMap and Maybe for Section 4.3 exercise with Distance, foldMap and Maybe for Section 4.3 Jul 12, 2025
@stefan-hoeck
Copy link
Owner

While I like the example for its practical relevance, I don't think that the square of a Distance is still a Distance. At least in physics - where we are strict about this kind of thing - it is not. So, semantically, square and sqrt are not sound. In addition, sqrt is a partial function.

I therefore wonder, if we'd need not explain more about this in order to include it here.

@Liable5607
Copy link
Contributor Author

Thanks, you're right. I'll try to think of a more sound exercise with these Idris concepts.

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