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

[ interpolate ] Implement Interpolation for primitive numeric types #3171

Merged

Conversation

buzden
Copy link
Contributor

@buzden buzden commented Dec 20, 2023

Description

Interfaces Interpolation and Show have different meanings, and polymorphic implementations of Interpolation tend to require Interpolation for inner types rathen than Show, which is logical. Primitive numeric types have almost single meaningful canonical string representation, so I suggest to add Interpolation implementaitons for them (and for Nat too).

Should this change go in the CHANGELOG?

  • If this is a fix, user-facing change, a compiler change, or a new paper
    implementation, I have updated CHANGELOG.md (and potentially also
    CONTRIBUTORS.md).

@stefan-hoeck
Copy link
Contributor

Personally, I don't think this is a good idea. I'm not opposed to adding default implementations for Interpolation, but in my opinion, they should not be auto-imported via the Prelude. There are quite a few use cases, where custom implementations would be useful (displaying numbers in a different base or adding separators for readability), and those use cases will now require newtype wrappers or explicit function calling to still work correctly.

I'd prefer it, if these default implementations would go into a module in base, that needs to be imported explicitely.

@buzden buzden force-pushed the interpolation-for-primitive-types branch from a0d0e5f to 81da17a Compare December 20, 2023 15:09
@buzden
Copy link
Contributor Author

buzden commented Dec 20, 2023

Well, that sounds reasonable, let's move it to base. At least, this change indeed will be backwards compatible with custom user declarations

@buzden buzden force-pushed the interpolation-for-primitive-types branch from 81da17a to 2b4ed49 Compare December 22, 2023 10:46
@mattpolzin mattpolzin merged commit 3fe95d4 into idris-lang:main Dec 29, 2023
22 checks passed
@buzden buzden deleted the interpolation-for-primitive-types branch December 29, 2023 17:57
buzden added a commit to buzden/Idris2 that referenced this pull request Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants