I am having hard time making sense of GHC.Conc. Is there a writeup that describes the significance of "#", or the meaning of "primOp" and "primType"?<br><br>Thanks<br><br>Daryoush<br><br><div class="gmail_quote">
On Sun, Dec 7, 2008 at 11:48 PM, Don Stewart <span dir="ltr"><<a href="mailto:dons@galois.com">dons@galois.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
dmehrtash:<br>
<div class="im">> Any idea was the atomically# mean in the following code?<br>
><br>
> atomically :: STM a -> IO a<br>
> atomically (STM m) = IO (\s -> (atomically# m) s )<br>
><br>
> Code is from GHC.Conc module<br>
</div>> [1]<a href="http://www.haskell.org/ghc/docs/6.6/html/libraries/base/GHC-Conc.html" target="_blank">http://www.haskell.org/ghc/docs/6.6/html/libraries/base/GHC-Conc.html</a><br>
<br>
It is a primitive hook into the runtime, where transactional memory is<br>
implemented.<br>
<br>
It is documented in the primops module in the GHC source,<br>
<br>
$ cd ghc/compiler/prelude/<br>
<br>
------------------------------------------------------------------------<br>
section "STM-accessible Mutable Variables"<br>
------------------------------------------------------------------------<br>
<br>
primtype TVar# s a<br>
<br>
primop AtomicallyOp "atomically#" GenPrimOp<br>
(State# RealWorld -> (# State# RealWorld, a #) )<br>
-> State# RealWorld -> (# State# RealWorld, a #)<br>
with<br>
out_of_line = True<br>
has_side_effects = True<br>
<br>
primop RetryOp "retry#" GenPrimOp<br>
State# RealWorld -> (# State# RealWorld, a #)<br>
with<br>
out_of_line = True<br>
has_side_effects = True<br>
<br>
<br>
Along with other primitives like:<br>
<br>
------------------------------------------------------------------------<br>
section "Parallelism"<br>
------------------------------------------------------------------------<br>
<br>
primop ParOp "par#" GenPrimOp<br>
a -> Int#<br>
with<br>
-- Note that Par is lazy to avoid that the sparked thing<br>
-- gets evaluted strictly, which it should *not* be<br>
has_side_effects = True<br>
<font color="#888888"><br>
-- Don<br>
</font></blockquote></div><br><br>