title: Importing 'C' Delay function into Haskell using FFI
body: <p>There is a function in the wiringPi 'C' library called <code>delay</code> with type </p>
  
  <p><code>void delay(unsigned int howLong);</code></p>
  
  <p>This function delays execution of code for <code>howLong</code> milliseconds. I wrote the binding code in haskell to be able to call this function. The haskell code is as follows,</p>
  
  <pre><code>foreign import ccall "wiringPi.h delay" c_delay :: CUInt -&gt; IO ()
  hdelay :: Int -&gt; IO ()
  hdelay howlong = c_delay (fromIntegral howlong)
  </code></pre>
  
  <p>After this, I wrote a simple haskell program to call this function. The simply haskell code is as follows..</p>
  
  <p>--After importing relavent libraries I did</p>
  
  <pre><code>main = wiringPiSetup
      &gt;&gt; delay 5000
  </code></pre>
  
  <p>But the delay does not happen or rather the executable generated by the ghc compiler exits right away. </p>
  
  <p>Could someone tell me what could possibly go wrong here? A small nudge in the right direction would help.</p>
  
  <p>Cheers and Regards.</p>