Haskell Quine: "ap" Monad

What is the correct way to use the "ap" monad in Haskell? I want to do something similar to this:

main = (putStr . ap (++) show) "main = (putStr . ap (++) show) "

but I get the error "Out of scope:" ap ".

Using "import Control.Monad" does nothing. And I tried to give him

"ap :: Monad m => m (a -> b) -> m a -> m b" 

then I get: "Type signatures for" ap "are not enough accompanying binding"

+5
source share
1 answer

Import Control.Monadshould give you ap. However, in all but the most recent versions of GHC (7.6.1 and later), you will also need to import Control.Monad.Instancesin order to use the monad instance for functions.

Control.Applicative, <*>, ap Applicative, .

+8

All Articles