I have two functions of the form
foo :: Int -> IO String
bar :: Int -> IO Integer
which basically live in the functor given by the composition of (->) Int and IO.
Now, having a function of type
baz :: String -> Integer -> Float
I would like to lift it to the Int -> IO _ context using applicative syntax like
foobarbaz :: Int -> IO Float
foobarbaz = baz <$> foo <*> bar
If I do this the compiler yells at me with
Couldn't match type `IO String' with `[Char]'
Expected type: Int -> String
Actual type: Int -> IO String
as if it was trying to use the applicative instance only for (->) Int.
I thought applicative functors composed, so that I could use the applicative instance for the composed functor. Am I wrong? Or should I just provide more information to the compiler?
I tried also to enable TypeApplications to specify explicitly the functor I want to use, but I realized that I can't write (->) Int (IO _). Is there actually a way to do it?