On Nov 29, 2007, at 6:19 PM, Stefan O'Rear wrote:

On Thu, Nov 29, 2007 at 09:10:16PM +0000, Andrew Coppin wrote:
Sebastian Sylvan wrote:
On Nov 29, 2007 6:43 PM, Andrew Coppin <[EMAIL PROTECTED]>
wrote:

I don't understand the ST monad.

...[and ST uses language extensions Andrew doesn't understand.]

(As far as ST goes, runST is unsafePerformIO renamed.  The only tricky
bit is proving safety.)

To put it another way, runST is unsafePerformIO where somebody has already done the safety proof for you (so you know it's 100% safe). The "strange" extensions are simply a device to make the safety proof work. Indeed, if you drop the extensions it can all be made to work (just say runST :: ST () a -> a) but you lose the safety proof and it's equivalent to unsafePerformIO.

-Jan

[The trick used in runST is one of my all-time favorite bits of type theory, and is what convinced me we wanted second-order types back before the first Haskell workshop.]

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to