Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can this function be implemented?

Is there any implementation for this function?

foo :: (Monad m, Monad n) => m a -> n a -> (a -> a -> a) -> m (n a)
foo x y f = ...
like image 394
drhodes Avatar asked Dec 15 '22 03:12

drhodes


1 Answers

Yes, and it can be given a more general type.

foo :: (Functor f, Functor g) => (a -> b -> c) -> f a -> g b -> f (g c)
foo f fx gy = fmap (\x -> fmap (f x) gy) fx
like image 130
Benjamin Hodgson Avatar answered Dec 30 '22 01:12

Benjamin Hodgson