-- 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: -- --
-- >>> 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 -- | Shape for arrays that hold elements that can alternatively be stored -- in nested tuples. newtype NestedTuple ixtype tuple NestedTuple :: tuple -> NestedTuple ixtype tuple [getNestedTuple] :: NestedTuple ixtype tuple -> tuple class (ElementTuple tuple) => AccessorTuple tuple tupleAccessors :: AccessorTuple tuple => tuple -> [tuple -> Element] class (ElementTuple tuple, Eq tuple) => StaticTuple tuple staticTuple :: StaticTuple tuple => State Element tuple newtype Element Element :: Int -> Element data TupleAccessor data TupleIndex data ElementIndex tuple class ElementTuple tuple where { type DataTuple tuple x; } indexTupleA :: (ElementTuple tuple, Applicative f) => (Element -> f a) -> tuple -> f (DataTuple tuple a) indexTupleFromShape :: ElementTuple tuple => NestedTuple TupleIndex tuple -> DataTuple tuple (ElementIndex tuple) -- | Shape for arrays that hold elements that can alternatively be stored -- in a Traversable record. newtype Record f Record :: f Element -> Record f [getRecord] :: Record f -> f Element data FieldIndex (f :: * -> *) indexRecordFromShape :: Traversable f => Record f -> f (FieldIndex f) data Constructed tag data ConsIndex tag data Construction tag a construct :: Construction tag a -> (Constructed tag, a) consIndex :: Construction tag (ConsIndex tag) 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 GHC.Show.Show tuple => GHC.Show.Show (Data.Array.Comfort.Shape.NestedTuple ixtype tuple) instance GHC.Classes.Eq tuple => GHC.Classes.Eq (Data.Array.Comfort.Shape.NestedTuple ixtype tuple) instance GHC.Show.Show Data.Array.Comfort.Shape.Element instance GHC.Classes.Eq Data.Array.Comfort.Shape.Element instance GHC.Show.Show (Data.Array.Comfort.Shape.ElementIndex tuple) instance GHC.Classes.Ord (Data.Array.Comfort.Shape.ElementIndex tuple) instance GHC.Classes.Eq (Data.Array.Comfort.Shape.ElementIndex tuple) instance GHC.Show.Show (Data.Array.Comfort.Shape.FieldIndex f) instance GHC.Classes.Eq (Data.Array.Comfort.Shape.FieldIndex f) instance GHC.Show.Show (Data.Array.Comfort.Shape.Constructed tag) instance GHC.Classes.Eq (Data.Array.Comfort.Shape.Constructed tag) instance GHC.Show.Show (Data.Array.Comfort.Shape.ConsIndex tag) instance GHC.Classes.Eq (Data.Array.Comfort.Shape.ConsIndex tag) instance GHC.Base.Functor (Data.Array.Comfort.Shape.Construction tag) instance GHC.Base.Applicative (Data.Array.Comfort.Shape.Construction tag) instance GHC.Base.Monad (Data.Array.Comfort.Shape.Construction tag) instance Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.Constructed tag) instance Data.Array.Comfort.Shape.InvIndexed (Data.Array.Comfort.Shape.Constructed tag) instance Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.Constructed tag) instance Data.Foldable.Foldable f => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.Record f) instance Data.Foldable.Foldable f => GHC.Classes.Eq (Data.Array.Comfort.Shape.Record f) instance Data.Foldable.Foldable f => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.Record f) instance (GHC.Base.Applicative f, Data.Traversable.Traversable f) => Data.Array.Comfort.Shape.Static (Data.Array.Comfort.Shape.Record f) instance Data.Array.Comfort.Shape.ElementTuple tuple => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.NestedTuple Data.Array.Comfort.Shape.TupleIndex tuple) instance Data.Array.Comfort.Shape.ElementTuple tuple => Data.Array.Comfort.Shape.Pattern (Data.Array.Comfort.Shape.NestedTuple Data.Array.Comfort.Shape.TupleIndex tuple) instance Data.Array.Comfort.Shape.StaticTuple () instance Data.Array.Comfort.Shape.StaticTuple Data.Array.Comfort.Shape.Element instance (Data.Array.Comfort.Shape.StaticTuple a, Data.Array.Comfort.Shape.StaticTuple b) => Data.Array.Comfort.Shape.StaticTuple (a, b) instance (Data.Array.Comfort.Shape.StaticTuple a, Data.Array.Comfort.Shape.StaticTuple b, Data.Array.Comfort.Shape.StaticTuple c) => Data.Array.Comfort.Shape.StaticTuple (a, b, c) instance (Data.Array.Comfort.Shape.StaticTuple a, Data.Array.Comfort.Shape.StaticTuple b, Data.Array.Comfort.Shape.StaticTuple c, Data.Array.Comfort.Shape.StaticTuple d) => Data.Array.Comfort.Shape.StaticTuple (a, b, c, d) instance Data.Array.Comfort.Shape.StaticTuple a => Data.Array.Comfort.Shape.StaticTuple (Data.Complex.Complex a) instance Data.Array.Comfort.Shape.StaticTuple tuple => Data.Array.Comfort.Shape.Static (Data.Array.Comfort.Shape.NestedTuple ixtype tuple) instance Data.Array.Comfort.Shape.AccessorTuple () instance Data.Array.Comfort.Shape.AccessorTuple Data.Array.Comfort.Shape.Element instance (Data.Array.Comfort.Shape.AccessorTuple a, Data.Array.Comfort.Shape.AccessorTuple b) => Data.Array.Comfort.Shape.AccessorTuple (a, b) instance (Data.Array.Comfort.Shape.AccessorTuple a, Data.Array.Comfort.Shape.AccessorTuple b, Data.Array.Comfort.Shape.AccessorTuple c) => Data.Array.Comfort.Shape.AccessorTuple (a, b, c) instance (Data.Array.Comfort.Shape.AccessorTuple a, Data.Array.Comfort.Shape.AccessorTuple b, Data.Array.Comfort.Shape.AccessorTuple c, Data.Array.Comfort.Shape.AccessorTuple d) => Data.Array.Comfort.Shape.AccessorTuple (a, b, c, d) instance (Data.Array.Comfort.Shape.AccessorTuple a, GHC.Float.RealFloat a) => Data.Array.Comfort.Shape.AccessorTuple (Data.Complex.Complex a) instance Data.Array.Comfort.Shape.AccessorTuple tuple => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Shape.NestedTuple Data.Array.Comfort.Shape.TupleAccessor tuple) instance Data.Array.Comfort.Shape.ElementTuple tuple => Control.DeepSeq.NFData (Data.Array.Comfort.Shape.NestedTuple ixtype tuple) instance GHC.Base.Functor Data.Array.Comfort.Shape.StrictUnitWriter instance GHC.Base.Applicative Data.Array.Comfort.Shape.StrictUnitWriter instance GHC.Base.Monad Data.Array.Comfort.Shape.StrictUnitWriter instance Data.Array.Comfort.Shape.ElementTuple () instance Data.Array.Comfort.Shape.ElementTuple Data.Array.Comfort.Shape.Element instance (Data.Array.Comfort.Shape.ElementTuple a, Data.Array.Comfort.Shape.ElementTuple b) => Data.Array.Comfort.Shape.ElementTuple (a, b) instance (Data.Array.Comfort.Shape.ElementTuple a, Data.Array.Comfort.Shape.ElementTuple b, Data.Array.Comfort.Shape.ElementTuple c) => Data.Array.Comfort.Shape.ElementTuple (a, b, c) instance (Data.Array.Comfort.Shape.ElementTuple a, Data.Array.Comfort.Shape.ElementTuple b, Data.Array.Comfort.Shape.ElementTuple c, Data.Array.Comfort.Shape.ElementTuple d) => Data.Array.Comfort.Shape.ElementTuple (a, b, c, d) instance Data.Array.Comfort.Shape.ElementTuple a => Data.Array.Comfort.Shape.ElementTuple (Data.Complex.Complex a) instance Data.Array.Comfort.Shape.ElementTuple tuple => Data.Array.Comfort.Shape.C (Data.Array.Comfort.Shape.NestedTuple ixtype tuple) instance Control.DeepSeq.NFData Data.Array.Comfort.Shape.Element 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 (Data.Array.Comfort.Shape.Pattern sh0, Data.Array.Comfort.Shape.Pattern sh1) => Data.Array.Comfort.Shape.Pattern (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 (Data.Array.Comfort.Shape.Pattern sh0, Data.Array.Comfort.Shape.Pattern sh1) => Data.Array.Comfort.Shape.Pattern (sh0, sh1) instance Data.Array.Comfort.Shape.Pattern sh => Data.Array.Comfort.Shape.Pattern (Data.Array.Comfort.Shape.Square 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 GHC.Real.Integral n => Data.Array.Comfort.Shape.Pattern (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.Pattern () instance Data.Array.Comfort.Shape.Pattern sh => Data.Array.Comfort.Shape.Pattern (Data.Tagged.Tagged s sh) 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 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 -> () class (C f) => Indexed f where { type Index f; } indices :: Indexed f => Shape f -> [Index f] unifiedSizeOffset :: (Indexed f, Checking check) => Shape f -> (Int, Index f -> Result check Int) 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.Indexed f => Data.Array.Comfort.Shape.Indexed (Data.Array.Comfort.Container.Shape f) instance Data.Array.Comfort.Container.Indexed [] instance Data.Array.Comfort.Container.C f => Data.Array.Comfort.Container.Indexed (Data.NonEmptyPrivate.T f) instance GHC.Classes.Ord k => Data.Array.Comfort.Container.Indexed (Data.Map.Internal.Map k) instance GHC.Classes.Ord k => Data.Array.Comfort.Container.Indexed (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 append :: (C shx, C shy) => Array shx a -> Array shy a -> Array (shx ::+ shy) a infixr 5 `append` -- |
-- \(QC.NonNegative n) (ArrayChar x) -> x == Array.mapShape (Shape.ZeroBased . Shape.size) (Array.append (Array.take n x) (Array.drop n x)) --take :: Integral n => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a -- |
-- \(QC.NonNegative n) (ArrayChar x) -> x == Array.mapShape (Shape.ZeroBased . Shape.size) (Array.append (Array.take n x) (Array.drop n x)) --drop :: Integral n => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a -- |
-- \(ArrayChar x) (ArrayChar y) -> let xy = Array.append x y in x == Array.takeLeft xy && y == Array.takeRight xy --takeLeft :: (C sh0, C sh1) => Array (sh0 ::+ sh1) a -> Array sh0 a takeRight :: (C sh0, C sh1) => Array (sh0 ::+ sh1) a -> Array sh1 a split :: (C sh0, C sh1) => Array (sh0 ::+ sh1) a -> (Array sh0 a, Array sh1 a) -- |
-- \(ArrayChar x) (ArrayChar y) (ArrayChar z) -> let xyz = Array.append x $ Array.append y z in y == Array.takeCenter xyz --takeCenter :: (C sh0, C sh1, C sh2) => Array (sh0 ::+ (sh1 ::+ sh2)) a -> Array sh1 a instance (GHC.Classes.Eq sh, GHC.Classes.Eq a) => GHC.Classes.Eq (Data.Array.Comfort.Boxed.Unchecked.Array sh a) 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 fromTuple :: NestedTuple tuple => DataTuple tuple a -> Array (NestedTuple ixtype tuple) a toTuple :: NestedTuple tuple => Array (NestedTuple ixtype tuple) a -> DataTuple tuple a fromRecord :: Traversable f => f a -> Array (Record f) a toRecord :: Traversable f => Array (Record f) a -> f 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 pick :: (Indexed sh0, C sh1) => Array (sh0, sh1) a -> Index sh0 -> Array sh1 a append :: (C shx, C shy) => Array shx a -> Array shy a -> Array (shx ::+ shy) a infixr 5 `append` -- |
-- \(QC.NonNegative n) (ArrayChar x) -> x == Array.mapShape (Shape.ZeroBased . Shape.size) (Array.append (Array.take n x) (Array.drop n x)) --take :: Integral n => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a -- |
-- \(QC.NonNegative n) (ArrayChar x) -> x == Array.mapShape (Shape.ZeroBased . Shape.size) (Array.append (Array.take n x) (Array.drop n x)) --drop :: Integral n => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a -- |
-- \(ArrayChar x) (ArrayChar y) -> let xy = Array.append x y in x == Array.takeLeft xy && y == Array.takeRight xy --takeLeft :: (C sh0, C sh1) => Array (sh0 ::+ sh1) a -> Array sh0 a takeRight :: (C sh0, C sh1) => Array (sh0 ::+ sh1) a -> Array sh1 a split :: (C sh0, C sh1) => Array (sh0 ::+ sh1) a -> (Array sh0 a, Array sh1 a) -- |
-- \(ArrayChar x) (ArrayChar y) (ArrayChar z) -> let xyz = Array.append x $ Array.append y z in y == Array.takeCenter xyz --takeCenter :: (C sh0, C sh1, C sh2) => Array (sh0 ::+ (sh1 ::+ sh2)) a -> Array sh1 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)] -- |
-- >>> Array.fromList (Shape.ZeroBased (5::Int)) ['a'..]
-- StorableArray.fromList (ZeroBased {zeroBasedSize = 5}) "abcde"
--
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
-- |
-- >>> Array.fromTuple ('a',('b','c')) :: Array.Array (Shape.NestedTuple Shape.TupleIndex (X,(X,X))) Char
-- StorableArray.fromList (NestedTuple {getNestedTuple = (Element 0,(Element 1,Element 2))}) "abc"
--
--
--
-- >>> :{ let arr = Array.fromTuple ('a',('b','c')) :: Array.Array (Shape.NestedTuple Shape.TupleAccessor (X,(X,X))) Char
-- in (arr ! fst, arr ! (fst.snd))
-- :}
-- ('a','b')
--
fromTuple :: (NestedTuple tuple, Storable a) => DataTuple tuple a -> Array (NestedTuple ixtype tuple) a
toTuple :: (NestedTuple tuple, Storable a) => Array (NestedTuple ixtype tuple) a -> DataTuple tuple a
-- |
-- >>> :{ let arr = Array.fromRecord ('a' :+ 'b') in
-- let (real:+imag) = Shape.indexRecordFromShape $ Array.shape arr in
-- (arr ! real, arr ! imag)
-- :}
-- ('a','b')
--
fromRecord :: (Traversable f, Storable a) => f a -> Array (Record f) a
toRecord :: (Traversable f, Storable a) => Array (Record f) a -> f 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, Storable a, Ord a) => Array sh a -> (Index sh, 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, Storable a, Ord a) => Array sh a -> (Index sh, 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