Skip to content

Support ByteArray with UnliftedFFITypes

Motivation

I have a bunch of places in library where I pass a ByteArray to a C function through the FFI. For example:

foreign import ccall unsafe "rd_kafka_topic_partition_list_add"
  rdKafkaTopicPartitionListAdd ::
       Ptr TopicPartitionList                                                                  
    -> ByteArray#
    -> Partition
    -> IO (Ptr TopicPartition)

Every time I do this, I have to unwrap the ByteArray to expose the ByteArray# that I am trying to get at.

Proposal

When UnliftedFFITypes is enabled, allow ByteArray as an argument type in FFI calls. This is possible now that ByteArray has been moved to base.

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