-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Arrays where the index type is a function of the shape type
--
-- Arrays from the basic array package are already very powerful
-- compared with arrays in other languages. They may have any number of
-- dimensions, are type safe and defined in a uniform way using the Ix
-- class with free choice of the lower bounds (0, 1, or whatever you
-- like).
--
-- This package goes one step further: The shape and the index type are
-- different, but the index type is a type function of the shape type.
-- This offers much more flexibility and type safety.
--
-- Some examples are:
--
--
-- - Range: Allow dynamic choice of lower and upper array
-- bounds such as in the Arrays from the array package.
-- You can combine it with other shapes in other dimensions. It allows
-- you to describe the bounds of each dimension individually.
-- - Shifted: Describe array bounds by start index and length.
-- It is sometimes more natural to use these parameters. E.g. a
-- non-negative index type like Word cannot represent -1
-- and thus cannot encode an empty range starting with index
-- 0.
-- - Square: An 2D array where both dimensions always have
-- equal size.
-- - ZeroBased, OneBased: Arrays with fixed lower bound,
-- either 0 or 1, respectively.
-- - (:+:): The Append type constructor allows to respresent
-- block arrays, e.g. block matrices.
-- - Arrays with indices like LT, EQ, GT and dummy
-- shape.
--
--
-- The lapack package defines even more fancy shapes like tall
-- rectangular matrices, triangular matrices and banded matrices.
@package comfort-array
@version 0.1.2
module Data.Array.Comfort.Shape
class C sh
size :: C sh => sh -> Int
uncheckedSize :: C sh => sh -> Int
class C sh => Indexed sh where {
type family Index sh :: *;
}
indices :: Indexed sh => sh -> [Index sh]
offset :: Indexed sh => sh -> Index sh -> Int
uncheckedOffset :: Indexed sh => sh -> Index sh -> Int
inBounds :: Indexed sh => sh -> Index sh -> Bool
sizeOffset :: Indexed sh => sh -> Index sh -> (Int, Int)
uncheckedSizeOffset :: Indexed sh => sh -> Index sh -> (Int, Int)
class Indexed sh => InvIndexed sh
-- | It should hold indexFromOffset sh k == indices sh !! k, but
-- indexFromOffset should generally be faster.
indexFromOffset :: InvIndexed sh => sh -> Int -> Index sh
uncheckedIndexFromOffset :: InvIndexed sh => sh -> Int -> Index sh
-- | ZeroBased denotes a range starting at zero and has a certain
-- length.
newtype ZeroBased n
ZeroBased :: n -> ZeroBased n
[zeroBasedSize] :: ZeroBased n -> n
-- | OneBased denotes a range starting at one and has a certain
-- length.
newtype OneBased n
OneBased :: n -> OneBased n
[oneBasedSize] :: OneBased n -> n
-- | Range denotes an inclusive range like those of the Haskell 98
-- standard Array type from the array package. E.g. the
-- shape type (Range Int32, Range Int64) is equivalent to the ix
-- type (Int32, Int64) for Arrays.
data Range n
Range :: n -> Range n
[rangeFrom, rangeTo] :: Range n -> n
-- | Shifted denotes a range defined by the start index and the
-- length.
data Shifted n
Shifted :: n -> Shifted n
[shiftedOffset, shiftedSize] :: Shifted n -> n
data sh0 (:+:) sh1
(:+:) :: sh0 -> sh1 -> (:+:) sh0 sh1
instance (GHC.Show.Show sh0, GHC.Show.Show sh1) => GHC.Show.Show (sh0 Data.Array.Comfort.Shape.:+: sh1)
instance (GHC.Classes.Eq sh0, GHC.Classes.Eq sh1) => GHC.Classes.Eq (sh0 Data.Array.Comfort.Shape.:+: sh1)
instance GHC.Show.Show n => GHC.Show.Show (Data.Array.Comfort.Shape.Shifted n)
instance GHC.Classes.Eq n => GHC.Classes.Eq (Data.Array.Comfort.Shape.Shifted n)
instance GHC.Show.Show n => GHC.Show.Show (Data.Array.Comfort.Shape.Range n)
instance GHC.Classes.Eq n => GHC.Classes.Eq (Data.Array.Comfort.Shape.Range n)
instance GHC.Show.Show n => GHC.Show.Show (Data.Array.Comfort.Shape.OneBased n)
instance GHC.Classes.Eq n => GHC.Classes.Eq (Data.Array.Comfort.Shape.OneBased n)
instance GHC.Show.Show n => GHC.Show.Show (Data.Array.Comfort.Shape.ZeroBased n)
instance GHC.Classes.Eq n => GHC.Classes.Eq (Data.Array.Comfort.Shape.ZeroBased n)
instance (Data.Array.Comfort.Shape.C sh0, Data.Array.Comfort.Shape.C sh1) => Data.Array.Comfort.Shape.C (sh0 Data.Array.Comfort.Shape.:+: sh1)
instance (Data.Array.Comfort.Shape.Indexed sh0, Data.Array.Comfort.Shape.Indexed sh1) => Data.Array.Comfort.Shape.Indexed (sh0 Data.Array.Comfort.Shape.:+: sh1)
instance (Data.Array.Comfort.Shape.InvIndexed sh0, Data.Array.Comfort.Shape.InvIndexed sh1) => Data.Array.Comfort.Shape.InvIndexed (sh0 Data.Array.Comfort.Shape.:+: sh1)
instance GHC.Real.Integral n => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.ZeroBased n)
instance GHC.Real.Integral n => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.OneBased n)
instance GHC.Base.Functor Data.Array.Comfort.Shape.Shifted
instance GHC.Real.Integral n => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.Shifted n)
instance GHC.Real.Integral n => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.Shifted n)
instance GHC.Real.Integral n => Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.Shifted n)
instance Foreign.Storable.Storable n => Foreign.Storable.Storable (Data.Array.Comfort.Shape.Shifted n)
instance GHC.Base.Functor Data.Array.Comfort.Shape.Range
instance GHC.Arr.Ix n => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.Range n)
instance GHC.Arr.Ix n => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.Range n)
instance GHC.Arr.Ix n => Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.Range n)
instance Foreign.Storable.Storable n => Foreign.Storable.Storable (Data.Array.Comfort.Shape.Range n)
instance GHC.Base.Functor Data.Array.Comfort.Shape.OneBased
instance Foreign.Storable.Storable n => Foreign.Storable.Storable (Data.Array.Comfort.Shape.OneBased n)
instance GHC.Real.Integral n => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.OneBased n)
instance GHC.Real.Integral n => Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.OneBased n)
instance GHC.Base.Functor Data.Array.Comfort.Shape.ZeroBased
instance Foreign.Storable.Storable n => Foreign.Storable.Storable (Data.Array.Comfort.Shape.ZeroBased n)
instance GHC.Real.Integral n => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.ZeroBased n)
instance GHC.Real.Integral n => Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.ZeroBased n)
instance Data.Array.Comfort.Shape.InvIndexed ()
instance (Data.Array.Comfort.Shape.InvIndexed sh0, Data.Array.Comfort.Shape.InvIndexed sh1) => Data.Array.Comfort.Shape.InvIndexed (sh0, sh1)
instance (Data.Array.Comfort.Shape.InvIndexed sh0, Data.Array.Comfort.Shape.InvIndexed sh1, Data.Array.Comfort.Shape.InvIndexed sh2) => Data.Array.Comfort.Shape.InvIndexed (sh0, sh1, sh2)
instance Data.Array.Comfort.Shape.Indexed ()
instance (Data.Array.Comfort.Shape.Indexed sh0, Data.Array.Comfort.Shape.Indexed sh1) => Data.Array.Comfort.Shape.Indexed (sh0, sh1)
instance (Data.Array.Comfort.Shape.Indexed sh0, Data.Array.Comfort.Shape.Indexed sh1, Data.Array.Comfort.Shape.Indexed sh2) => Data.Array.Comfort.Shape.Indexed (sh0, sh1, sh2)
instance Data.Array.Comfort.Shape.C ()
instance (Data.Array.Comfort.Shape.C sh0, Data.Array.Comfort.Shape.C sh1) => Data.Array.Comfort.Shape.C (sh0, sh1)
instance (Data.Array.Comfort.Shape.C sh0, Data.Array.Comfort.Shape.C sh1, Data.Array.Comfort.Shape.C sh2) => Data.Array.Comfort.Shape.C (sh0, sh1, sh2)
module Data.Array.Comfort.Boxed
data Array sh a
shape :: Array sh a -> sh
(!) :: (Indexed sh) => Array sh a -> Index sh -> a
infixl 9 !
toList :: (C sh) => Array sh a -> [a]
fromList :: (C sh) => sh -> [a] -> Array sh a
vectorFromList :: [a] -> Array (ZeroBased Int) a
map :: (C sh) => (a -> b) -> Array sh a -> Array sh b
module Data.Array.Comfort.Shape.Test
tests :: (InvIndexed sh, Show sh, Index sh ~ ix, Eq ix, Show ix) => Gen sh -> [(String, Property)]
module Data.Array.Comfort.Storable.Internal
data Array sh a
Array :: sh -> ForeignPtr a -> Array sh a
[shape] :: Array sh a -> sh
[buffer] :: Array sh a -> ForeignPtr a
reshape :: sh1 -> Array sh0 a -> Array sh1 a
mapShape :: (sh0 -> sh1) -> Array sh0 a -> Array sh1 a
(!) :: (Indexed sh, Storable a) => Array sh a -> Index sh -> a
infixl 9 !
unsafeCreate :: (C sh, Storable a) => sh -> (Ptr a -> IO ()) -> Array sh a
unsafeCreateWithSize :: (C sh, Storable a) => sh -> (Int -> Ptr a -> IO ()) -> Array sh a
unsafeCreateWithSizeAndResult :: (C sh, Storable a) => sh -> (Int -> Ptr a -> IO b) -> (Array sh a, b)
toList :: (C sh, Storable a) => Array sh a -> [a]
fromList :: (C sh, Storable a) => sh -> [a] -> Array sh a
vectorFromList :: (Storable a) => [a] -> Array (ZeroBased Int) a
map :: (C sh, Storable a, Storable b) => (a -> b) -> Array sh a -> Array sh b
copyIO :: (C sh, Storable a) => Array sh a -> IO (Array sh a)
(//) :: (Indexed sh, Storable a) => Array sh a -> [(Index sh, a)] -> Array sh a
createIO :: (C sh, Storable a) => sh -> (Ptr a -> IO ()) -> IO (Array sh a)
createWithSizeIO :: (C sh, Storable a) => sh -> (Int -> Ptr a -> IO ()) -> IO (Array sh a)
createWithSizeAndResultIO :: (C sh, Storable a) => sh -> (Int -> Ptr a -> IO b) -> IO (Array sh a, b)
showIO :: (C sh, Show sh, Storable a, Show a) => Array sh a -> IO String
readIO :: (Indexed sh, Storable a) => Array sh a -> Index sh -> IO a
toListIO :: (C sh, Storable a) => Array sh a -> IO [a]
fromListIO :: (C sh, Storable a) => sh -> [a] -> IO (Array sh a)
vectorFromListIO :: (Storable a) => [a] -> IO (Array (ZeroBased Int) a)
instance (Data.Array.Comfort.Shape.C sh, GHC.Show.Show sh, Foreign.Storable.Storable a, GHC.Show.Show a) => GHC.Show.Show (Data.Array.Comfort.Storable.Internal.Array sh a)
module Data.Array.Comfort.Storable
data Array sh a
shape :: Array sh a -> sh
(!) :: (Indexed sh, Storable a) => Array sh a -> Index sh -> a
infixl 9 !
toList :: (C sh, Storable a) => Array sh a -> [a]
fromList :: (C sh, Storable a) => sh -> [a] -> Array sh a
vectorFromList :: (Storable a) => [a] -> Array (ZeroBased Int) a
map :: (C sh, Storable a, Storable b) => (a -> b) -> Array sh a -> Array sh b
(//) :: (Indexed sh, Storable a) => Array sh a -> [(Index sh, a)] -> Array sh a
module Data.Array.Comfort.Storable.Mutable
data Array sh a
shape :: Array sh a -> sh
read :: (Indexed sh, Storable a) => Array sh a -> Index sh -> IO a
write :: (Indexed sh, Storable a) => Array sh a -> Index sh -> a -> IO ()
thaw :: (Indexed sh, Storable a) => Array sh a -> IO (Array sh a)
freeze :: (Indexed sh, Storable a) => Array sh a -> IO (Array sh a)