[Haskell-cafe] Trouble understanding NewBinary

Joel Reymont joelr1 at gmail.com
Fri Oct 7 18:02:22 EDT 2005


Folks,

In http://www.n-heptane.com/nhlab/repos/NewBinary/NewBinary/Binary.hs  
there's the following bit of code. What are the I#, S# and J#?

instance Binary Integer where
     put_ bh (S# i#) = do putByte bh 0; put_ bh (I# i#)
     put_ bh (J# s# a#) = do
      p <- putByte bh 1;
     put_ bh (I# s#)
     let sz# = sizeofByteArray# a#  -- in *bytes*
     put_ bh (I# sz#)  -- in *bytes*
     putByteArray bh a# sz#

     get bh = do
     b <- getByte bh
     case b of
       0 -> do (I# i#) <- get bh
           return (S# i#)
       _ -> do (I# s#) <- get bh
           sz <- get bh
           (BA a#) <- getByteArray bh sz
           return (J# s# a#)

     Thanks, Joel

--
http://wagerlabs.com/idealab







More information about the Haskell-Cafe mailing list