Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: qrczak@knm.org.pl (Marcin 'Qrczak' Kowalczyk)
To: caml-list@inria.fr
Cc: Dave Berry <dave@kal.com>
Subject: Re: Language Design
Date: 1 Sep 2000 19:12:24 GMT	[thread overview]
Message-ID: <slrn8qvvso.ljc.qrczak@qrnik.knm.org.pl> (raw)
In-Reply-To: <3145774E67D8D111BE6E00C0DF418B662D78C0@nt.kal.com>

Fri, 1 Sep 2000 12:57:13 +0100, Dave Berry <dave@kal.com> pisze:

> Given a value in a monad, e.g. IO v, how can I remove v from the Monad?

For Haskell's IO monad, you don't have a function of type IO v -> v.
IO is carried up to main, the "action of the whole program".

Other monads may or may not provide a similar function.

> Surely this would be required to seamlessly integrate stateful and
> functional code?

In a pure language it is not possible to create a function which does
I/O when applied. If an operation may do I/O, it is reflected in its
type and usage. It may be considered a good thing, and is practically
a must in a lazy language.

In some Haskell implementations there is monad called ST (state
transformer) which provides mutable references and arrays, and can
be wrapped in a pure function. Not all stateful code requires IO.

Actually in some implementations there is unsafePerformIO :: IO a -> a
but it's, well, unsafe. It's sometimes very useful for real life
problems.

-- 
 __("<  Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



  parent reply	other threads:[~2000-09-03 20:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-09-01 11:57 Dave Berry
2000-09-01 17:48 ` Markus Mottl
2000-09-01 19:12 ` Marcin 'Qrczak' Kowalczyk [this message]
     [not found]   ` <39B5DD81.E2500203@maxtal.com.au>
2000-09-06  6:33     ` Marcin 'Qrczak' Kowalczyk
  -- strict thread matches above, loose matches on Subject: below --
2000-08-21 21:44 David McClain
2000-08-23  5:55 ` John Max Skaller
2000-08-24  9:12   ` Francois Pottier
2000-08-24 20:16     ` John Max Skaller
2000-08-25  9:52       ` Andreas Rossberg
2000-08-27 22:00         ` John Max Skaller
2000-08-28 23:11           ` Daan Leijen
2000-08-25 15:41       ` Jerome Vouillon
2000-08-27 22:21         ` John Max Skaller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=slrn8qvvso.ljc.qrczak@qrnik.knm.org.pl \
    --to=qrczak@knm.org.pl \
    --cc=caml-list@inria.fr \
    --cc=dave@kal.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox