Skip to content

GHC should accept FFI type wrapping State# RealWorld -> (# State# RealWorld, a #)

Motivation

Recently I'm using ST RealWorld as an alternative IO monad to get rid of the PrimMonad constraint all over the place, it works pretty fine, with just one inconvenience: The type ST RealWorld a is not accepted as a return type of FFI imports. This is an unnecessary limitation.

Proposal

Please accept any type wrapping around State# RealWorld -> (# State# RealWorld, a #) as an FFI return type.

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