PyF icon indicating copy to clipboard operation
PyF copied to clipboard

Idea: Make interpolation dependent on user-defined instances

Open Profpatsch opened this issue 11 months ago • 1 comments

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 avatar Jan 20 '25 17:01 Profpatsch

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

Profpatsch avatar Jan 21 '25 10:01 Profpatsch