On Mon, May 19, 2014 at 7:48 AM, Bob Hutchison <hutch-li...@recursive.ca>wrote:
> > Haskell's STM transactions can be thought of as a form of IO action (like > reading a file is an IO action) that modify refs (there are no atoms in > Haskell, only refs). A transaction must be started in the IO monad and > then, like IO, the STM monad is 'carried' in type signatures through all > intervening computations that could take part in the transaction. The STM > type/monad 'blocks' the IO type/monad (you can't do other IO actions if you > might take part in an STM transaction (IO action), this is an effect of, > and enforced by, Haskell's type system (i.e. it's a compilation not a > runtime error)). In Clojure the STM isn't part of the IO system, and you > can start or take part in a transaction anywhere you want to, even nest > dosyncs within a single transaction, and intermingle transactional code > with IO (no matter how bad an idea that is). > You can use regular IO in an STM action with unsafeUItoSTM: < http://hackage.haskell.org/package/base-4.7.0.0/docs/GHC-Conc-Sync.html#v:unsafeIOToSTM>. IMO it's advantageous that you have to explicitly say that you want to do IO inside a transaction, given that (in general) you probably shouldn't be doing it. -- Ben Wolfson "Human kind has used its intelligence to vary the flavour of drinks, which may be sweet, aromatic, fermented or spirit-based. ... Family and social life also offer numerous other occasions to consume drinks for pleasure." [Larousse, "Drink" entry] -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.