Re: [m-users.] Impurity needed?

Volker Wysk <[email protected]>
Newsgroups gmane.comp.lang.mercury.general
Message-ID <[email protected]>
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

_______________________________________________
users mailing list
[email protected]
https://lists.mercurylang.org/listinfo/users
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEE6QXGh82Ov3+2nrxp+K4ydFOsHoUFAmPsWzYACgkQ+K4ydFOs
HoXYfQ//UMhmZmDuikDVTB/i8WGH9nbJBHk+yD0FvCLocWdn8vx6FbsB7KhXja/U
W2DrO3VEcfURpCioXqR6Dw6gqX/8A035rJ4mIdsIo8bJmdt9VV0DEDiaHk/Bm4lg
eahSY+DwybnoGntNL9W2vVR8wZTtRwY8Eg+0D4msPtQWH39jCV70C+/zdHvvRKEo
gZXYLnjEmXbs7tWvgk0K3RRS3Fou9UJ95DiNK775VUWJMOpRmvQ230Ep+F7Oz2IB
8043Qu4i++mE41kxcdfkCsNwgEca7PIKdDh5eqlgCZ5hUq+ejom0IfARfhelBERk
qgu3M4JwzMxsLC31Um3k86oMjFuTMCkgoyXLiRhy3ROtCluDJ5poA/SDCH1srC0N
+EqkL8p4Y8T26gcFt27UtLjG0xq0Ku7JjbnmYE0mOcAEuNZvrxXYa4WQzNwYD6Cv
X7EtshiiDqP+oTNayTccsOCtFmf4HaefTFo0FAFFtDUUSQGQrgMcgemwYKsqksoo
KNxGFEZpaYI1yzjUjrFqyvVWRUpFDosOv4EqGXaXvIMv3EcqtEj/rtJWEA9S81Yo
caYdQjM72eh62HvGAKJQPdoAvtFEHVX9vbvgmyjge+khdI16IkotdDYH8ZHkNtbG
k1kJC5VDwSQkHVv8WUMXZax4We31hVh9SDF7tXqv7nmVr2aJ3+Q=
=wRD2
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.