-- 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 Shape example types 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 cartesianFromSquare :: Square sh -> (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 cartesianFromCube :: Cube sh -> (sh, 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) -- | Dynamically build a shape and its indices in the Construction -- monad. 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.Real.Integral n => Data.Array.Comfort.Shape.AppendSemigroup (Data.Array.Comfort.Shape.OneBased n) instance GHC.Real.Integral n => Data.Array.Comfort.Shape.AppendMonoid (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.AppendSemigroup (Data.Array.Comfort.Shape.ZeroBased n) instance GHC.Real.Integral n => Data.Array.Comfort.Shape.AppendMonoid (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.AppendSemigroup Data.Array.Comfort.Shape.Zero instance Data.Array.Comfort.Shape.AppendMonoid Data.Array.Comfort.Shape.Zero instance (Data.Array.Comfort.Shape.AppendSemigroup sh0, Data.Array.Comfort.Shape.C sh1, GHC.Classes.Eq sh1) => Data.Array.Comfort.Shape.AppendSemigroup (sh0, sh1) instance (Data.Array.Comfort.Shape.AppendSemigroup sh0, Data.Array.Comfort.Shape.C sh1, GHC.Classes.Eq sh1, Data.Array.Comfort.Shape.C sh2, GHC.Classes.Eq sh2) => Data.Array.Comfort.Shape.AppendSemigroup (sh0, sh1, sh2) 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 Data.Array.Comfort.Shape.InvIndexed Data.IntSet.Internal.IntSet 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 shape => Data.Array.Comfort.Shape.InvIndexed (Data.IntMap.Internal.IntMap 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 Data.Array.Comfort.Shape.Indexed Data.IntSet.Internal.IntSet 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 shape => Data.Array.Comfort.Shape.Indexed (Data.IntMap.Internal.IntMap 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 Data.Array.Comfort.Shape.C Data.IntSet.Internal.IntSet 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 shape => Data.Array.Comfort.Shape.C (Data.IntMap.Internal.IntMap 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)] -- | Framework for extracting subsize in unsafeCreateWithSizes. module Data.Array.Comfort.Shape.SubSize newtype T sh nsize Cons :: (sh -> (Int, nsize)) -> T sh nsize [measure] :: T sh nsize -> sh -> (Int, nsize) auto :: C nsize => T (ToShape nsize) nsize atom :: C sh => T sh Int data Sub nsize Sub :: Int -> nsize -> Sub nsize sub :: T sh nsize -> T sh (Sub nsize) pair :: T sh0 nsize0 -> T sh1 nsize1 -> T (sh0, sh1) (nsize0, nsize1) triple :: T sh0 nsize0 -> T sh1 nsize1 -> T sh2 nsize2 -> T (sh0, sh1, sh2) (nsize0, nsize1, nsize2) append :: T sh0 nsize0 -> T sh1 nsize1 -> T (sh0 ::+ sh1) (nsize0 ::+ nsize1) class C nsize where { type ToShape nsize; } newtype Atom sh Atom :: Int -> Atom sh -- | Compute the sizes of a shape and some sub-shapes. evaluate :: C nsize => ToShape nsize -> (Int, nsize) instance Data.Array.Comfort.Shape.C sh => Data.Array.Comfort.Shape.SubSize.C (Data.Array.Comfort.Shape.SubSize.Atom sh) instance Data.Array.Comfort.Shape.SubSize.C sub => Data.Array.Comfort.Shape.SubSize.C (Data.Array.Comfort.Shape.SubSize.Sub sub) instance (Data.Array.Comfort.Shape.SubSize.C nsize0, Data.Array.Comfort.Shape.SubSize.C nsize1) => Data.Array.Comfort.Shape.SubSize.C (nsize0, nsize1) instance (Data.Array.Comfort.Shape.SubSize.C nsize0, Data.Array.Comfort.Shape.SubSize.C nsize1, Data.Array.Comfort.Shape.SubSize.C nsize2) => Data.Array.Comfort.Shape.SubSize.C (nsize0, nsize1, nsize2) instance (Data.Array.Comfort.Shape.SubSize.C nsize0, Data.Array.Comfort.Shape.SubSize.C nsize1) => Data.Array.Comfort.Shape.SubSize.C (nsize0 Data.Array.Comfort.Shape.::+ nsize1) -- | 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 cartesian :: (C sh0, C sh1) => Array sh0 a -> Array sh1 b -> Array (sh0, sh1) (a, b) 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 -- |
-- QC.forAll genArray2 $ \xs -> -- let shape = Array.shape xs in -- Shape.size shape > 0 QC.==> -- QC.forAll (QC.elements $ Shape.indices shape) $ \(ix0,ix1) -> -- Array.pick xs ix0 ! ix1 == xs!(ix0,ix1) --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 -- | Can be an alternative to the enumset package. module Data.Array.Comfort.Bool data Array sh shape :: Array sh -> sh reshape :: (C sh0, C sh1) => sh1 -> Array sh0 -> Array sh1 mapShape :: (C sh0, C sh1) => (sh0 -> sh1) -> Array sh0 -> Array sh1 fromList :: Indexed sh => sh -> [Index sh] -> Array sh toList :: InvIndexed sh => Array sh -> [Index sh] fromSet :: (Indexed sh, Index sh ~ ix, Ord ix) => sh -> Set ix -> Array sh toSet :: (InvIndexed sh, Index sh ~ ix, Ord ix) => Array sh -> Set ix member :: Indexed sh => Index sh -> Array sh -> Bool union :: (Indexed sh, Eq sh) => Array sh -> Array sh -> Array sh difference :: (Indexed sh, Eq sh) => Array sh -> Array sh -> Array sh intersection :: (Indexed sh, Eq sh) => Array sh -> Array sh -> Array sh 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) readEither :: (PrimMonad m, Indexed sh, Storable a) => Array m sh a -> Index sh -> Either String (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) append :: (C shx, C shy, Storable a) => (shx -> shy -> shz) -> Array shx a -> Array shy a -> Array shz 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) instance (Data.Array.Comfort.Shape.AppendSemigroup sh, Foreign.Storable.Storable a) => GHC.Base.Semigroup (Data.Array.Comfort.Storable.Private.Array sh a) instance (Data.Array.Comfort.Shape.AppendMonoid sh, Foreign.Storable.Storable a) => GHC.Base.Monoid (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.Creator newtype Creator arr ptr Creator :: (forall a. (ptr -> IO a) -> IO (arr, a)) -> Creator arr ptr liftIO :: IO ptr -> Creator () ptr liftContT :: (forall a. ContT a IO ptr) -> Creator () ptr pair :: Creator arr0 ptr0 -> Creator arr1 ptr1 -> Creator (arr0, arr1) (ptr0, ptr1) unsafeRun :: PrimMonad m => Creator arr ptr -> (ptr -> IO ()) -> m arr unsafeRunWithResult :: PrimMonad m => Creator arr ptr -> (ptr -> IO b) -> m (arr, b) create :: (C sh, Storable a) => sh -> Creator (Array sh a) (Ptr a) createWithSize :: (C sh, Storable a) => sh -> Creator (Array sh a) (Int, Ptr a) createWithSizes :: (C sh, Storable a) => T sh nsize -> sh -> Creator (Array sh a) (nsize, Ptr a) instance GHC.Base.Functor (Data.Array.Comfort.Storable.Unchecked.Creator.Creator arr) instance Data.Bifunctor.Bifunctor Data.Array.Comfort.Storable.Unchecked.Creator.Creator instance Data.Biapplicative.Biapplicative Data.Array.Comfort.Storable.Unchecked.Creator.Creator 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) unsafeCreateWithSizes :: (PrimMonad m, C sh, Storable a) => T sh nsize -> sh -> (nsize -> 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) unsafeCreateWithSizesAndResult :: (PrimMonad m, C sh, Storable a) => T sh nsize -> sh -> (nsize -> Ptr a -> IO b) -> m (Array sh a, b) _unsafeCreateWithSizesAndResult :: (PrimMonad m, Storable a, C nsize, ToShape nsize ~ sh, C sh) => sh -> (Int -> nsize -> 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 unsafeCreateWithSizes :: (C sh, Storable a) => T sh nsize -> sh -> (nsize -> Ptr a -> IO ()) -> Array sh a unsafeCreateWithAutoSizes :: (C sh, sh ~ ToShape nsize, C nsize, Storable a) => sh -> (nsize -> 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 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, 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.Dim2 type Array2 sh0 sh1 = Array (sh0, sh1) singleRow :: Array width a -> Array2 () width a flattenRow :: Array2 () width a -> Array width a singleColumn :: Array height a -> Array2 height () a flattenColumn :: Array2 height () a -> Array height a -- |
-- QC.forAll genNonEmptyArray2 $ \xs -> -- QC.forAll (QC.elements $ Shape.indices $ Array.shape xs) $ \(ix0,ix1) -> -- Array2.takeRow xs ix0 ! ix1 == xs!(ix0,ix1) --takeRow :: (Indexed sh0, C sh1, Storable a) => Array2 sh0 sh1 a -> Index sh0 -> Array sh1 a toRowArray :: (C sh0, C sh1, Storable a) => Array2 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 == Array2.fromRowArray (snd $ Array.shape xs) (Array2.toRowArray xs) --fromRowArray :: (C sh0, C sh1, Eq sh1, Storable a) => sh1 -> Array sh0 (Array sh1 a) -> Array2 sh0 sh1 a -- |
-- QC.forAll genArray2 $ \xs -> -- let (Shape.ZeroBased m, width) = Array.shape xs in -- QC.forAll (QC.choose (0, m)) $ \k -> -- let ys = Array.reshape -- (Shape.ZeroBased k ::+ Shape.ZeroBased (m-k), width) xs in -- ys == Array2.above (Array2.takeTop ys) (Array2.takeBottom ys) --above :: (C heightA, C heightB) => (C width, Eq width) => Storable a => Array2 heightA width a -> Array2 heightB width a -> Array2 (heightA ::+ heightB) width a infixr 2 `above` -- |
-- QC.forAll genArray2 $ \xs -> -- let (height, Shape.ZeroBased n) = Array.shape xs in -- QC.forAll (QC.choose (0, n)) $ \k -> -- let ys = Array.reshape -- (height, Shape.ZeroBased k ::+ Shape.ZeroBased (n-k)) xs in -- ys == Array2.beside (Array2.takeLeft ys) (Array2.takeRight ys) --beside :: (C height, Eq height) => (C widthA, C widthB) => Storable a => Array2 height widthA a -> Array2 height widthB a -> Array2 height (widthA ::+ widthB) a infixr 3 `beside` takeTop :: (C heightA, C heightB, C width, Storable a) => Array2 (heightA ::+ heightB) width a -> Array2 heightA width a takeBottom :: (C heightA, C heightB, C width, Storable a) => Array2 (heightA ::+ heightB) width a -> Array2 heightB width a takeLeft :: (C height, C widthA, C widthB, Storable a) => Array2 height (widthA ::+ widthB) a -> Array2 height widthA a takeRight :: (C height, C widthA, C widthB, Storable a) => Array2 height (widthA ::+ widthB) a -> Array2 height widthB a -- | Only the outer BoxedArray need to be non-empty. -- --
-- >>> let shapeR0 = shapeInt 2; shapeR1 = shapeInt 3 in
-- let shapeC0 = shapeInt 3; shapeC1 = shapeInt 2 in
-- let block sh a = Array.replicate sh (a::Word16) in
-- Array2.fromBlockArray
-- (Map.singleton 'A' shapeR0 <> Map.singleton 'B' shapeR1)
-- (Map.singleton '1' shapeC0 <> Map.singleton '2' shapeC1) $
-- BoxedArray.fromList (Set.fromList "AB", Set.fromList "12")
-- [block (shapeR0,shapeC0) 0, block (shapeR0,shapeC1) 1,
-- block (shapeR1,shapeC0) 2, block (shapeR1,shapeC1) 3]
-- StorableArray.fromList (fromList [('A',ZeroBased {... 2}),('B',ZeroBased {... 3})],fromList [('1',ZeroBased {... 3}),('2',ZeroBased {... 2})]) [0,0,0,1,1,0,0,0,1,1,2,2,2,3,3,2,2,2,3,3,2,2,2,3,3]
--
--
-- -- QC.forAll genArray2 $ \blockA1 -> -- QC.forAll genArray2 $ \blockB2 -> -- let shapeR0 = fst $ Array.shape blockA1 in -- let shapeC0 = snd $ Array.shape blockA1 in -- let shapeR1 = fst $ Array.shape blockB2 in -- let shapeC1 = snd $ Array.shape blockB2 in -- QC.forAll (genArrayForShape (shapeR0, shapeC1)) $ \blockA2 -> -- QC.forAll (genArrayForShape (shapeR1, shapeC0)) $ \blockB1 -> -- let blocked = -- BoxedArray.fromList (Set.fromList "AB", Set.fromList "12") -- [blockA1, blockA2, blockB1, blockB2] in -- -- transpose (Array2.fromNonEmptyBlockArray blocked) -- QC.=== -- Array2.fromNonEmptyBlockArray -- (TestBoxedArray.transpose (fmap transpose blocked)) ---- --
-- QC.forAll genArray2 $ \blockA1 -> -- QC.forAll genArray2 $ \blockB2 -> -- QC.forAll genArray2 $ \blockC3 -> -- let shapeR0 = fst $ Array.shape blockA1 in -- let shapeC0 = snd $ Array.shape blockA1 in -- let shapeR1 = fst $ Array.shape blockB2 in -- let shapeC1 = snd $ Array.shape blockB2 in -- let shapeR2 = fst $ Array.shape blockC3 in -- let shapeC2 = snd $ Array.shape blockC3 in -- QC.forAll (genArrayForShape (shapeR0, shapeC1)) $ \blockA2 -> -- QC.forAll (genArrayForShape (shapeR0, shapeC2)) $ \blockA3 -> -- QC.forAll (genArrayForShape (shapeR1, shapeC0)) $ \blockB1 -> -- QC.forAll (genArrayForShape (shapeR1, shapeC2)) $ \blockB3 -> -- QC.forAll (genArrayForShape (shapeR2, shapeC0)) $ \blockC1 -> -- QC.forAll (genArrayForShape (shapeR2, shapeC1)) $ \blockC2 -> -- let blocked = -- BoxedArray.fromList (Set.fromList "ABC", Set.fromList "123") -- [blockA1, blockA2, blockA3, -- blockB1, blockB2, blockB3, -- blockC1, blockC2, blockC3] in -- -- transpose (Array2.fromNonEmptyBlockArray blocked) -- QC.=== -- Array2.fromNonEmptyBlockArray -- (TestBoxedArray.transpose (fmap transpose blocked)) --fromNonEmptyBlockArray :: (Ord row, C height, Eq height) => (Ord column, C width, Eq width) => Storable a => Array (Set row, Set column) (Array2 height width a) -> Array2 (Map row height) (Map column width) a -- | Explicit parameters for the shape of the result matrix allow for -- working with arrays of zero rows or columns. -- --
-- >>> (id :: Id (array (height, Map Char ShapeInt) Word16)) $
-- Array2.fromBlockArray
-- (Map.singleton 'A' (shapeInt 2) <> Map.singleton 'B' (shapeInt 3))
-- Map.empty $
-- BoxedArray.fromList (Set.fromList "AB", Set.empty) []
-- StorableArray.fromList (fromList [('A',ZeroBased {... 2}),('B',ZeroBased {... 3})],fromList []) []
--
--
-- -- QC.forAll genArray2 $ \block -> -- let height = Map.singleton 'A' $ fst $ Array.shape block in -- let width = Map.singleton '1' $ snd $ Array.shape block in -- -- Array.reshape (height,width) block -- QC.=== -- Array2.fromBlockArray height width -- (BoxedArray.replicate (Set.singleton 'A', Set.singleton '1') block) --fromBlockArray :: (Ord row, C height, Eq height) => (Ord column, C width, Eq width) => Storable a => Map row height -> Map column width -> Array (Set row, Set column) (Array2 height width a) -> Array2 (Map row height) (Map column width) a -- |
-- QC.forAll genArray2 $ \blockA1 -> -- QC.forAll genArray2 $ \blockB2 -> -- let shapeR0 = fst $ Array.shape blockA1 in -- let shapeC0 = snd $ Array.shape blockA1 in -- let shapeR1 = fst $ Array.shape blockB2 in -- let shapeC1 = snd $ Array.shape blockB2 in -- let shapeR = shapeR0::+shapeR1::+Shape.Zero in -- let shapeC = shapeC0::+shapeC1::+Shape.Zero in -- QC.forAll (genArrayForShape (shapeR0, shapeC1)) $ \blockA2 -> -- QC.forAll (genArrayForShape (shapeR1, shapeC0)) $ \blockB1 -> -- let blocked = -- BoxedArray.fromList (Set.fromList "AB", Set.fromList "12") -- [blockA1, blockA2, blockB1, blockB2] in -- -- Array.reshape (shapeR, shapeC) -- (Array2.fromNonEmptyBlockArray blocked) -- QC.=== -- Array2.fromBlocks shapeR shapeC Proxy -- blockA1 blockA2 -- blockB1 blockB2 --fromBlocks :: (ShapeSequence height, ShapeSequence width, Storable a) => height -> width -> Proxy a -> BlockFunction height width a (Array2 height width a) type family BlockFunction heights widths a r type family RowFunction height widths a r class (C sh) => ShapeSequence sh switchSequence :: ShapeSequence sh => f Zero -> (forall sh0 shs. (C sh0, Eq sh0, ShapeSequence shs) => f (sh0 ::+ shs)) -> f sh data BlockArray shape a type BlockMatrix height width = BlockArray (height, width) class Block block -- |
-- QC.forAll genArray2 $ \blockA1 ->
-- QC.forAll genArray2 $ \blockB3 ->
-- QC.forAll
-- (liftA2
-- (\char0 char1 -> Shape.Range (min char0 char1) (max char0 char1))
-- (QC.choose ('a','k')) (QC.choose ('a','k'))) $
-- \shapeC1 ->
-- let shapeR0 = fst $ Array.shape blockA1 in
-- let shapeC0 = snd $ Array.shape blockA1 in
-- let shapeR1 = fst $ Array.shape blockB3 in
-- let shapeC2 = snd $ Array.shape blockB3 in
-- QC.forAll (genArrayForShape (shapeR0, shapeC1)) $ \blockA2 ->
-- QC.forAll (genArrayForShape (shapeR0, shapeC2)) $ \blockA3 ->
-- QC.forAll (genArrayForShape (shapeR1, shapeC0)) $ \blockB1 ->
-- QC.forAll (genArrayForShape (shapeR1, shapeC1)) $ \blockB2 ->
--
-- Array2.fromBlockMatrix
-- (blockA1 &||| Array2.beside blockA2 blockA3
-- &===
-- blockB1 &||| blockB2 &||| blockB3)
-- QC.===
-- Array.reshape
-- (shapeR0::+shapeR1, shapeC0::+shapeC1::+shapeC2)
-- (Array2.fromBlocks
-- (shapeR0::+shapeR1::+Shape.Zero)
-- (shapeC0::+shapeC1::+shapeC2::+Shape.Zero)
-- Proxy
-- blockA1 blockA2 blockA3
-- blockB1 blockB2 blockB3)
--
--
--
-- QC.forAll
-- (liftA2
-- (\char0 char1 -> Shape.Range (min char0 char1) (max char0 char1))
-- (QC.choose ('a','k')) (QC.choose ('a','k'))) $
-- \shapeR0 ->
-- QC.forAll
-- (liftA2 Shape.Shifted (QC.choose (-10,10)) (QC.choose (0,10::Int))) $
-- \shapeR1 ->
-- let shapeR2 = () in
-- QC.forAll (fmap Shape.ZeroBased (QC.choose (0,10::Int))) $
-- \shapeC0 ->
-- QC.forAll (fmap Shape.OneBased (QC.choose (0,10::Int))) $
-- \shapeC1 ->
-- let shapeC2 :: Shape.Enumeration Ordering
-- shapeC2 = Shape.Enumeration in
--
-- QC.forAll (genArrayForShape (shapeR0, shapeC0)) $ \blockA1 ->
-- QC.forAll (genArrayForShape (shapeR0, shapeC1)) $ \blockA2 ->
-- QC.forAll (genArrayForShape (shapeR0, shapeC2)) $ \blockA3 ->
-- QC.forAll (genArrayForShape (shapeR1, shapeC0)) $ \blockB1 ->
-- QC.forAll (genArrayForShape (shapeR1, shapeC1)) $ \blockB2 ->
-- QC.forAll (genArrayForShape (shapeR1, shapeC2)) $ \blockB3 ->
-- QC.forAll (genArrayForShape (shapeR2, shapeC0)) $ \blockC1 ->
-- QC.forAll (genArrayForShape (shapeR2, shapeC1)) $ \blockC2 ->
-- QC.forAll (genArrayForShape (shapeR2, shapeC2)) $ \blockC3 ->
--
-- Array2.fromBlockMatrix
-- (blockA1 &||| blockA2 &||| blockA3
-- &===
-- blockB1 &||| blockB2 &||| blockB3
-- &===
-- blockC1 &||| blockC2 &||| blockC3)
-- QC.===
-- Array2.beside
-- (Array2.above blockA1 $ Array2.above blockB1 blockC1)
-- (Array2.above
-- (Array2.beside blockA2 blockA3)
-- (Array2.beside
-- (Array2.above blockB2 blockC2)
-- (Array2.above blockB3 blockC3)))
--
fromBlockMatrix :: (C height, C width, Storable a) => BlockMatrix height width a -> Array2 height width a
block :: (Block block, C height, C width, Storable a) => block (height, width) a -> BlockMatrix height width a
blockAbove :: Eq width => BlockMatrix heightA width a -> BlockMatrix heightB width a -> BlockMatrix (heightA ::+ heightB) width a
blockBeside :: Eq height => BlockMatrix height widthA a -> BlockMatrix height widthB a -> BlockMatrix height (widthA ::+ widthB) a
(&===) :: (Block blockA, Block blockB) => (C heightA, C heightB) => (C width, Eq width) => Storable a => blockA (heightA, width) a -> blockB (heightB, width) a -> BlockMatrix (heightA ::+ heightB) width a
infixr 2 &===
(&|||) :: (Block blockA, Block blockB) => (C height, Eq height) => (C widthA, C widthB) => Storable a => blockA (height, widthA) a -> blockB (height, widthB) a -> BlockMatrix height (widthA ::+ widthB) a
infixr 3 &|||
instance Data.Array.Comfort.Storable.Dim2.Block Data.Array.Comfort.Storable.Dim2.BlockArray
instance Data.Array.Comfort.Storable.Dim2.Block Data.Array.Comfort.Storable.Private.Array
instance Data.Array.Comfort.Storable.Dim2.ShapeSequence Data.Array.Comfort.Shape.Zero
instance (Data.Array.Comfort.Shape.C sh, GHC.Classes.Eq sh, Data.Array.Comfort.Storable.Dim2.ShapeSequence shs) => Data.Array.Comfort.Storable.Dim2.ShapeSequence (sh Data.Array.Comfort.Shape.::+ shs)
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 (shapeInt 5) ['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
fromIntMap :: Storable a => IntMap a -> Array IntSet a
toIntMap :: Storable a => Array IntSet a -> IntMap a
-- |
-- >>> Array.fromTuple ('a',('b','c')) :: Array (Shape.NestedTuple Shape.TupleIndex (X,(X,X))) Char
-- StorableArray.fromList (NestedTuple {getNestedTuple = (Element 0,(Element 1,Element 2))}) "abc"
--
--
--
-- >>> let arr :: Array (Shape.NestedTuple Shape.TupleAccessor (X,(X,X))) Char
-- arr = Array.fromTuple ('a',('b','c'))
-- 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
replicate :: (C sh, Storable a) => 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
-- | Deprecated: Use fromBlockArray instead.
fromBlockArray1 :: (Ord k, C shape, Storable a) => Array (Set k) (Array shape a) -> Array (Map k shape) a
-- | Deprecated: Use Storable.Dim2.fromBlockArray instead.
fromBlockArray2 :: (Ord row, C height, Eq height) => (Ord column, C width, Eq width) => Storable a => Map row height -> Map column width -> Array (Set row, Set column) (Array (height, width) a) -> Array (Map row height, Map column width) a
-- | Deprecated: Use Storable.Dim2.fromNonEmptyBlockArray instead.
fromNonEmptyBlockArray2 :: (Ord row, C height, Eq height) => (Ord column, C width, Eq width) => Storable a => Array (Set row, Set column) (Array (height, width) a) -> Array (Map row height, Map column width) 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
-- | Deprecated: Use Storable.Dim2.takeRow instead.
pick :: (Indexed sh0, C sh1, Storable a) => Array (sh0, sh1) a -> Index sh0 -> Array sh1 a
-- | Deprecated: Use Storable.Dim2.toRowArray instead.
toRowArray :: (Indexed sh0, C sh1, Storable a) => Array (sh0, sh1) a -> Array sh0 (Array sh1 a)
-- | Deprecated: Use Storable.Dim2.fromRowArray instead.
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 -- |
-- >>> Array.takeSet (Set.fromList [0,2,4,7,13]) (Array.vectorFromList [3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3::Word8]) -- StorableArray... (... [0,2,4,7,13]) [3,4,5,6,7] --takeSet :: (Indexed sh, Index sh ~ ix, Ord ix, Storable a) => Set ix -> Array sh a -> Array (Set ix) a -- |
-- >>> Array.takeIntSet (IntSet.fromList [0,2,4,7,13]) (Array.vectorFromList [3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3::Word8]) -- StorableArray... (... [0,2,4,7,13]) [3,4,5,6,7] --takeIntSet :: (Indexed sh, Index sh ~ Int, Storable a) => IntSet -> Array sh a -> Array IntSet 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