Movatterモバイル変換
[0]ホーム
{-# LANGUAGE Unsafe #-}{-# LANGUAGE NoImplicitPrelude, RoleAnnotations #-}{-# OPTIONS_GHC -funbox-strict-fields #-}{-# OPTIONS_HADDOCK hide #-}------------------------------------------------------------------------------- |-- Module : GHC.IOArray-- Copyright : (c) The University of Glasgow 2008-- License : see libraries/base/LICENSE---- Maintainer : cvs-ghc@haskell.org-- Stability : internal-- Portability : non-portable (GHC Extensions)---- The IOArray type-------------------------------------------------------------------------------moduleGHC.IOArray(IOArray(..),newIOArray,unsafeReadIOArray,unsafeWriteIOArray,readIOArray,writeIOArray,boundsIOArray)whereimportGHC.BaseimportGHC.IOimportGHC.Arr-- ----------------------------------------------------------------------------- | An 'IOArray' is a mutable, boxed, non-strict array in the 'IO' monad.-- The type arguments are as follows:---- * @i@: the index type of the array (should be an instance of 'Ix')---- * @e@: the element type of the array.----newtypeIOArrayie=IOArray(STArrayRealWorldie)-- index type should have a nominal role due to Ix class. See also #9220.typeroleIOArraynominalrepresentational-- explicit instance because Haddock can't figure out a derived one-- | @since 4.1.0.0instanceEq(IOArrayie)whereIOArrayx==IOArrayy=x==y-- |Build a new 'IOArray'newIOArray::Ixi=>(i,i)->e->IO(IOArrayie){-# INLINEnewIOArray#-}newIOArrayluinitial=stToIO$do{marr<-newSTArrayluinitial;return(IOArraymarr)}-- | Read a value from an 'IOArray'unsafeReadIOArray::IOArrayie->Int->IOe{-# INLINEunsafeReadIOArray#-}unsafeReadIOArray(IOArraymarr)i=stToIO(unsafeReadSTArraymarri)-- | Write a new value into an 'IOArray'unsafeWriteIOArray::IOArrayie->Int->e->IO(){-# INLINEunsafeWriteIOArray#-}unsafeWriteIOArray(IOArraymarr)ie=stToIO(unsafeWriteSTArraymarrie)-- | Read a value from an 'IOArray'readIOArray::Ixi=>IOArrayie->i->IOereadIOArray(IOArraymarr)i=stToIO(readSTArraymarri)-- | Write a new value into an 'IOArray'writeIOArray::Ixi=>IOArrayie->i->e->IO()writeIOArray(IOArraymarr)ie=stToIO(writeSTArraymarrie){-# INLINEboundsIOArray#-}boundsIOArray::IOArrayie->(i,i)boundsIOArray(IOArraymarr)=boundsSTArraymarr
[8]ページ先頭