Commit 3c44399a authored by sof's avatar sof

[project @ 1997-03-14 05:24:00 by sof]

New interfaces
parent 1401a028
%
% (c) The AQUA Project, Glasgow University, 1994-1997
%
\section[ByteArray]{The @ByteArray@ interface}
Immutable, read-only chunks of bytes, the @ByteArray@ collects
together the definitions in @ArrBase@ and exports them as one.
\begin{code}
module ByteArray
(
ByteArray(..), -- not abstract, for now.
Ix,
--Indexing of ordinary @Arrays@ is standard Haskell and isn't defined here.
indexCharArray, --:: Ix ix => ByteArray ix -> ix -> Char
indexIntArray, --:: Ix ix => ByteArray ix -> ix -> Int
indexAddrArray, --:: Ix ix => ByteArray ix -> ix -> Addr
indexFloatArray, --:: Ix ix => ByteArray ix -> ix -> Float
indexDoubleArray, --:: Ix ix => ByteArray ix -> ix -> Double
--Indexing off @Addrs@ is similar, and therefore given here.
indexCharOffAddr, --:: Addr -> Int -> Char
indexIntOffAddr, --:: Addr -> Int -> Int
indexAddrOffAddr, --:: Addr -> Int -> Addr
indexFloatOffAddr, --:: Addr -> Int -> Float
indexDoubleOffAddr, --:: Addr -> Int -> Double
Addr,
Word
) where
import ArrBase
import Ix
import PrelBase (Addr, Word)
\end{code}
%
% (c) The AQUA Project, Glasgow University, 1994-1996
%
\section[GlaExts]{The @GlaExts@ interface}
The @GlaExts@ packages up various Glasgow extensions and
exports them all through one interface. The Idea being that
a Haskell program using a Glasgow extension doesn't have to
selective import of obscure/likely-to-move (believe me, we
really like to move functions around for the prelude bits!)
GHC interfaces - instead import the GlaExts rag bag and you should be away!
\begin{code}
module GlaExts
(
-- From module STBase, the PrimIO monad
-- (an instance of ST):
PrimIO,
ST, RealWorld,
module Monad, -- ST is an instance
fixPrimIO, unsafePerformPrimIO, unsafeInterleavePrimIO,
returnPrimIO, thenPrimIO, seqPrimIO,
listPrimIO, mapPrimIO, mapAndUnzipPrimIO,
-- operations for interfacing IO and ST/PrimIO
--
stToIO, --:: ST RealWorld a -> IO a
primIOToIO, --:: PrimIO a -> IO a
ioToST, --:: IO a -> ST RealWorld a
ioToPrimIO, --:: IO a -> PrimIO a
thenIO_Prim, -- :: PrimIO a -> (a -> IO b) -> IO b
-- Everything from module ByteArray:
module ByteArray,
-- Same for Mutable(Byte)Array interface:
module MutableArray,
-- the representation of some basic types:
Int(..),Addr(..),Word(..),Float(..),Double(..),Integer(..),
-- misc bits
trace,
-- and finally, all the unboxed primops of GHC!
module GHC
) where
import GHC
import STBase
import PrelBase
import ByteArray
import MutableArray
import Monad
import IOBase
\end{code}
%
% (c) The AQUA Project, Glasgow University, 1994-1996
%
\section[MutVar]{Mutable variables}
Mutable variables, for the @IO@ monad.
\begin{code}
module MutVar
(
MutVar, -- abstract
newVar, -- :: a -> IO (MutVar a)
readVar, -- :: MutVar a -> IO a
writeVar, -- :: MutVar a -> a -> IO ()
sameVar -- :: MutVar a -> MutVar a -> Bool
) where
import qualified ST
import qualified ArrBase
import IOBase ( IO , stToIO )
import GHC (RealWorld)
\end{code}
\begin{code}
newtype MutVar a = MutVar (ArrBase.MutableVar RealWorld a)
newVar :: a -> IO (MutVar a)
newVar v = stToIO (ST.newVar v) >>= \ var -> return (MutVar var)
readVar :: MutVar a -> IO a
readVar (MutVar var) = stToIO (ST.readVar var)
writeVar :: MutVar a -> a -> IO ()
writeVar (MutVar var) v = stToIO (ST.writeVar var v)
sameVar :: MutVar a -> MutVar a -> Bool
sameVar (MutVar var1) (MutVar var2) = ST.sameVar var1 var2
\end{code}
%
% (c) The AQUA Project, Glasgow University, 1997
%
\section[MutableArray]{The @MutableArray@ interface}
Mutable (byte)arrays interface, re-exports type types and operations
over them from @ArrBase@. Have to be used in conjunction with
@ST@.
\begin{code}
module MutableArray
(
MutableArray(..), -- not abstract
MutableByteArray(..),
ST,
Ix,
-- Creators:
newArray, -- :: Ix ix => (ix,ix) -> elt -> ST s (MutableArray s ix elt)
newCharArray,
newAddrArray,
newIntArray,
newFloatArray,
newDoubleArray, -- :: Ix ix => (ix,ix) -> ST s (MutableByteArray s ix)
boundsOfArray, -- :: Ix ix => MutableArray s ix elt -> (ix, ix)
boundsOfByteArray, -- :: Ix ix => MutableByteArray s ix -> (ix, ix)
readArray, -- :: Ix ix => MutableArray s ix elt -> ix -> ST s elt
readCharArray, -- :: Ix ix => MutableByteArray s ix -> ix -> ST s Char
readIntArray, -- :: Ix ix => MutableByteArray s ix -> ix -> ST s Int
readAddrArray, -- :: Ix ix => MutableByteArray s ix -> ix -> ST s Addr
readFloatArray, -- :: Ix ix => MutableByteArray s ix -> ix -> ST s Float
readDoubleArray, -- :: Ix ix => MutableByteArray s ix -> ix -> ST s Double
writeArray, -- :: Ix ix => MutableArray s ix elt -> ix -> elt -> ST s ()
writeCharArray, -- :: Ix ix => MutableByteArray s ix -> ix -> Char -> ST s ()
writeIntArray, -- :: Ix ix => MutableByteArray s ix -> ix -> Int -> ST s ()
writeAddrArray, -- :: Ix ix => MutableByteArray s ix -> ix -> Addr -> ST s ()
writeFloatArray, -- :: Ix ix => MutableByteArray s ix -> ix -> Float -> ST s ()
writeDoubleArray, -- :: Ix ix => MutableByteArray s ix -> ix -> Double -> ST s ()
freezeArray, -- :: Ix ix => MutableArray s ix elt -> ST s (Array ix elt)
freezeCharArray, -- :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix)
freezeIntArray, -- :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix)
freezeAddrArray, -- :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix)
freezeFloatArray, -- :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix)
freezeDoubleArray, -- :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix)
unsafeFreezeArray, -- :: Ix ix => MutableArray s ix elt -> ST s (Array ix elt)
unsafeFreezeByteArray, -- :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix)
thawArray -- :: Ix ix => Array ix elt -> ST s (MutableArray s ix elt)
) where
import ArrBase
import ST
import Ix
\end{code}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment