
Oops, I thought I had sent a response to the cafe, but it looks like
it just went to Matthew.
Unfortunately, I was trying to give a simplification of the real
problem, where the monad is STM instead of []. Based on apfelmus's
observation of why they can't be isomorphic, I'm guessing I'm out of
luck.
http://www.haskell.org/pipermail/haskell-cafe/2006-December/020041.html
So in reality, I'm trying to construct something like
f :: (a -> STM b) -> STM (a -> b)
I just figured it was a general monadic kind of problem, more simply
expressed using lists. But the (!!) solution doesn't make sense in
this context.
On 2/2/07, Yitzchak Gale
Chad Scherrer wrote:
Are (a -> [b]) and [a -> b] isomorphic? I'm trying to construct a function
f :: (a -> [b]) -> [a -> b]
that is the (at least one-sided) inverse of
f' :: [a -> b] -> a -> [b] f' gs x = map ($ x) gs
Anything better than this?
f g = [\x -> g x !! n | n <- [0..]]
-Yitz
-- Chad Scherrer "Time flies like an arrow; fruit flies like a banana" -- Groucho Marx