home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / gofer230.zip / Progs / Gofer / ioarray.gs < prev    next >
Text File  |  1994-06-23  |  2KB  |  41 lines

  1. ------------------------------------------------------------------------------
  2. -- This file contains a Gofer implementation of the monadic array
  3. -- primitives for Lazy state threads, as described in the PLDI '94
  4. -- paper by John Launchbury and Simon Peyton Jones, using new Gofer
  5. -- primitives added in Gofer 2.30.
  6. --
  7. -- This file must be loaded only after both array.gs and iomonad.gs,
  8. -- and requires the standard, or cc prelude.
  9. --
  10. -- You will not be able to use this file unless the version of Gofer that
  11. -- is installed on your machine has been compiled with the IO_MONAD flag
  12. -- and the HASKELL_ARRAYS flag set to 1.
  13. --
  14. -- Mark P Jones, 1994
  15. ------------------------------------------------------------------------------
  16.  
  17. module LazyStateArr( newArr, readArr, writeArr, freezeArr ) where
  18.  
  19. primitive primSTNewArr   "primSTNewArr"
  20.           :: (a -> Int) -> (a,a) -> b -> ST s (MutArr s a b)
  21. primitive primSTReadArr  "primSTReadArr"
  22.           :: ((a,a) -> a -> Int) -> MutArr s a b -> a -> ST s b
  23. primitive primSTWriteArr "primSTWriteArr"
  24.           :: ((a,a) -> a -> Int) -> MutArr s a b -> a -> b -> ST s ()
  25. primitive primSTFreeze   "primSTFreeze"
  26.           :: MutArr s a b -> ST s (Array a b)
  27.  
  28. newArr       :: Ix a => (a,a) -> b -> ST s (MutArr s a b)
  29. newArr bounds = primSTNewArr (index bounds) bounds
  30.  
  31. readArr      :: Ix a => MutArr s a b -> a -> ST s b
  32. readArr       = primSTReadArr index
  33.  
  34. writeArr     :: Ix a => MutArr s a b -> a -> b -> ST s ()
  35. writeArr      = primSTWriteArr index
  36.  
  37. freezeArr    :: Ix a => MutArr s a b -> ST s (Array a b)
  38. freezeArr     = primSTFreeze
  39.  
  40. ------------------------------------------------------------------------------
  41.