I'm wondering whether there is a systematic/generic way to find an inverse function in Haskell.
Assuming that the function is bijective. Like:
map (+1) . map (\x -> x-1) == id
transpose . transpose == id
(It is interesting that funs like transpose and reverse are inverse themselves.)
We can manually find the inverse of these functions.
While functions are not bijective cannot:
f = (*0)
sum
I also find that functions with two params may or may not be bijections. For map, like map (+1) is bijective while map (*0) is not.
The composition of two bijective functions are also bijective (when considering only one param):
g = transpose . map (map (+1))
h = map (map (\x->x-1)). transpose
g . h == id
(For h = f . g, if we can find f' and g', then we can find h' = g' . f')
So if we restrict to a bijective function f :: a -> b , is there a systematic way to find the inverse f' :: b -> a or inverse functions of some compositions of bijective functions?