drhodes
drhodes

Reputation: 1009

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 = ...

Upvotes: 4

Views: 100

Answers (1)

Benjamin Hodgson
Benjamin Hodgson

Reputation: 44603

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

Upvotes: 12

Related Questions