Skip to content

Typeclasses#46

Open
chenson2018 wants to merge 21 commits into
mainfrom
typeclasses
Open

Typeclasses#46
chenson2018 wants to merge 21 commits into
mainfrom
typeclasses

Conversation

@chenson2018

Copy link
Copy Markdown
Collaborator

This is a first pass at a chapter on typeclasses. This is still in a rough draft state, but I'm trying to follow Benjamin's request to PR things earlier if possible. There are a couple of organizational questions in my mind:

  • In LF/Maps.lean I have already ported a version of that chapter, but using typeclasses. I left a placeholder here where it seems natural to fit in, but I wasn't sure if this was too long.
  • The reflection material collects the examples from Logic and IndProp. I left things unfinished towards the end where I wasn't sure what was important to translate.

Comment thread LF/Typeclasses.lean Outdated
Comment thread LF/Typeclasses.lean Outdated
Comment on lines +286 to +287
Maps could go here as an example to reinforce this? Or maybe that's too long of an aside? The code
exists (with limited prose) in `Maps.lean` already. --CGH

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think the idea is to fold Maps into this chapter entirely, using it as an extended example to motivate typeclasses.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I would be in support of this, I'll wait a bit to see that others agree before doing so.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That was my impression also.

Comment thread LF/Typeclasses.lean Outdated
Comment thread LF/Typeclasses.lean
Comment thread LF/Typeclasses.lean Outdated
Co-authored-by: Daniel Sainati <sainatidaniel@gmail.com>

@rogerburtonpatel rogerburtonpatel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks like a great start. I recommend a few more exercises, and some shifting of text, but it's already in a nice spot if we assume a post-indprop audience.

Comment thread LF/Typeclasses.lean
Comment thread LF/Typeclasses.lean
Comment thread LF/Typeclasses.lean Outdated
Comment thread LF/Typeclasses.lean Outdated
Comment thread LF/Typeclasses.lean Outdated
Comment thread LF/Typeclasses.lean
@chenson2018

Copy link
Copy Markdown
Collaborator Author

Note to self: confirmed in another PR that we will have structures by this point, so should use that in the initial explanation.

@bcpierce00

Copy link
Copy Markdown
Collaborator

I've had a quick look at the PR -- will review the chapter more thoroughly later, but I suggest we close the discussions on the PR, merge it, and continue thinking about all the remaining stuff at leisure.

Doesn't seem to compile right now, though...

@chenson2018

Copy link
Copy Markdown
Collaborator Author

Doesn't seem to compile right now, though...

I think there's something odd happening with the generated Lean files, I'll have a look.

@bcpierce00

bcpierce00 commented Jun 30, 2026 via email

Copy link
Copy Markdown
Collaborator

Comment thread LF/Typeclasses.lean Outdated
Comment thread LF/Typeclasses.lean
@bcpierce00
bcpierce00 requested a review from a team as a code owner July 14, 2026 17:21
@dsainati1

Copy link
Copy Markdown
Collaborator

This wasn't building because the -keep and +error flags were being ignored during Verso extraction. I left a comment to this effect in the file and commented out the erroring code.

@dsainati1

Copy link
Copy Markdown
Collaborator

Build on this remains broken for two reasons, as best I can tell:

  • The generated LF.IndPropVerso file does not seem to typecheck
  • The import of Typeclasses into HL.Imp doesn't strip the verso module imports

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.

6 participants