[Haskell-cafe] Invertible functions list
aslatter at gmail.com
Mon Dec 28 22:43:08 EST 2009
On Mon, Dec 28, 2009 at 10:32 PM, Jonathan Fischoff
<jonathangfischoff at gmail.com> wrote:
> I would to create a list of tuples (or something similar) of invertible
> [((a -> b), (b -> a)), ((b -> c), (c -> b)), ....
> Such that I could call
> forward invertibleFuctionList domainValue = ? -- composite all the functions
> backward invertibleFuctionList rangeValue =
> forward (reverse invertibleFuctionList) rangeValue -- or something
> I would also like to concat them. This sounds like a job for GADT that
> someone might have already tackled. Any ideas?
It looks like the thrist package should help you out:
You could define some sort of type Iso:
data Iso a b = Iso (a -> b) (b -> a)
And then build a Thrist and fold over it, the functions forward and
backwards can both be implemented with right-folds.
More information about the Haskell-Cafe