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

Future of PyF with native string interpolation in GHC #140

Closed
guibou opened this issue Aug 18, 2024 · 1 comment
Closed

Future of PyF with native string interpolation in GHC #140

guibou opened this issue Aug 18, 2024 · 1 comment

Comments

@guibou
Copy link
Owner

guibou commented Aug 18, 2024

ghc-proposals/ghc-proposals#570 (comment) is a GHC proposal which will introduce native string interpolation in GHC, in a syntax like:

s"Name: ${name}, age: ${age}"

Where name and age could be any haskell expression.

GHC 9.12 will already have multiline string with prefix removed.

So compared to GHC with native string interpolation, what is the added value of PyF? Well, simple, formatting.

However, PyF requires template haskell and for this reason the library had never really found its users (I don't see any reason, if you know why, please share).

Another of the niceties of PyF, from my point of view, is the compact formatting expression minilanguage (which can be a nightmare if you want to use all possible options), which is also well known (because used in python and inspired by printf, ...).

So I'm thinking about introducing a library in PyF able to be used in a compact way inside string interpolation. For example, the former:

```haskell
[fmt|Name: {name}, age: {age:.2}|]

Could be turned to:

f"Name: ${name}, age: ${#".2" age}

The idea is to lift the formatting mini language to a symbol / label. Error reporting won't be as nice as what we currently have in PyF (e.g. no carret into the mini language).

Any idea ?

@guibou
Copy link
Owner Author

guibou commented Jan 3, 2025

PyF does not have enough visibilty to generate discussion here. I'm closing.

@guibou guibou closed this as completed Jan 3, 2025
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

No branches or pull requests

1 participant