I have a function seperateFuncs such that
seperateFuncs :: [a -> b] -> (a -> [b])
seperateFuncs xs = \x -> map ($ x) xs
I was wondering whether the converse existed, i.e. is there a function
joinFuncs :: (a -> [b]) -> [a -> b]
I think not (mainly because lists are not fixed length), but perhaps I’ll be proved wrong.
The question then is there some datatype f which has a function :: (a -> f b) -> f (a -> b)?
You can generalize
seperateFuncstoApplicative(orMonad) pretty cleanly:Written in point-free style, you have
seperateFuncs = ((. pure) . (<*>)), so you basically wantunap . (. extract), giving the following definition if you write it in pointful style:Here I define
Unapplictaiveas:To get the definitions given by leftaroundabout, you could give the following instances:
I think it’s hard to come up with a “useful” function
f :: (f a -> f b) -> f (a -> b)for anyfthat isn’t like(->).