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

Added string formatting library #1326

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Added string formatting library #1326

wants to merge 1 commit into from

Conversation

Izaakwltn
Copy link
Collaborator

Here is a rough draft for a string formatting library.

I'm happy to change any of the names or syntax.

The library centers around a macro format, which takes any number of strings and concatenates them into one string.

The rest of the library provides tools for formatting different types into strings in different ways.

A few examples:

COALTON-LIBRARY/FORMAT> (coalton (format "Numbers:" \n (format-with-delimiter eng \n (iter:up-to 5))))
"Numbers:
zero
one
two
three
four
"
COALTON-LIBRARY/FORMAT> (coalton (format "the number " (ticked 20) " is not the same as " (ticked 21)))
"the number `20` is not the same as `21`"
COALTON-LIBRARY/FORMAT> (coalton-toplevel
                          (declare print-bin (Integer -> Unit))
                          (define (print-bin x)
                            (coalton-library/functions:trace (format "The integer " (into x) " is printed in binary as " (bin x)))))
; No value
COALTON-LIBRARY/FORMAT> (coalton (print-bin 3))
The integer 3 is printed in binary as 11

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.

1 participant