[polyml] FFI conversions that are portable across Poly/ML versions