title: Why does importing Control.Applicative allow this bad code to type check?
body: <p>I'm helping a friend learn Haskell and he recently created code like this, which type checks and produces a CPU-burning loop at runtime. I'm completely baffled by this.</p>
  
  <pre><code>import Control.Monad
  import Control.Applicative
  
  main = forever putStrLn "Hello, infinity"
  </code></pre>
  
  <p>That shouldn't type check, but does. The correct version would clearly be:</p>
  
  <pre><code>main = forever $ putStrLn "Hello, infinity"
  </code></pre>
  
  <p>What's weird and surprising to me is that you get different results with and without importing Control.Applicative. Without importing it, it doesn't type check:</p>
  
  <pre><code>Prelude Control.Monad&gt; forever putStrLn "Hello, infinity"
  
  &lt;interactive&gt;:1:1:
      No instance for (Monad ((-&gt;) String))
        arising from a use of `forever'
      Possible fix: add an instance declaration for (Monad ((-&gt;) String))
      In the expression: forever putStrLn "Hello, infinity"
      In an equation for `it': it = forever putStrLn "Hello, infinity"
  </code></pre>
  
  <p>I don't see a Monad instance for <code>((-&gt;) String</code> in the source for Control.Applicative, so I'm guessing something weird is happening due to its use of Control.Category or Control.Arrow, but I don't know. So I guess I have two questions:</p>
  
  <ol>
  <li>What is it about importing Control.Applicative that lets this happen?</li>
  <li>What's happening when it enters the infinite loop? What is Haskell actually trying to execute in that case?</li>
  </ol>
  
  <p>Thanks,</p>