> while pondering over the four fours problem, I wondered: Is there a > function of type > (a -> [b]) -> [a -> b] > > It looks a bit like sequence when applied in the ((->) a) Monad: > sequence :: [a -> b] -> a -> [b] > but I was looking for the other direction. > > I came up with: > \g -> map (\n a -> g a !! n) [1..] > which has the desired type and functionality, but it looks rather > inelegant and messy. Any better ideas?
While you showed that there exists unsequence :: (a -> [b]) -> [a -> b] , I doubt that it's very useful. The point is that (sequence) is not surjective: (a -> [b]) has strictly more functions than [a -> b]. (a -> [b]) has the freedom to adjust the length of the resulting depending on a list whereas [a -> b] hasn't. (sequence) converts an Applicative Functor to a Monad but there is no canonical other way round. In other words, unsequence . sequence === id but sequence . unsequence =/= id Regards, apfelmus _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe