withForeignPtr package:streaming-bytestring

This is similar to withForeignPtr but comes with an important caveat: the user must guarantee that the continuation does not diverge (e.g. loop or throw an exception). In exchange for this loss of generality, this function offers the ability of GHC to optimise more aggressively. Specifically, applications of the form: unsafeWithForeignPtr fptr (forever something) See GHC issue #17760 for more information about the unsoundness behavior that this function can result in.