Folks,

How is one to interpret the following? I'm particularly interested in the "IO $ \ s -> " notatoin as I have never seen that before.

allocaBytes :: Int -> (Ptr a -> IO b) -> IO b
allocaBytes (I# size) action = IO $ \ s ->
     case newPinnedByteArray# size s      of { (# s, mbarr# #) ->
     case unsafeFreezeByteArray# mbarr# s of { (# s, barr#  #) ->
     let addr = Ptr (byteArrayContents# barr#) in
     case action addr    of { IO action ->
     case action s       of { (# s, r #) ->
     case touch# barr# s of { s ->
     (# s, r #)
  }}}}}

Lemmih suggested that this is unrolling the code (manual inlining?) but how much speedup is that buying you?

Last but not least, what is

     case action addr    of { IO action ->
     case action s       of { (# s, r #) ->


        Thanks, Joel

--
http://wagerlabs.com/





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

Reply via email to