-- 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: -- -- -- -- With our Array type you can perform -- -- -- -- See also comfort-graph for a Graph data structure, with -- non-Int node identifiers and flexible edge types. @package comfort-array @version 0.5 module Data.Array.Comfort.Shape class C sh size :: 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 unifiedOffset :: (Indexed sh, Checking check) => sh -> Index sh -> Result check Int inBounds :: Indexed sh => sh -> Index sh -> Bool sizeOffset :: Indexed sh => sh -> (Int, Index sh -> Int) uncheckedSizeOffset :: Indexed sh => sh -> (Int, Index sh -> Int) unifiedSizeOffset :: (Indexed sh, Checking check) => sh -> (Int, Index sh -> Result check 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 unifiedIndexFromOffset :: (InvIndexed sh, Checking check) => sh -> Int -> Result check (Index sh) messageIndexFromOffset :: String -> Int -> String assertIndexFromOffset :: Checking check => String -> Int -> Bool -> Result check () class (C sh, Eq sh) => Static sh static :: Static sh => sh requireCheck :: CheckSingleton check -> Result check a -> Result check a data CheckSingleton check [Checked] :: CheckSingleton Checked [Unchecked] :: CheckSingleton Unchecked class Checking check where { data family Result check a; } switchCheck :: Checking check => f Checked -> f Unchecked -> f check runChecked :: String -> Result Checked a -> a runUnchecked :: Result Unchecked a -> a assert :: Checking check => String -> Bool -> Result check () throwOrError :: Checking check => String -> Result check a data Zero Zero :: Zero -- | ZeroBased denotes a range starting at zero and has a certain -- length. -- --
--   >>> Shape.indices (Shape.ZeroBased (7::Int))
--   [0,1,2,3,4,5,6]
--   
newtype ZeroBased n ZeroBased :: n -> ZeroBased n [zeroBasedSize] :: ZeroBased n -> n zeroBasedSplit :: Real n => n -> ZeroBased n -> ZeroBased n ::+ ZeroBased n -- | OneBased denotes a range starting at one and has a certain -- length. -- --
--   >>> Shape.indices (Shape.OneBased (7::Int))
--   [1,2,3,4,5,6,7]
--   
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. -- --
--   >>> Shape.indices (Shape.Range (-5) (5::Int))
--   [-5,-4,-3,-2,-1,0,1,2,3,4,5]
--   
--   >>> Shape.indices (Shape.Range (-1,-1) (1::Int,1::Int))
--   [(-1,-1),(-1,0),(-1,1),(0,-1),(0,0),(0,1),(1,-1),(1,0),(1,1)]
--   
data Range n Range :: n -> Range n [rangeFrom, rangeTo] :: Range n -> n -- | Shifted denotes a range defined by the start index and the -- length. -- --
--   >>> Shape.indices (Shape.Shifted (-4) (8::Int))
--   [-4,-3,-2,-1,0,1,2,3]
--   
data Shifted n Shifted :: n -> Shifted n [shiftedOffset, shiftedSize] :: Shifted n -> n -- | Enumeration denotes a shape of fixed size that is defined by -- Enum and Bounded methods. For correctness it is -- necessary that the Enum and Bounded instances are -- properly implemented. Automatically derived instances are fine. -- --
--   >>> Shape.indices (Shape.Enumeration :: Shape.Enumeration Ordering)
--   [LT,EQ,GT]
--   
data Enumeration n Enumeration :: Enumeration n -- | This data type wraps another array shape. Its index type is a wrapped -- Int. The advantages are: No conversion forth and back -- Int and Index sh. You can convert once using -- deferIndex and revealIndex whenever you need your -- application specific index type. No need for e.g. Storable (Index -- sh), because Int is already Storable. You get -- Indexed and InvIndexed instances without the need for an -- Index type. The disadvantage is: A deferred index should be -- bound to a specific shape, but this is not checked. That is, you may -- obtain a deferred index for one shape and accidentally abuse it for -- another shape without a warning. -- -- Example: -- --
--   >>> :{
--   let sh2 = (Shape.ZeroBased (2::Int), Shape.ZeroBased (2::Int)) in
--   let sh3 = (Shape.ZeroBased (3::Int), Shape.ZeroBased (3::Int)) in
--   (Shape.offset sh3 $ Shape.indexFromOffset sh2 3,
--    Shape.offset (Shape.Deferred sh3) $
--      Shape.indexFromOffset (Shape.Deferred sh2) 3)
--   :}
--   (4,3)
--   
newtype Deferred sh Deferred :: sh -> Deferred sh -- | DeferredIndex has an Ord instance that is based on the -- storage order in memory. This way, you can put DeferredIndex -- values in a Set or use them as keys in a Map even if -- Index sh has no Ord instance. The downside is, that -- the ordering of DeferredIndex sh may differ from the one of -- Index sh. newtype DeferredIndex sh DeferredIndex :: Int -> DeferredIndex sh deferIndex :: (Indexed sh, Index sh ~ ix) => sh -> ix -> DeferredIndex sh revealIndex :: (InvIndexed sh, Index sh ~ ix) => sh -> DeferredIndex sh -> ix -- | Row-major composition of two dimensions. -- --
--   >>> Shape.indices (Shape.ZeroBased (3::Int) ::+ Shape.Range 'a' 'c')
--   [Left 0,Left 1,Left 2,Right 'a',Right 'b',Right 'c']
--   
data sh0 ::+ sh1 (::+) :: sh0 -> sh1 -> (::+) sh0 sh1 infixr 5 ::+ infixr 5 ::+ -- | Square is like a Cartesian product, but it is statically -- asserted that both dimension shapes match. -- --
--   >>> Shape.indices $ Shape.Square $ Shape.ZeroBased (3::Int)
--   [(0,0),(0,1),(0,2),(1,0),(1,1),(1,2),(2,0),(2,1),(2,2)]
--   
newtype Square sh Square :: sh -> Square sh [squareSize] :: Square sh -> sh -- | Cube is like a Cartesian product, but it is statically asserted -- that both dimension shapes match. -- --
--   >>> Shape.indices $ Shape.Cube $ Shape.ZeroBased (2::Int)
--   [(0,0,0),(0,0,1),(0,1,0),(0,1,1),(1,0,0),(1,0,1),(1,1,0),(1,1,1)]
--   
newtype Cube sh Cube :: sh -> Cube sh [cubeSize] :: Cube sh -> sh -- |
--   >>> Shape.indices $ Shape.Triangular Shape.Upper $ Shape.ZeroBased (3::Int)
--   [(0,0),(0,1),(0,2),(1,1),(1,2),(2,2)]
--   
--   >>> Shape.indices $ Shape.Triangular Shape.Lower $ Shape.ZeroBased (3::Int)
--   [(0,0),(1,0),(1,1),(2,0),(2,1),(2,2)]
--   
data Triangular part size Triangular :: part -> size -> Triangular part size [triangularPart] :: Triangular part size -> part [triangularSize] :: Triangular part size -> size data Lower Lower :: Lower data Upper Upper :: Upper type LowerTriangular = Triangular Lower type UpperTriangular = Triangular Upper lowerTriangular :: size -> LowerTriangular size upperTriangular :: size -> UpperTriangular size triangleSize :: Int -> Int triangleRoot :: Floating a => a -> a -- | Simplex is a generalization of Triangular to more than two -- dimensions. Indices are tuples of fixed size with elements ordered in -- ascending, strictly ascending, descending or strictly descending -- order. "Order" refers to the index order in indices. In order -- to avoid confusion we suggest that the order of indices is -- consistent with <=. -- -- Obviously, offset implements ranking and indexFromOffset -- implements unranking of combinations (in the combinatorial sense) with -- or without repetitions. -- --
--   >>> Shape.indices $ Shape.simplexAscending (replicate 3 Shape.AllDistinct) $ Shape.ZeroBased (4::Int)
--   [[0,1,2],[0,1,3],[0,2,3],[1,2,3]]
--   
--   >>> Shape.indices $ Shape.simplexAscending (replicate 3 Shape.SomeRepetitive) $ Shape.ZeroBased (3::Int)
--   [[0,0,0],[0,0,1],[0,0,2],[0,1,1],[0,1,2],[0,2,2],[1,1,1],[1,1,2],[1,2,2],[2,2,2]]
--   
--   >>> Shape.indices $ Shape.simplexAscending [Shape.Repetitive,Shape.Distinct,Shape.Repetitive] $ Shape.ZeroBased (4::Int)
--   [[0,0,1],[0,0,2],[0,0,3],[0,1,2],[0,1,3],[0,2,3],[1,1,2],[1,1,3],[1,2,3],[2,2,3]]
--   
--   >>> Shape.indices $ Shape.simplexAscending [Shape.Repetitive,Shape.Distinct,Shape.Distinct] $ Shape.ZeroBased (4::Int)
--   [[0,0,1],[0,0,2],[0,0,3],[0,1,2],[0,1,3],[0,2,3],[1,1,2],[1,1,3],[1,2,3],[2,2,3]]
--   
-- --
--   >>> Shape.indices $ Shape.simplexDescending (replicate 3 Shape.AllDistinct) $ Shape.ZeroBased (4::Int)
--   [[2,1,0],[3,1,0],[3,2,0],[3,2,1]]
--   
--   >>> Shape.indices $ Shape.simplexDescending (replicate 3 Shape.SomeRepetitive) $ Shape.ZeroBased (3::Int)
--   [[0,0,0],[1,0,0],[1,1,0],[1,1,1],[2,0,0],[2,1,0],[2,1,1],[2,2,0],[2,2,1],[2,2,2]]
--   
--   >>> Shape.indices $ Shape.simplexDescending [Shape.Repetitive,Shape.Distinct,Shape.Repetitive] $ Shape.ZeroBased (4::Int)
--   [[1,1,0],[2,1,0],[2,2,0],[2,2,1],[3,1,0],[3,2,0],[3,2,1],[3,3,0],[3,3,1],[3,3,2]]
--   
--   >>> Shape.indices $ Shape.simplexDescending [Shape.Repetitive,Shape.Distinct,Shape.Distinct] $ Shape.ZeroBased (4::Int)
--   [[1,1,0],[2,1,0],[2,2,0],[2,2,1],[3,1,0],[3,2,0],[3,2,1],[3,3,0],[3,3,1],[3,3,2]]
--   
data Simplex order coll f size Simplex :: SimplexOrder order -> f coll -> size -> Simplex order coll f size [simplexOrder] :: Simplex order coll f size -> SimplexOrder order [simplexDimension] :: Simplex order coll f size -> f coll [simplexSize] :: Simplex order coll f size -> size type SimplexAscending = Simplex Ascending simplexAscending :: f coll -> size -> SimplexAscending coll f size type SimplexDescending = Simplex Descending simplexDescending :: f coll -> size -> SimplexDescending coll f size data Ascending data Descending data SimplexOrder order [Ascending] :: SimplexOrder Ascending [Descending] :: SimplexOrder Descending class SimplexOrderC order data AllDistinct AllDistinct :: AllDistinct data SomeRepetitive SomeRepetitive :: SomeRepetitive data Collision Distinct :: Collision Repetitive :: Collision class CollisionC coll -- | Cyclic is a shape, where the indices wrap around at the array -- boundaries. E.g. -- --
--   let shape = Shape.Cyclic (10::Int) in Shape.offset shape (-1) == Shape.offset shape 9
--   
-- -- This also means that there are multiple indices that address the same -- array element. -- --
--   >>> Shape.indices (Shape.Cyclic (7::Int))
--   [0,1,2,3,4,5,6]
--   
newtype Cyclic n Cyclic :: n -> Cyclic n [cyclicSize] :: Cyclic n -> n instance GHC.Show.Show Data.Array.Comfort.Shape.Zero instance GHC.Classes.Ord Data.Array.Comfort.Shape.Zero instance GHC.Classes.Eq Data.Array.Comfort.Shape.Zero 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 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.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.Shifted n) instance GHC.Classes.Eq n => GHC.Classes.Eq (Data.Array.Comfort.Shape.Shifted n) instance GHC.Show.Show (Data.Array.Comfort.Shape.Enumeration n) instance GHC.Classes.Eq (Data.Array.Comfort.Shape.Enumeration n) instance GHC.Show.Show sh => GHC.Show.Show (Data.Array.Comfort.Shape.Deferred sh) instance GHC.Classes.Eq sh => GHC.Classes.Eq (Data.Array.Comfort.Shape.Deferred sh) instance GHC.Show.Show (Data.Array.Comfort.Shape.DeferredIndex sh) instance GHC.Classes.Ord (Data.Array.Comfort.Shape.DeferredIndex sh) instance GHC.Classes.Eq (Data.Array.Comfort.Shape.DeferredIndex sh) instance GHC.Show.Show sh => GHC.Show.Show (Data.Array.Comfort.Shape.Square sh) instance GHC.Classes.Eq sh => GHC.Classes.Eq (Data.Array.Comfort.Shape.Square sh) instance GHC.Show.Show sh => GHC.Show.Show (Data.Array.Comfort.Shape.Cube sh) instance GHC.Classes.Eq sh => GHC.Classes.Eq (Data.Array.Comfort.Shape.Cube sh) instance GHC.Show.Show Data.Array.Comfort.Shape.Lower instance GHC.Classes.Eq Data.Array.Comfort.Shape.Lower instance GHC.Show.Show Data.Array.Comfort.Shape.Upper instance GHC.Classes.Eq Data.Array.Comfort.Shape.Upper instance (GHC.Show.Show part, GHC.Show.Show size) => GHC.Show.Show (Data.Array.Comfort.Shape.Triangular part size) instance GHC.Classes.Eq Data.Array.Comfort.Shape.AllDistinct instance GHC.Show.Show Data.Array.Comfort.Shape.AllDistinct instance GHC.Classes.Eq Data.Array.Comfort.Shape.SomeRepetitive instance GHC.Show.Show Data.Array.Comfort.Shape.SomeRepetitive instance GHC.Enum.Enum Data.Array.Comfort.Shape.Collision instance GHC.Classes.Ord Data.Array.Comfort.Shape.Collision instance GHC.Classes.Eq Data.Array.Comfort.Shape.Collision instance GHC.Show.Show Data.Array.Comfort.Shape.Collision instance GHC.Show.Show n => GHC.Show.Show (Data.Array.Comfort.Shape.Cyclic n) instance GHC.Classes.Eq n => GHC.Classes.Eq (Data.Array.Comfort.Shape.Cyclic n) 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 (Control.DeepSeq.NFData sh0, Control.DeepSeq.NFData sh1) => Control.DeepSeq.NFData (sh0 Data.Array.Comfort.Shape.::+ sh1) 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 (Data.Array.Comfort.Shape.Static sh0, Data.Array.Comfort.Shape.Static sh1) => Data.Array.Comfort.Shape.Static (sh0 Data.Array.Comfort.Shape.::+ sh1) instance GHC.Base.Functor Data.Array.Comfort.Shape.Cyclic instance GHC.Base.Applicative Data.Array.Comfort.Shape.Cyclic instance Control.DeepSeq.NFData n => Control.DeepSeq.NFData (Data.Array.Comfort.Shape.Cyclic n) instance Foreign.Storable.Storable n => Foreign.Storable.Storable (Data.Array.Comfort.Shape.Cyclic n) instance GHC.Real.Integral n => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.Cyclic n) instance GHC.Real.Integral n => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.Cyclic n) instance GHC.Real.Integral n => Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.Cyclic n) instance Data.Array.Comfort.Shape.CollisionC Data.Array.Comfort.Shape.AllDistinct instance Data.Array.Comfort.Shape.CollisionC Data.Array.Comfort.Shape.SomeRepetitive instance Data.Array.Comfort.Shape.CollisionC Data.Array.Comfort.Shape.Collision instance (Data.Array.Comfort.Shape.SimplexOrderC order, Data.Array.Comfort.Shape.CollisionC coll, Data.Traversable.Traversable f, Data.Array.Comfort.Shape.C size) => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.Simplex order coll f size) instance (Data.Array.Comfort.Shape.SimplexOrderC order, Data.Array.Comfort.Shape.CollisionC coll, Data.Traversable.Traversable f, Data.Functor.Classes.Eq1 f, Data.Array.Comfort.Shape.Indexed size) => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.Simplex order coll f size) instance (Data.Array.Comfort.Shape.SimplexOrderC order, Data.Array.Comfort.Shape.CollisionC coll, Data.Traversable.Traversable f, Data.Functor.Classes.Eq1 f, Data.Array.Comfort.Shape.InvIndexed size) => Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.Simplex order coll f size) instance Data.Array.Comfort.Shape.SimplexOrderC Data.Array.Comfort.Shape.Ascending instance Data.Array.Comfort.Shape.SimplexOrderC Data.Array.Comfort.Shape.Descending instance (Data.Array.Comfort.Shape.SimplexOrderC order, GHC.Show.Show coll, Data.Functor.Classes.Show1 f, GHC.Show.Show size) => GHC.Show.Show (Data.Array.Comfort.Shape.Simplex order coll f size) instance GHC.Classes.Eq (Data.Array.Comfort.Shape.SimplexOrder order) instance GHC.Show.Show (Data.Array.Comfort.Shape.SimplexOrder order) instance (Data.Array.Comfort.Shape.TriangularPart part, Control.DeepSeq.NFData size) => Control.DeepSeq.NFData (Data.Array.Comfort.Shape.Triangular part size) instance (Data.Array.Comfort.Shape.TriangularPart part, GHC.Classes.Eq size) => GHC.Classes.Eq (Data.Array.Comfort.Shape.Triangular part size) instance (Data.Array.Comfort.Shape.TriangularPart part, Data.Array.Comfort.Shape.C size) => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.Triangular part size) instance (Data.Array.Comfort.Shape.TriangularPart part, Data.Array.Comfort.Shape.Indexed size) => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.Triangular part size) instance (Data.Array.Comfort.Shape.TriangularPart part, Data.Array.Comfort.Shape.InvIndexed size) => Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.Triangular part size) instance (Data.Array.Comfort.Shape.TriangularPart part, Data.Array.Comfort.Shape.Static size) => Data.Array.Comfort.Shape.Static (Data.Array.Comfort.Shape.Triangular part size) instance Data.Array.Comfort.Shape.TriangularPart Data.Array.Comfort.Shape.Lower instance Data.Array.Comfort.Shape.TriangularPart Data.Array.Comfort.Shape.Upper instance GHC.Base.Functor Data.Array.Comfort.Shape.Cube instance GHC.Base.Applicative Data.Array.Comfort.Shape.Cube instance Control.DeepSeq.NFData sh => Control.DeepSeq.NFData (Data.Array.Comfort.Shape.Cube sh) instance Foreign.Storable.Storable sh => Foreign.Storable.Storable (Data.Array.Comfort.Shape.Cube sh) instance Data.Array.Comfort.Shape.C sh => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.Cube sh) instance Data.Array.Comfort.Shape.Indexed sh => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.Cube sh) instance Data.Array.Comfort.Shape.InvIndexed sh => Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.Cube sh) instance GHC.Base.Functor Data.Array.Comfort.Shape.Square instance GHC.Base.Applicative Data.Array.Comfort.Shape.Square instance Control.DeepSeq.NFData sh => Control.DeepSeq.NFData (Data.Array.Comfort.Shape.Square sh) instance Foreign.Storable.Storable sh => Foreign.Storable.Storable (Data.Array.Comfort.Shape.Square sh) instance Data.Array.Comfort.Shape.C sh => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.Square sh) instance Data.Array.Comfort.Shape.Indexed sh => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.Square sh) instance Data.Array.Comfort.Shape.InvIndexed sh => Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.Square sh) instance Data.Array.Comfort.Shape.C sh => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.Deferred sh) instance Data.Array.Comfort.Shape.C sh => Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.Deferred sh) instance Foreign.Storable.Storable (Data.Array.Comfort.Shape.DeferredIndex sh) instance Control.DeepSeq.NFData sh => Control.DeepSeq.NFData (Data.Array.Comfort.Shape.Deferred sh) instance Data.Array.Comfort.Shape.C sh => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.Deferred sh) instance Data.Array.Comfort.Shape.Static sh => Data.Array.Comfort.Shape.Static (Data.Array.Comfort.Shape.Deferred sh) instance Control.DeepSeq.NFData (Data.Array.Comfort.Shape.Enumeration n) instance (GHC.Enum.Enum n, GHC.Enum.Bounded n) => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.Enumeration n) instance (GHC.Enum.Enum n, GHC.Enum.Bounded n) => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.Enumeration n) instance (GHC.Enum.Enum n, GHC.Enum.Bounded n) => Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.Enumeration n) instance (GHC.Enum.Enum n, GHC.Enum.Bounded n) => Data.Array.Comfort.Shape.Static (Data.Array.Comfort.Shape.Enumeration n) instance Foreign.Storable.Storable (Data.Array.Comfort.Shape.Enumeration n) 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 Control.DeepSeq.NFData n => Control.DeepSeq.NFData (Data.Array.Comfort.Shape.Shifted n) 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 Control.DeepSeq.NFData n => Control.DeepSeq.NFData (Data.Array.Comfort.Shape.Range n) instance GHC.Ix.Ix n => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.Range n) instance GHC.Ix.Ix n => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.Range n) instance GHC.Ix.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 GHC.Base.Applicative Data.Array.Comfort.Shape.OneBased instance Control.DeepSeq.NFData n => Control.DeepSeq.NFData (Data.Array.Comfort.Shape.OneBased n) 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 GHC.Base.Applicative Data.Array.Comfort.Shape.ZeroBased instance Control.DeepSeq.NFData n => Control.DeepSeq.NFData (Data.Array.Comfort.Shape.ZeroBased n) 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.C Data.Array.Comfort.Shape.Zero instance Data.Array.Comfort.Shape.Static Data.Array.Comfort.Shape.Zero instance Data.Array.Comfort.Shape.Static () instance Data.Array.Comfort.Shape.Static sh => Data.Array.Comfort.Shape.Static (Data.Tagged.Tagged s sh) instance (Data.Array.Comfort.Shape.Static sh0, Data.Array.Comfort.Shape.Static sh1) => Data.Array.Comfort.Shape.Static (sh0, sh1) instance (Data.Array.Comfort.Shape.Static sh0, Data.Array.Comfort.Shape.Static sh1, Data.Array.Comfort.Shape.Static sh2) => Data.Array.Comfort.Shape.Static (sh0, sh1, sh2) instance Data.Array.Comfort.Shape.InvIndexed () instance GHC.Classes.Ord n => Data.Array.Comfort.Shape.InvIndexed (Data.Set.Internal.Set n) instance (GHC.Classes.Ord k, Data.Array.Comfort.Shape.InvIndexed shape) => Data.Array.Comfort.Shape.InvIndexed (Data.Map.Internal.Map k shape) instance Data.Array.Comfort.Shape.InvIndexed sh => Data.Array.Comfort.Shape.InvIndexed (Data.Tagged.Tagged s sh) 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 GHC.Classes.Ord n => Data.Array.Comfort.Shape.Indexed (Data.Set.Internal.Set n) instance (GHC.Classes.Ord k, Data.Array.Comfort.Shape.Indexed shape) => Data.Array.Comfort.Shape.Indexed (Data.Map.Internal.Map k shape) instance Data.Array.Comfort.Shape.Indexed sh => Data.Array.Comfort.Shape.Indexed (Data.Tagged.Tagged s sh) 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 GHC.Classes.Ord n => Data.Array.Comfort.Shape.C (Data.Set.Internal.Set n) instance (GHC.Classes.Ord k, Data.Array.Comfort.Shape.C shape) => Data.Array.Comfort.Shape.C (Data.Map.Internal.Map k shape) instance Data.Array.Comfort.Shape.C sh => Data.Array.Comfort.Shape.C (Data.Tagged.Tagged s sh) 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) instance (Data.Array.Comfort.Shape.Checking check, GHC.Classes.Eq a) => GHC.Classes.Eq (Data.Array.Comfort.Shape.Result check a) instance Data.Array.Comfort.Shape.Checking check => GHC.Base.Functor (Data.Array.Comfort.Shape.Result check) instance Data.Array.Comfort.Shape.Checking check => GHC.Base.Applicative (Data.Array.Comfort.Shape.Result check) instance Data.Array.Comfort.Shape.Checking check => GHC.Base.Monad (Data.Array.Comfort.Shape.Result check) instance Data.Array.Comfort.Shape.Checking Data.Array.Comfort.Shape.Checked instance Data.Array.Comfort.Shape.Checking Data.Array.Comfort.Shape.Unchecked module Data.Array.Comfort.Shape.Test tests :: (InvIndexed sh, Show sh, Index sh ~ ix, Eq ix, Show ix) => Gen sh -> [(String, Property)] -- | This module provides an array shape type, that allows to store -- elements from a container while preserving the container structure. module Data.Array.Comfort.Container class (Foldable f) => C f where { data family Shape f; } shapeSize :: C f => Shape f -> Int fromList :: C f => Shape f -> [a] -> f a toShape :: C f => f a -> Shape f class (C f) => EqShape f eqShape :: EqShape f => Shape f -> Shape f -> Bool class (C f) => NFShape f rnfShape :: NFShape f => Shape f -> () instance GHC.Show.Show (Data.Array.Comfort.Container.Shape []) instance GHC.Show.Show (Data.Array.Comfort.Container.Shape Data.Empty.T) instance GHC.Show.Show k => GHC.Show.Show (Data.Array.Comfort.Container.Shape (Data.Map.Internal.Map k)) instance GHC.Show.Show k => GHC.Show.Show (Data.Array.Comfort.Container.Shape (Data.NonEmpty.Map.T k)) instance Data.Array.Comfort.Container.EqShape f => GHC.Classes.Eq (Data.Array.Comfort.Container.Shape f) instance Data.Array.Comfort.Container.EqShape [] instance Data.Array.Comfort.Container.EqShape f => Data.Array.Comfort.Container.EqShape (Data.NonEmptyPrivate.T f) instance Data.Array.Comfort.Container.EqShape Data.Empty.T instance GHC.Classes.Ord k => Data.Array.Comfort.Container.EqShape (Data.Map.Internal.Map k) instance GHC.Classes.Ord k => Data.Array.Comfort.Container.EqShape (Data.NonEmpty.Map.T k) instance Data.Array.Comfort.Container.NFShape f => Control.DeepSeq.NFData (Data.Array.Comfort.Container.Shape f) instance Data.Array.Comfort.Container.NFShape [] instance Data.Array.Comfort.Container.NFShape f => Data.Array.Comfort.Container.NFShape (Data.NonEmptyPrivate.T f) instance Data.Array.Comfort.Container.NFShape Data.Empty.T instance (Control.DeepSeq.NFData k, GHC.Classes.Ord k) => Data.Array.Comfort.Container.NFShape (Data.Map.Internal.Map k) instance (Control.DeepSeq.NFData k, GHC.Classes.Ord k) => Data.Array.Comfort.Container.NFShape (Data.NonEmpty.Map.T k) instance Data.Array.Comfort.Container.C f => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Container.Shape f) instance Data.Array.Comfort.Container.C [] instance Data.Array.Comfort.Container.C f => Data.Array.Comfort.Container.C (Data.NonEmptyPrivate.T f) instance Data.Array.Comfort.Container.C Data.Empty.T instance GHC.Classes.Ord k => Data.Array.Comfort.Container.C (Data.Map.Internal.Map k) instance GHC.Classes.Ord k => Data.Array.Comfort.Container.C (Data.NonEmpty.Map.T k) module Data.Array.Comfort.Boxed.Unchecked data Array sh a Array :: sh -> Array a -> Array sh a [shape] :: Array sh a -> sh [buffer] :: Array sh a -> Array a reshape :: sh1 -> Array sh0 a -> Array sh1 a mapShape :: (sh0 -> sh1) -> Array sh0 a -> Array sh1 a (!) :: 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 replicate :: C sh => sh -> a -> Array sh a map :: C sh => (a -> b) -> Array sh a -> Array sh b zipWith :: C sh => (a -> b -> c) -> Array sh a -> Array sh b -> Array sh c instance (Data.Array.Comfort.Shape.C sh, GHC.Show.Show sh, GHC.Show.Show a) => GHC.Show.Show (Data.Array.Comfort.Boxed.Unchecked.Array sh a) instance (Data.Array.Comfort.Shape.C sh, Control.DeepSeq.NFData sh, Control.DeepSeq.NFData a) => Control.DeepSeq.NFData (Data.Array.Comfort.Boxed.Unchecked.Array sh a) instance Data.Array.Comfort.Shape.C sh => GHC.Base.Functor (Data.Array.Comfort.Boxed.Unchecked.Array sh) instance Data.Array.Comfort.Shape.Static sh => GHC.Base.Applicative (Data.Array.Comfort.Boxed.Unchecked.Array sh) instance Data.Array.Comfort.Shape.C sh => Data.Foldable.Foldable (Data.Array.Comfort.Boxed.Unchecked.Array sh) instance Data.Array.Comfort.Shape.C sh => Data.Traversable.Traversable (Data.Array.Comfort.Boxed.Unchecked.Array sh) module Data.Array.Comfort.Boxed data Array sh a shape :: Array sh a -> sh reshape :: (C sh0, C sh1) => sh1 -> Array sh0 a -> Array sh1 a mapShape :: (C sh0, C sh1) => (sh0 -> sh1) -> Array sh0 a -> Array sh1 a accessMaybe :: Indexed sh => Array sh a -> Index sh -> Maybe a (!) :: 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 toAssociations :: Indexed sh => Array sh a -> [(Index sh, a)] fromMap :: Ord k => Map k a -> Array (Set k) a toMap :: Ord k => Array (Set k) a -> Map k a fromContainer :: C f => f a -> Array (Shape f) a toContainer :: C f => Array (Shape f) a -> f a indices :: Indexed sh => sh -> Array sh (Index sh) replicate :: C sh => sh -> a -> Array sh a map :: C sh => (a -> b) -> Array sh a -> Array sh b zipWith :: (C sh, Eq sh) => (a -> b -> c) -> Array sh a -> Array sh b -> Array sh c (//) :: Indexed sh => Array sh a -> [(Index sh, a)] -> Array sh a accumulate :: Indexed sh => (a -> b -> a) -> Array sh a -> [(Index sh, b)] -> Array sh a fromAssociations :: Indexed sh => a -> sh -> [(Index sh, a)] -> Array sh a module Data.Array.Comfort.Storable.Mutable.Private data Array (m :: * -> *) sh a Array :: sh -> MutablePtr a -> Array (m :: * -> *) sh a [shape] :: Array (m :: * -> *) sh a -> sh [buffer] :: Array (m :: * -> *) sh a -> MutablePtr a type STArray s = Array (ST s) type IOArray = Array IO copy :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m (Array m sh a) create :: (C sh, Storable a) => sh -> (Ptr a -> IO ()) -> IO (IOArray sh a) createWithSize :: (C sh, Storable a) => sh -> (Int -> Ptr a -> IO ()) -> IO (IOArray sh a) createWithSizeAndResult :: (C sh, Storable a) => sh -> (Int -> Ptr a -> IO b) -> IO (IOArray sh a, b) unsafeCreate :: (PrimMonad m, C sh, Storable a) => sh -> (Ptr a -> IO ()) -> m (Array m sh a) unsafeCreateWithSize :: (PrimMonad m, C sh, Storable a) => sh -> (Int -> Ptr a -> IO ()) -> m (Array m sh a) unsafeCreateWithSizeAndResult :: (PrimMonad m, C sh, Storable a) => sh -> (Int -> Ptr a -> IO b) -> m (Array m sh a, b) unsafeArrayIOToPrim :: PrimMonad m => IOArray sh a -> Array m sh a show :: (PrimMonad m, C sh, Show sh, Storable a, Show a) => Array m sh a -> m String withArrayPtr :: PrimMonad m => MutablePtr a -> (Ptr a -> IO b) -> m b withPtr :: PrimMonad m => Array m sh a -> (Ptr a -> IO b) -> m b read :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> m a readMaybe :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> Maybe (m a) write :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> a -> m () update :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> (a -> a) -> m () new :: (PrimMonad m, C sh, Storable a) => sh -> a -> m (Array m sh a) toList :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m [a] fromList :: (PrimMonad m, C sh, Storable a) => sh -> [a] -> m (Array m sh a) vectorFromList :: (PrimMonad m, Storable a) => [a] -> m (Array m (ZeroBased Int) a) module Data.Array.Comfort.Storable.Private 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 ! 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 (//) :: (Indexed sh, Storable a) => Array sh a -> [(Index sh, a)] -> Array sh a accumulate :: (Indexed sh, Storable a) => (a -> b -> a) -> Array sh a -> [(Index sh, b)] -> Array sh a fromAssociations :: (Indexed sh, Storable a) => a -> sh -> [(Index sh, a)] -> Array sh a freeze :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m (Array sh a) thaw :: (PrimMonad m, C sh, Storable a) => Array sh a -> m (Array m sh a) unsafeFreeze :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m (Array sh a) unsafeThaw :: (PrimMonad m, C sh, Storable a) => Array sh a -> m (Array m sh 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.Private.Array sh a) instance Control.DeepSeq.NFData sh => Control.DeepSeq.NFData (Data.Array.Comfort.Storable.Private.Array sh a) instance (Data.Array.Comfort.Shape.C sh, GHC.Classes.Eq sh, Foreign.Storable.Storable a, GHC.Classes.Eq a) => GHC.Classes.Eq (Data.Array.Comfort.Storable.Private.Array sh a) -- | The functions in this module miss any bound checking. module Data.Array.Comfort.Storable.Mutable.Unchecked data Array (m :: * -> *) sh a Array :: sh -> MutablePtr a -> Array (m :: * -> *) sh a [shape] :: Array (m :: * -> *) sh a -> sh [buffer] :: Array (m :: * -> *) sh a -> MutablePtr a type STArray s = Array (ST s) type IOArray = Array IO new :: (PrimMonad m, C sh, Storable a) => sh -> a -> m (Array m sh a) copy :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m (Array m sh a) create :: (C sh, Storable a) => sh -> (Ptr a -> IO ()) -> IO (IOArray sh a) createWithSize :: (C sh, Storable a) => sh -> (Int -> Ptr a -> IO ()) -> IO (IOArray sh a) createWithSizeAndResult :: (C sh, Storable a) => sh -> (Int -> Ptr a -> IO b) -> IO (IOArray sh a, b) unsafeCreate :: (PrimMonad m, C sh, Storable a) => sh -> (Ptr a -> IO ()) -> m (Array m sh a) unsafeCreateWithSize :: (PrimMonad m, C sh, Storable a) => sh -> (Int -> Ptr a -> IO ()) -> m (Array m sh a) unsafeCreateWithSizeAndResult :: (PrimMonad m, C sh, Storable a) => sh -> (Int -> Ptr a -> IO b) -> m (Array m sh a, b) withPtr :: PrimMonad m => Array m sh a -> (Ptr a -> IO b) -> m b read :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> m a readMaybe :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> Maybe (m a) write :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> a -> m () update :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> (a -> a) -> m () toList :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m [a] fromList :: (PrimMonad m, C sh, Storable a) => sh -> [a] -> m (Array m sh a) vectorFromList :: (PrimMonad m, Storable a) => [a] -> m (Array m (ZeroBased Int) a) freeze :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m (Array sh a) unsafeFreeze :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m (Array sh a) thaw :: (PrimMonad m, C sh, Storable a) => Array sh a -> m (Array m sh a) unsafeThaw :: (PrimMonad m, C sh, Storable a) => Array sh a -> m (Array m sh a) module Data.Array.Comfort.Storable.Mutable data Array (m :: * -> *) sh a type STArray s = Array (ST s) type IOArray = Array IO shape :: Array m sh a -> sh new :: (PrimMonad m, C sh, Storable a) => sh -> a -> m (Array m sh a) read :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> m a readMaybe :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> Maybe (m a) write :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> a -> m () update :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> (a -> a) -> m () toList :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m [a] fromList :: (PrimMonad m, C sh, Storable a) => sh -> [a] -> m (Array m sh a) vectorFromList :: (PrimMonad m, Storable a) => [a] -> m (Array m (ZeroBased Int) a) thaw :: (PrimMonad m, C sh, Storable a) => Array sh a -> m (Array m sh a) freeze :: (PrimMonad m, C sh, Storable a) => Array m sh a -> m (Array sh a) module Data.Array.Comfort.Storable.Unchecked.Monadic unsafeCreate :: (PrimMonad m, C sh, Storable a) => sh -> (Ptr a -> IO ()) -> m (Array sh a) unsafeCreateWithSize :: (PrimMonad m, C sh, Storable a) => sh -> (Int -> Ptr a -> IO ()) -> m (Array sh a) unsafeCreateWithSizeAndResult :: (PrimMonad m, C sh, Storable a) => sh -> (Int -> Ptr a -> IO b) -> m (Array sh a, b) -- | The functions in this module miss any bound checking. module Data.Array.Comfort.Storable.Unchecked 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 mapWithIndex :: (Indexed sh, Index sh ~ ix, Storable a, Storable b) => (ix -> a -> b) -> Array sh a -> Array sh b zipWith :: (C sh, Storable a, Storable b, Storable c) => (a -> b -> c) -> Array sh a -> Array sh b -> Array sh c (//) :: (Indexed sh, Storable a) => Array sh a -> [(Index sh, a)] -> Array sh a accumulate :: (Indexed sh, Storable a) => (a -> b -> a) -> Array sh a -> [(Index sh, b)] -> Array sh a fromAssociations :: (Indexed sh, Storable a) => a -> sh -> [(Index sh, a)] -> Array sh a -- |
--   \x  ->  Array.singleton x ! () == (x::Word16)
--   
singleton :: Storable a => a -> Array () a append :: (C shx, C shy, Storable a) => Array shx a -> Array shy a -> Array (shx ::+ shy) a infixr 5 `append` -- |
--   \(QC.NonNegative n) (Array16 x)  ->  x == Array.mapShape (Shape.ZeroBased . Shape.size) (Array.append (Array.take n x) (Array.drop n x))
--   
take :: (Integral n, Storable a) => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a -- |
--   \(QC.NonNegative n) (Array16 x)  ->  x == Array.mapShape (Shape.ZeroBased . Shape.size) (Array.append (Array.take n x) (Array.drop n x))
--   
drop :: (Integral n, Storable a) => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a -- |
--   \(Array16 x) (Array16 y) -> let xy = Array.append x y in x == Array.takeLeft xy  &&  y == Array.takeRight xy
--   
takeLeft :: (C sh0, C sh1, Storable a) => Array (sh0 ::+ sh1) a -> Array sh0 a takeRight :: (C sh0, C sh1, Storable a) => Array (sh0 ::+ sh1) a -> Array sh1 a split :: (C sh0, C sh1, Storable a) => Array (sh0 ::+ sh1) a -> (Array sh0 a, Array sh1 a) -- |
--   \(Array16 x) (Array16 y) (Array16 z) -> let xyz = Array.append x $ Array.append y z in y == Array.takeCenter xyz
--   
takeCenter :: (C sh0, C sh1, C sh2, Storable a) => Array (sh0 ::+ (sh1 ::+ sh2)) a -> Array sh1 a -- |
--   \(Array16 xs)  ->  Array.sum xs == sum (Array.toList xs)
--   
sum :: (C sh, Storable a, Num a) => Array sh a -> a -- |
--   \(Array16 xs)  ->  Array.product xs == product (Array.toList xs)
--   
product :: (C sh, Storable a, Num a) => Array sh a -> a foldl :: (C sh, Storable a) => (b -> a -> b) -> b -> Array sh a -> b module Data.Array.Comfort.Storable data Array sh a shape :: Array sh a -> sh reshape :: (C sh0, C sh1) => sh1 -> Array sh0 a -> Array sh1 a mapShape :: (C sh0, C sh1) => (sh0 -> sh1) -> Array sh0 a -> Array sh1 a accessMaybe :: (Indexed sh, Storable a) => Array sh a -> Index sh -> Maybe a (!) :: (Indexed sh, Storable a) => Array sh a -> Index sh -> a infixl 9 ! toList :: (C sh, Storable a) => Array sh a -> [a] vectorFromList :: Storable a => [a] -> Array (ZeroBased Int) a toAssociations :: (Indexed sh, Storable a) => Array sh a -> [(Index sh, a)] fromList :: (C sh, Storable a) => sh -> [a] -> Array sh a fromMap :: (Ord k, Storable a) => Map k a -> Array (Set k) a toMap :: (Ord k, Storable a) => Array (Set k) a -> Map k a fromContainer :: (C f, Storable a) => f a -> Array (Shape f) a toContainer :: (C f, Storable a) => Array (Shape f) a -> f a sample :: (Indexed sh, Storable a) => sh -> (Index sh -> a) -> Array sh a fromBoxed :: (C sh, Storable a) => Array sh a -> Array sh a toBoxed :: (C sh, Storable a) => Array sh a -> Array sh a fromStorableVector :: Storable a => Vector a -> Array (ZeroBased Int) a toStorableVector :: (C sh, Storable a) => Array sh a -> Vector a map :: (C sh, Storable a, Storable b) => (a -> b) -> Array sh a -> Array sh b mapWithIndex :: (Indexed sh, Index sh ~ ix, Storable a, Storable b) => (ix -> a -> b) -> Array sh a -> Array sh b zipWith :: (C sh, Eq sh, Storable a, Storable b, Storable c) => (a -> b -> c) -> Array sh a -> Array sh b -> Array sh c (//) :: (Indexed sh, Storable a) => Array sh a -> [(Index sh, a)] -> Array sh a accumulate :: (Indexed sh, Storable a) => (a -> b -> a) -> Array sh a -> [(Index sh, b)] -> Array sh a fromAssociations :: (Indexed sh, Storable a) => a -> sh -> [(Index sh, a)] -> Array sh a -- |
--   QC.forAll genNonEmptyArray2 $ \xs -> QC.forAll (QC.elements $ Shape.indices $ Array.shape xs) $ \(ix0,ix1) -> Array.pick xs ix0 ! ix1 == xs!(ix0,ix1)
--   
pick :: (Indexed sh0, C sh1, Storable a) => Array (sh0, sh1) a -> Index sh0 -> Array sh1 a toRowArray :: (Indexed sh0, C sh1, Storable a) => Array (sh0, sh1) a -> Array sh0 (Array sh1 a) -- | It is a checked error if a row width differs from the result array -- width. -- --
--   QC.forAll genArray2 $ \xs -> xs == Array.fromRowArray (snd $ Array.shape xs) (Array.toRowArray xs)
--   
fromRowArray :: (C sh0, C sh1, Eq sh1, Storable a) => sh1 -> Array sh0 (Array sh1 a) -> Array (sh0, sh1) a -- |
--   \x  ->  Array.singleton x ! () == (x::Word16)
--   
singleton :: Storable a => a -> Array () a append :: (C shx, C shy, Storable a) => Array shx a -> Array shy a -> Array (shx ::+ shy) a infixr 5 `append` -- |
--   \(QC.NonNegative n) (Array16 x)  ->  x == Array.mapShape (Shape.ZeroBased . Shape.size) (Array.append (Array.take n x) (Array.drop n x))
--   
take :: (Integral n, Storable a) => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a -- |
--   \(QC.NonNegative n) (Array16 x)  ->  x == Array.mapShape (Shape.ZeroBased . Shape.size) (Array.append (Array.take n x) (Array.drop n x))
--   
drop :: (Integral n, Storable a) => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a -- |
--   \(Array16 x) (Array16 y) -> let xy = Array.append x y in x == Array.takeLeft xy  &&  y == Array.takeRight xy
--   
takeLeft :: (C sh0, C sh1, Storable a) => Array (sh0 ::+ sh1) a -> Array sh0 a takeRight :: (C sh0, C sh1, Storable a) => Array (sh0 ::+ sh1) a -> Array sh1 a split :: (C sh0, C sh1, Storable a) => Array (sh0 ::+ sh1) a -> (Array sh0 a, Array sh1 a) -- |
--   \(Array16 x) (Array16 y) (Array16 z) -> let xyz = Array.append x $ Array.append y z in y == Array.takeCenter xyz
--   
takeCenter :: (C sh0, C sh1, C sh2, Storable a) => Array (sh0 ::+ (sh1 ::+ sh2)) a -> Array sh1 a -- |
--   \(Array16 xs)  ->  Array.sum xs == sum (Array.toList xs)
--   
sum :: (C sh, Storable a, Num a) => Array sh a -> a -- |
--   \(Array16 xs)  ->  Array.product xs == product (Array.toList xs)
--   
product :: (C sh, Storable a, Num a) => Array sh a -> a -- | It is a checked error if the vector is empty. -- --
--   forAllNonEmpty $ \xs -> Array.minimum xs ==? minimum (Array.toList xs)
--   
minimum :: (C sh, Storable a, Ord a) => Array sh a -> a argMinimum :: (InvIndexed sh, Index sh ~ ix, Storable a, Ord a) => Array sh a -> (ix, a) -- | It is a checked error if the vector is empty. -- --
--   forAllNonEmpty $ \xs -> Array.maximum xs ==? maximum (Array.toList xs)
--   
maximum :: (C sh, Storable a, Ord a) => Array sh a -> a argMaximum :: (InvIndexed sh, Index sh ~ ix, Storable a, Ord a) => Array sh a -> (ix, a) -- |
--   forAllNonEmpty $ \xs -> Array.limits xs ==? (Array.minimum xs, Array.maximum xs)
--   
limits :: (C sh, Storable a, Ord a) => Array sh a -> (a, a) foldl :: (C sh, Storable a) => (b -> a -> b) -> b -> Array sh a -> b foldl1 :: (C sh, Storable a) => (a -> a -> a) -> Array sh a -> a foldMap :: (C sh, Storable a, Ord a, Semigroup m) => (a -> m) -> Array sh a -> m