title: Why doesn't sleep work?
body: <p>Why does <code>c_sleep</code> return immediately in the following code?</p>
  
  <pre><code>{-# LANGUAGE ForeignFunctionInterface #-}
  import Foreign.C.Types
  import Data.Time.Clock
  import Control.Concurrent
  
  foreign import ccall unsafe "unistd.h sleep" 
      c_sleep :: CUInt -&gt; IO CUInt
  
  main :: IO ()
  main = do
      getCurrentTime &gt;&gt;= print . utctDayTime
      c_sleep 10     &gt;&gt;= print                -- this doesn't sleep
      getCurrentTime &gt;&gt;= print . utctDayTime
      threadDelay $ 10 * 1000 * 1000          -- this does sleep
      getCurrentTime &gt;&gt;= print . utctDayTime
  </code></pre>
  
  <pre>$ ghc --make Sleep.hs && ./Sleep
  [1 of 1] Compiling Main             ( Sleep.hs, Sleep.o )
  Linking Sleep ...
  29448.191603s
  10
  29448.20158s
  29458.211402s
  
  $ ghc --version
  The Glorious Glasgow Haskell Compilation System, version 7.8.3
  
  $ cabal --version
  cabal-install version 1.20.0.3
  using version 1.20.0.0 of the Cabal library 
  </pre>
  
  <p><strong>Note:</strong> Actually, I would like to use <a href="http://man.cx/sleep%283%29" rel="noreferrer"><code>sleep</code></a> in C code to simulate some heavy computation in a function <code>func</code> and call <em>that</em> function in Haskell, but that doesn't work either, probably for the same reasons.</p>