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

format primitive for turning values into pretty-printed strings #411

Open
byorgey opened this issue Dec 4, 2024 · 0 comments
Open

format primitive for turning values into pretty-printed strings #411

byorgey opened this issue Dec 4, 2024 · 0 comments
Labels
C-Moderate Effort Should take a moderate amount of time to address. S-Nice to have Minor importance Z-Feature Request

Comments

@byorgey
Copy link
Member

byorgey commented Dec 4, 2024

Disco has strings (as List(Char)) but no easy way to turn values into strings. For example, suppose we wanted a function like

reportWidgets : N -> List(Char)
reportWidgets n = append("There are ", append(??? n, " widgets"))

There is currently nothing appropriate to put in place of ???. We could manually write our own function to turn natural numbers into strings but it would be tedious and inefficient.

I propose adding some function like format : a -> List(Char) [format a] where format is a new constraint for types that can be formatted. Alternatively we could just make it defined on all types, format : a -> List(Char), but have it return some default for types whose values can't be converted.

@byorgey byorgey added C-Moderate Effort Should take a moderate amount of time to address. Z-Feature Request S-Nice to have Minor importance labels Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Moderate Effort Should take a moderate amount of time to address. S-Nice to have Minor importance Z-Feature Request
Projects
None yet
Development

No branches or pull requests

1 participant