[m-users.] Impurity needed?
Volker Wysk
post at volker-wysk.de
Tue Feb 14 02:49:08 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)
> )
> )
>
> unsafe_{get,set}_io are the primitives that the compiler uses
> to implement trace [io(!IO)]. We don't advertise them, since we want to
> discourage their use, but there is no point in hiding them either,
> because it is trivial to implement them using foreign_procs anyway.
This looks very interesting. I have to play with it. :-)
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/20230213/8c8833c5/attachment.sig>
More information about the users
mailing list