Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Equivalent of IO Monad in other functional languages?
(Tony Morris)
2. Re: Equivalent of IO Monad in other functional languages?
(Karl Voelker)
----------------------------------------------------------------------
Message: 1
Date: Mon, 16 Mar 2015 07:17:33 +1000
From: Tony Morris <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Equivalent of IO Monad in other
functional languages?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252; format=flowed
Scalaz implements IO and ST as a library for Scala.
http://eed3si9n.com/learning-scalaz/IO+Monad.html
On 16/03/15 02:17, Simon Kitching wrote:
> [Note: learning haskell, not familiar with other functional languages]
>
> I have a question about handling impure operations in functional or
> semi-functional languages other than Haskell (eg OCaml, F#, Scala, ..).
>
> Haskell uses the IO monad to (a) cleanly separate pure and impure
> code, and (b) prevent function-calls from being reordered when they
> have side-effects that must happen in the right order. How do other
> languages handle this?
>
> AIUI, whether a Haskell function is 'pure' or not can be seen from its
> method signature : if it returns IO then it is impure. All standard
> library functions that have side-effects (read/write/etc) return IO,
> and any function that uses an IO value must return type IO. Do other
> functional languages (1) use a similar approach, or (2) not provide a
> way to be certain that a function is 'pure' (side-effect-free)?
>
> And AIUI the Haskell compiler/runtime can postpone evaluation of any
> function (laziness), or reorder function calls whever it thinks this
> good. However using the monad design pattern (deliberately) prevents
> this (each operation passes its value as a parameter to the subsequent
> operation, thus forcing an order of evaluation). Do other languages
> (a) not support compiler/runtime reordering of functions, or (b) have
> some other way of preventing functions with side-effects from being
> reordered?
>
> Thanks..
> Simon
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
Message: 2
Date: Sun, 15 Mar 2015 14:44:02 -0700
From: Karl Voelker <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Equivalent of IO Monad in other
functional languages?
Message-ID:
<1426455842.3291431.240699409.6e305...@webmail.messagingengine.com>
Content-Type: text/plain
On Sun, Mar 15, 2015, at 09:17 AM, Simon Kitching wrote:
> And AIUI the Haskell compiler/runtime can postpone evaluation of any
> function (laziness), or reorder function calls whever it thinks this
> good.
It's not that it "can" but that it must. Haskell's evaluation strategy
is a part of the language specification.
Consider this expression:
let f = 1 : f in take 5 f
You can paste this into ghci and feel confident that it's going to
terminate. You're not at the whim of the runtime.
I think you may find these articles interesting:
https://wiki.haskell.org/Lazy_evaluation
https://wiki.haskell.org/Non-strict_semantics
-Karl
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 81, Issue 44
*****************************************