
@notjack would be nice if we can invoke the pattern f^{–1} g f easily from your converter.
Like, (compose1 number->string add1 string->number)

@sorawee what sort of use cases do you have for it?

This is the classic “change of basis” in algebra. And it’s useful in programming too as you can see in the above example

Like, I want to do some operations, but the data that I have right now can’t quite do that operation, so I need to convert it to a form that it can operates on, perform the operation, and then convert it back to the original format.

in general I think if you’re finding yourself in that situation often enough that the utility would be super useful, that’s a symptom that something deeper is wrong and should be fixed - why isn’t the data in the right format to begin with?

more importantly I’m not sure what a good name for such a utility would be

(convert-function-forward number<->string add1)
I think that makes it pretty readable; it converts a number-to-number function to a string-to-string function.

hmm

(function<->function
number<->string
number<->string)
add1)
With a function<->function
conversion combinator like this, you can read off the left side (-> number? number?)
and the right side (-> string? string?)
of the conversion. It’s not as concise, but it’s easier to see how more complex type signatures would be catered to this way. [edited for code formatting]

I think I’d rather just write (convert-backward number<->string (add1 (convert-forward number<->string x)))