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

Idea: Make interpolation dependent on user-defined instances #147

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Profpatsch
Copy link
Contributor

@Profpatsch Profpatsch commented Jan 20, 2025

This is a WIP idea I’ve had that’s related to I think GHC string
interpolation should ultimately work.

Instead of defaulting to IsString and having a fixed amount of output
formats we can use, we want the user to provide three things:

A) The output type out, which has to be Semigroup for
concatenation
B) An instance Interpolate a out for each type that
should be able to be interpolated into out.
C) An instance
Interpolate Text out for interpolating raw strings

This way the user can provide domain-specific instances and prevent
some problematic interpolations.

This is just an initial idea, not intended to be merged.

This is a WIP idea I’ve had that’s related to I think GHC string
interpolation should ultimately work.

Instead of defaulting to IsString and having a fixed amount of output
formats we can use, we want the user to provide three things:

A) The output type `out`, which has to be `Semigroup` for
   concatenation
B) An instance `Interpolate a out` for each type that
should be able to be interpolated into `out`.
C) An instance `Interpolate Text out` for interpolating raw strings

This way the user can provide domain-specific instances and prevent
some problematic interpolations.

This is just an initial idea, not intended to be merged.
@Profpatsch
Copy link
Contributor Author

Now that I think about it, the output type should probably come first so that you can curry the type constructor better

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