Data.Array.IO.Safe

array-0.5.2.0: Mutable and immutable arrays

Copyright | (c) The University of Glasgow 2001
License | BSD-style (see the file libraries/base/LICENSE)
Maintainer | libraries@haskell.org
Stability | experimental
Portability | non-portable (uses Data.Array.MArray)
Safe Haskell | Trustworthy
Language | Haskell2010

Data.Array.IO.Safe

Contents

- `IO` arrays with boxed elements
- `IO` arrays with unboxed elements
- Overloaded mutable array interface
- Doing I/O with `IOUArray`s

Description

Mutable boxed and unboxed arrays in the IO monad. . Safe API only of Data.Array.IO.

Since: array-0.4.0.0

Synopsis

- data IOArray i e
- data IOUArray i e
- module Data.Array.MArray.Safe
- hGetArray :: Handle -> IOUArray Int Word8 -> Int -> IO Int
- hPutArray :: Handle -> IOUArray Int Word8 -> Int -> IO ()

# `IO` arrays with boxed elements

data IOArray i e Source #

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.

Instances

MArray IOArray e IO # |
Instance details Defined in Data.Array.Base Methods getBounds :: Ix i => IOArray i e -> IO (i, i) # getNumElements :: Ix i => IOArray i e -> IO Int newArray :: Ix i => (i, i) -> e -> IO (IOArray i e) # newArray_ :: Ix i => (i, i) -> IO (IOArray i e) # unsafeNewArray_ :: Ix i => (i, i) -> IO (IOArray i e) unsafeRead :: Ix i => IOArray i e -> Int -> IO e unsafeWrite :: Ix i => IOArray i e -> Int -> e -> IO ()
Eq (IOArray i e) | Since: base-4.1.0.0
Instance details Defined in GHC.IOArray Methods (==) :: IOArray i e -> IOArray i e -> Bool # (/=) :: IOArray i e -> IOArray i e -> Bool #

# `IO` arrays with unboxed elements

data IOUArray i e #

Mutable, unboxed, strict arrays 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. Only certain element types are supported: see Data.Array.MArray for a list of instances.

Instances

MArray IOUArray Bool IO # |
Instance details Defined in Data.Array.IO.Internals Methods getBounds :: Ix i => IOUArray i Bool -> IO (i, i) # getNumElements :: Ix i => IOUArray i Bool -> IO Int newArray :: Ix i => (i, i) -> Bool -> IO (IOUArray i Bool) # newArray_ :: Ix i => (i, i) -> IO (IOUArray i Bool) # unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Bool) unsafeRead :: Ix i => IOUArray i Bool -> Int -> IO Bool unsafeWrite :: Ix i => IOUArray i Bool -> Int -> Bool -> IO ()
MArray IOUArray Char IO # |
Instance details Defined in Data.Array.IO.Internals Methods getBounds :: Ix i => IOUArray i Char -> IO (i, i) # getNumElements :: Ix i => IOUArray i Char -> IO Int newArray :: Ix i => (i, i) -> Char -> IO (IOUArray i Char) # newArray_ :: Ix i => (i, i) -> IO (IOUArray i Char) # unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Char) unsafeRead :: Ix i => IOUArray i Char -> Int -> IO Char unsafeWrite :: Ix i => IOUArray i Char -> Int -> Char -> IO ()
MArray IOUArray Double IO # |
Instance details Defined in Data.Array.IO.Internals Methods getBounds :: Ix i => IOUArray i Double -> IO (i, i) # getNumElements :: Ix i => IOUArray i Double -> IO Int newArray :: Ix i => (i, i) -> Double -> IO (IOUArray i Double) # newArray_ :: Ix i => (i, i) -> IO (IOUArray i Double) # unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Double) unsafeRead :: Ix i => IOUArray i Double -> Int -> IO Double unsafeWrite :: Ix i => IOUArray i Double -> Int -> Double -> IO ()
MArray IOUArray Float IO # |
Instance details Defined in Data.Array.IO.Internals Methods getBounds :: Ix i => IOUArray i Float -> IO (i, i) # getNumElements :: Ix i => IOUArray i Float -> IO Int newArray :: Ix i => (i, i) -> Float -> IO (IOUArray i Float) # newArray_ :: Ix i => (i, i) -> IO (IOUArray i Float) # unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Float) unsafeRead :: Ix i => IOUArray i Float -> Int -> IO Float unsafeWrite :: Ix i => IOUArray i Float -> Int -> Float -> IO ()
MArray IOUArray Int IO # |
Instance details Defined in Data.Array.IO.Internals Methods getBounds :: Ix i => IOUArray i Int -> IO (i, i) # getNumElements :: Ix i => IOUArray i Int -> IO Int newArray :: Ix i => (i, i) -> Int -> IO (IOUArray i Int) # newArray_ :: Ix i => (i, i) -> IO (IOUArray i Int) # unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Int) unsafeRead :: Ix i => IOUArray i Int -> Int -> IO Int unsafeWrite :: Ix i => IOUArray i Int -> Int -> Int -> IO ()
MArray IOUArray Int8 IO # |
Instance details Defined in Data.Array.IO.Internals Methods getBounds :: Ix i => IOUArray i Int8 -> IO (i, i) # getNumElements :: Ix i => IOUArray i Int8 -> IO Int newArray :: Ix i => (i, i) -> Int8 -> IO (IOUArray i Int8) # newArray_ :: Ix i => (i, i) -> IO (IOUArray i Int8) # unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Int8) unsafeRead :: Ix i => IOUArray i Int8 -> Int -> IO Int8 unsafeWrite :: Ix i => IOUArray i Int8 -> Int -> Int8 -> IO ()
MArray IOUArray Int16 IO # |
Instance details Defined in Data.Array.IO.Internals Methods getBounds :: Ix i => IOUArray i Int16 -> IO (i, i) # getNumElements :: Ix i => IOUArray i Int16 -> IO Int newArray :: Ix i => (i, i) -> Int16 -> IO (IOUArray i Int16) # newArray_ :: Ix i => (i, i) -> IO (IOUArray i Int16) # unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Int16) unsafeRead :: Ix i => IOUArray i Int16 -> Int -> IO Int16 unsafeWrite :: Ix i => IOUArray i Int16 -> Int -> Int16 -> IO ()
MArray IOUArray Int32 IO # |
Instance details Defined in Data.Array.IO.Internals Methods getBounds :: Ix i => IOUArray i Int32 -> IO (i, i) # getNumElements :: Ix i => IOUArray i Int32 -> IO Int newArray :: Ix i => (i, i) -> Int32 -> IO (IOUArray i Int32) # newArray_ :: Ix i => (i, i) -> IO (IOUArray i Int32) # unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Int32) unsafeRead :: Ix i => IOUArray i Int32 -> Int -> IO Int32 unsafeWrite :: Ix i => IOUArray i Int32 -> Int -> Int32 -> IO ()
MArray IOUArray Int64 IO # |
Instance details Defined in Data.Array.IO.Internals Methods getBounds :: Ix i => IOUArray i Int64 -> IO (i, i) # getNumElements :: Ix i => IOUArray i Int64 -> IO Int newArray :: Ix i => (i, i) -> Int64 -> IO (IOUArray i Int64) # newArray_ :: Ix i => (i, i) -> IO (IOUArray i Int64) # unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Int64) unsafeRead :: Ix i => IOUArray i Int64 -> Int -> IO Int64 unsafeWrite :: Ix i => IOUArray i Int64 -> Int -> Int64 -> IO ()
MArray IOUArray Word IO # |
Instance details Defined in Data.Array.IO.Internals Methods getBounds :: Ix i => IOUArray i Word -> IO (i, i) # getNumElements :: Ix i => IOUArray i Word -> IO Int newArray :: Ix i => (i, i) -> Word -> IO (IOUArray i Word) # newArray_ :: Ix i => (i, i) -> IO (IOUArray i Word) # unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Word) unsafeRead :: Ix i => IOUArray i Word -> Int -> IO Word unsafeWrite :: Ix i => IOUArray i Word -> Int -> Word -> IO ()
MArray IOUArray Word8 IO # |
Instance details Defined in Data.Array.IO.Internals Methods getBounds :: Ix i => IOUArray i Word8 -> IO (i, i) # getNumElements :: Ix i => IOUArray i Word8 -> IO Int newArray :: Ix i => (i, i) -> Word8 -> IO (IOUArray i Word8) # newArray_ :: Ix i => (i, i) -> IO (IOUArray i Word8) # unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Word8) unsafeRead :: Ix i => IOUArray i Word8 -> Int -> IO Word8 unsafeWrite :: Ix i => IOUArray i Word8 -> Int -> Word8 -> IO ()
MArray IOUArray Word16 IO # |
Instance details Defined in Data.Array.IO.Internals Methods getBounds :: Ix i => IOUArray i Word16 -> IO (i, i) # getNumElements :: Ix i => IOUArray i Word16 -> IO Int newArray :: Ix i => (i, i) -> Word16 -> IO (IOUArray i Word16) # newArray_ :: Ix i => (i, i) -> IO (IOUArray i Word16) # unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Word16) unsafeRead :: Ix i => IOUArray i Word16 -> Int -> IO Word16 unsafeWrite :: Ix i => IOUArray i Word16 -> Int -> Word16 -> IO ()
MArray IOUArray Word32 IO # |
Instance details Defined in Data.Array.IO.Internals Methods getBounds :: Ix i => IOUArray i Word32 -> IO (i, i) # getNumElements :: Ix i => IOUArray i Word32 -> IO Int newArray :: Ix i => (i, i) -> Word32 -> IO (IOUArray i Word32) # newArray_ :: Ix i => (i, i) -> IO (IOUArray i Word32) # unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Word32) unsafeRead :: Ix i => IOUArray i Word32 -> Int -> IO Word32 unsafeWrite :: Ix i => IOUArray i Word32 -> Int -> Word32 -> IO ()
MArray IOUArray Word64 IO # |
Instance details Defined in Data.Array.IO.Internals Methods getBounds :: Ix i => IOUArray i Word64 -> IO (i, i) # getNumElements :: Ix i => IOUArray i Word64 -> IO Int newArray :: Ix i => (i, i) -> Word64 -> IO (IOUArray i Word64) # newArray_ :: Ix i => (i, i) -> IO (IOUArray i Word64) # unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Word64) unsafeRead :: Ix i => IOUArray i Word64 -> Int -> IO Word64 unsafeWrite :: Ix i => IOUArray i Word64 -> Int -> Word64 -> IO ()
MArray IOUArray (StablePtr a) IO # |
Instance details Defined in Data.Array.IO.Internals Methods getBounds :: Ix i => IOUArray i (StablePtr a) -> IO (i, i) # getNumElements :: Ix i => IOUArray i (StablePtr a) -> IO Int newArray :: Ix i => (i, i) -> StablePtr a -> IO (IOUArray i (StablePtr a)) # newArray_ :: Ix i => (i, i) -> IO (IOUArray i (StablePtr a)) # unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i (StablePtr a)) unsafeRead :: Ix i => IOUArray i (StablePtr a) -> Int -> IO (StablePtr a) unsafeWrite :: Ix i => IOUArray i (StablePtr a) -> Int -> StablePtr a -> IO ()
MArray IOUArray (Ptr a) IO # |
Instance details Defined in Data.Array.IO.Internals Methods getBounds :: Ix i => IOUArray i (Ptr a) -> IO (i, i) # getNumElements :: Ix i => IOUArray i (Ptr a) -> IO Int newArray :: Ix i => (i, i) -> Ptr a -> IO (IOUArray i (Ptr a)) # newArray_ :: Ix i => (i, i) -> IO (IOUArray i (Ptr a)) # unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i (Ptr a)) unsafeRead :: Ix i => IOUArray i (Ptr a) -> Int -> IO (Ptr a) unsafeWrite :: Ix i => IOUArray i (Ptr a) -> Int -> Ptr a -> IO ()
MArray IOUArray (FunPtr a) IO # |
Instance details Defined in Data.Array.IO.Internals Methods getBounds :: Ix i => IOUArray i (FunPtr a) -> IO (i, i) # getNumElements :: Ix i => IOUArray i (FunPtr a) -> IO Int newArray :: Ix i => (i, i) -> FunPtr a -> IO (IOUArray i (FunPtr a)) # newArray_ :: Ix i => (i, i) -> IO (IOUArray i (FunPtr a)) # unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i (FunPtr a)) unsafeRead :: Ix i => IOUArray i (FunPtr a) -> Int -> IO (FunPtr a) unsafeWrite :: Ix i => IOUArray i (FunPtr a) -> Int -> FunPtr a -> IO ()
Eq (IOUArray i e) # |
Instance details Defined in Data.Array.IO.Internals Methods (==) :: IOUArray i e -> IOUArray i e -> Bool # (/=) :: IOUArray i e -> IOUArray i e -> Bool #

# Overloaded mutable array interface

module Data.Array.MArray.Safe

# Doing I/O with `IOUArray`s

hGetArray #

Arguments

:: Handle | Handle to read from
-> IOUArray Int Word8 | Array in which to place the values
-> Int | Number of `Word8`s to read
-> IO Int | Returns: the number of `Word8`s actually read, which might be smaller than the number requested if the end of file was reached.

Reads a number of `Word8`s from the specified `Handle` directly into an array.

hPutArray #

Arguments

:: Handle | Handle to write to
-> IOUArray Int Word8 | Array to write from
-> Int | Number of `Word8`s to write
-> IO () |

Writes an array of `Word8` to the specified `Handle`.