Imported foreign functions should be strict

Simon Marlow marlowsd at gmail.com
Tue Jul 10 09:57:31 CEST 2012


On 07/07/2012 05:06, Favonia wrote:
> Hi all,
>
> Recently I am tuning one of our incomplete libraries that uses FFI.
> After dumping the interface file I realized strictness/demand analysis
> failed for imported foreign functions---that is, they are not inferred
> to be strict in their arguments. In my naive understanding all
> imported foreign functions are strict! Here's a minimum example (with
> GHC 7.4.2):
>
> {-# LANGUAGE ForeignFunctionInterface #-}
> module Main where
> import Foreign.C
> foreign import ccall unsafe "sin" sin' :: CDouble -> CDouble
>
> where in the interface file the function sin' will have strictness
> U(L) (meaning Unpackable(Lazy)).

This is fine - it means the CDouble is unpacked into its unboxed Double# 
component.  An unboxed value is always represented by L in strictness 
signatures.

Cheers,
	Simon



More information about the Glasgow-haskell-users mailing list