Is there ever a good reason to use unsafePerformIO?

后端 未结 6 560
北海茫月
北海茫月 2020-12-24 07:04

The question says it all. More specifically, I am writing bindings to a C library, and I\'m wondering what c functions I can use unsafePerformIO with. I assume

6条回答
  •  生来不讨喜
    2020-12-24 07:24

    The way I see it, the various unsafe* nonfunctions really should only be used in cases where you want to do something that respects referential transparency but whose implementation would otherwise require augmenting the compiler or runtime system to add a new primitive capability. It's easier, more modular, readable, maintainable and agile to use the unsafe stuff than to have to modify the language implementation for things like that.

    FFI work often intrinsically requires you to do this sort of thing.

提交回复
热议问题