Skip to content

Document UnliftedFFITypes

Motivation

There is no documentation of UnliftedFFITypes in the GHC user manual (other than that there is an extension with this name). With the power of google and the power of having been around a while, I've learned two things:

  • It lets you use GHC.Exts.Any in FFI type signatures.
  • It lets you use ByteArray# and MutableByteArray# in FFI type signatures. It also adds as offset to the stg closure to give the user the address that refers to the beginning of the payload. This being undocumented has led to confusion.

I have no idea what happens if you pass Array#, SmallArray#, etc. Is an offset applied to the pointer or not?

Proposal

Document this extension.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information