[Haskell-cafe] Expressing "self-composable" functions at the type level
baliulia at gmail.com
Sat Nov 9 23:46:59 UTC 2013
I'm wondering if there's some way to express that a function can be
composed with itself at the type level. Due to polymorphism this is not
quite the same as saying that the domain and co-domain match.
swap :: (a, b) -> (b, a)
swap . swap :: (a, b) -> (a, b)
I'd like to write a function such as (in pseudocode):
involute :: ((a -> b) &&& (b -> a)) -> (a -> a)
involute f = f . f
But I obviously can't write down the type for (a -> b) &&& (b -> a)
Perhaps this can be done with some typeclass hackery?
More information about the Haskell-Cafe