[m-users.] Impurity needed?

Volker Wysk post at volker-wysk.de
Wed Feb 15 15:10:30 AEDT 2023


Am Dienstag, dem 14.02.2023 um 01:05 +1100 schrieb Zoltan Somogyi:
> If you need an equivalent of Haskell's unsafe_perform_io, and it seems you do,
> you can build it yourself like this:
> 
> promise_pure (
>   some [!IO] (
>     io.unsafe_get_io_state(!:IO),
>     ...,
>     io.unsafe_set_io_state(!.IO)
>   )
> )

For the record, the Haskell function is "unsafePerformIO", and your code
snippet should be:

promise_pure (
  some [!IO] (
    semipure io.unsafe_get_io_state(!:IO),
    ...,
    impure io.unsafe_set_io_state(!.IO)
  )
).

Thanks for your answer!

Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mercurylang.org/archives/users/attachments/20230215/b4e5770a/attachment.sig>


More information about the users mailing list