HORIZON HASKELLDocslts/ghc-10.0.x8c2f8e82026-10-19Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8c2f8e8 · 2026-10-19

Modulemassiv-1.0.5.0Haskell2010

Data.Massiv.Core

  • 19 types
  • 17 classes
  • 7 values
  • Packagemassiv-1.0.5.0
  • Exports50
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceCommon.hs
data familydata family Array r ix e
#

The array family. Representations r describe how data is arranged or computed. All arrays have a common property that each index ix always maps to the same unique element e, even if that element does not yet exist in memory and the array has to be computed in order to get the value of that element. Data is always arranged in a nested row-major fashion. Rank of an array is specified by Dimensions ix.

Instances84Monad, Functor, Applicative, Foldable, Traversable, IsList, …
  • Monad (Array DS Ix1)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Stream
  • Functor (Array DI ix)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Interleaved
  • Functor (Array D ix)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Pull
  • Functor (Array DS Ix1)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Stream
  • Functor (Array DW ix)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Windowed
  • Index ix => Functor (Array DL ix)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Push
  • Index ix => Functor (Array B ix)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Index ix => Functor (Array BL ix)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Applicative (Array DS Ix1)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Stream
  • Index ix => Applicative (Array DI ix)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Interleaved
  • Index ix => Applicative (Array D ix)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Pull
  • Foldable (Array DS Ix1)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Stream
  • Index ix => Foldable (Array DI ix)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Interleaved
  • Index ix => Foldable (Array D ix)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Pull

    Row-major sequential folding over a Delayed array.

  • Index ix => Foldable (Array B ix)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed

    Row-major sequential folding over a Boxed array.

  • Index ix => Foldable (Array BL ix)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed

    Row-major sequential folding over a Boxed array.

  • Index ix => Traversable (Array B ix)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Index ix => Traversable (Array BL ix)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • IsList (Array DS Ix1 e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Stream
  • Coercible (Elt ix e) (ListItem ix e) => IsList (Array L ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Core.List
  • (NFData e, IsList (Array L ix e), Ragged L ix e) => IsList (Array BN ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (Storable e, IsList (Array L ix e), Ragged L ix e) => IsList (Array S ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Storable
  • (IsList (Array L ix e), Ragged L ix e) => IsList (Array B ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (IsList (Array L ix e), Ragged L ix e) => IsList (Array BL ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (Prim e, IsList (Array L ix e), Ragged L ix e) => IsList (Array P ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Primitive
  • (Unbox e, IsList (Array L ix e), Ragged L ix e) => IsList (Array U ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Unboxed
  • (Eq e, Index ix) => Eq (Array DI ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Interleaved
  • (Eq e, Index ix) => Eq (Array D ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Pull
  • (Storable e, Eq e, Index ix) => Eq (Array S ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Storable
  • (Index ix, NFData e, Eq e) => Eq (Array BN ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (Index ix, Eq e) => Eq (Array B ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (Index ix, Eq e) => Eq (Array BL ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (Prim e, Eq e, Index ix) => Eq (Array P ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Primitive
  • (Unbox e, Eq e, Index ix) => Eq (Array U ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Unboxed
  • (Ord e, Index ix) => Ord (Array DI ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Interleaved
  • (Ord e, Index ix) => Ord (Array D ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Pull
  • (Storable e, Ord e, Index ix) => Ord (Array S ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Storable
  • (Index ix, NFData e, Ord e) => Ord (Array BN ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (Index ix, Ord e) => Ord (Array B ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (Index ix, Ord e) => Ord (Array BL ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (Prim e, Ord e, Index ix) => Ord (Array P ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Primitive
  • (Unbox e, Ord e, Index ix) => Ord (Array U ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Unboxed
  • Show e => Show (Array DS Ix1 e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed · orphan
  • (Ragged L ix e, Show e) => Show (Array DI ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Interleaved
  • (Ragged L ix e, Show e) => Show (Array D ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Pull
  • (Ragged L ix e, Show e) => Show (Array DL ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed · orphan
  • (Ragged L ix e, Show e) => Show (Array B ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (Ragged L ix e, Show e) => Show (Array BL ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (Ragged L ix e, Show e) => Show (Array L ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Core.List
  • (Ragged L ix e, Show e, NFData e) => Show (Array BN ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (Ragged L ix e, Show e, Storable e) => Show (Array S ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Storable
  • (Ragged L ix e, Show e, Prim e) => Show (Array P ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Primitive
  • (Ragged L ix e, Show e, Unbox e) => Show (Array U ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Unboxed
  • (Ragged L ix e, Load DW ix e, Show e) => Show (Array DW ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Windowed
  • Semigroup (Array DL Ix1 e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Push
  • Semigroup (Array DS Ix1 e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Stream
  • Monoid (Array DL Ix1 e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Push
  • Monoid (Array DS Ix1 e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Stream
  • NFData (Array BN ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed

    O(1) - BN is already in normal form

  • NFData ix => NFData (Array S ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Storable
  • NFData ix => NFData (Array U ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Unboxed
  • Index ix => NFData (Array P ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Primitive
  • (Index ix, NFData e) => NFData (Array B ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (Index ix, NFData e) => NFData (Array BL ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • type Item (Array DS Ix1 e) = eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Stream
  • type Item (Array B ix e) = Item (Array L ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • type Item (Array BL ix e) = Item (Array L ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • type Item (Array BN ix e) = Item (Array L ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • type Item (Array P ix e) = Item (Array L ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Primitive
  • type Item (Array S ix e) = Item (Array L ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Storable
  • type Item (Array U ix e) = Item (Array L ix e)Defined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Unboxed
  • type Item (Array L ix e) = ListItem ix eDefined in massiv-1.0.5.0 · Data.Massiv.Core.List
  • data Array DIDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Interleaved
  • data Array DDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Pull
  • data Array DLDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Push
  • data Array DS Ix1Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Stream
  • data Array DWDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Windowed
  • data Array BDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • data Array BLDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • data Array BNDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • data Array PDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Primitive
  • data Array SDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Storable
  • data Array UDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Unboxed
  • data Array LDefined in massiv-1.0.5.0 · Data.Massiv.Core.List
typetype Vector r e = Array r Ix1 e
#

Type synonym for a single dimension array, or simply a flat vector.

typetype MVector s r e = MArray s r Ix1 e
#

Type synonym for a single dimension mutable array, or simply a flat mutable vector.

typetype Matrix r e = Array r Ix2 e
#

Type synonym for a two-dimentsional array, or simply a matrix.

typetype MMatrix s r e = MArray s r Ix2 e
#

Type synonym for a two-dimentsional mutable array, or simply a mutable matrix.

classclass (Strategy r, Shape r ix) => Load r ix e where
#

Any array that can be computed and loaded into memory

Methods

Instances14Load, …
  • Load DS Ix1 eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Stream

    O(n) - size implementation.

  • Load DW Ix1 eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Windowed
  • Load DW Ix2 eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Windowed
  • Index ix => Load DI ix eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Interleaved
  • Index ix => Load D ix eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Pull
  • Index ix => Load DL ix eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Push
  • Index ix => Load B ix eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Index ix => Load BL ix eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (Shape L ix, Ragged L ix e) => Load L ix eDefined in massiv-1.0.5.0 · Data.Massiv.Core.List
  • (Index ix, NFData e) => Load BN ix eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (Index ix, Storable e) => Load S ix eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Storable
  • (Prim e, Index ix) => Load P ix eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Primitive
  • (Unbox e, Index ix) => Load U ix eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Unboxed
  • (Index (IxN n), Load DW (Ix (n - 1)) e) => Load DW (IxN n) eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Windowed
classclass Load r ix e => Stream r ix e where
#

Methods

Instances9Stream, …
  • Stream DS Ix1 eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Stream
  • Stream L Ix1 eDefined in massiv-1.0.5.0 · Data.Massiv.Core.List
  • Index ix => Stream D ix eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Pull
  • Index ix => Stream B ix eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Index ix => Stream BL ix eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (Index ix, NFData e) => Stream BN ix eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (Index ix, Storable e) => Stream S ix eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Storable
  • (Index ix, Unbox e) => Stream U ix eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Unboxed
  • (Prim e, Index ix) => Stream P ix eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Primitive
classclass (Strategy r, Size r) => Source r e where
#

Arrays that can be used as source to practically any manipulation function.

Instances7Source, …
  • NFData e => Source BN eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Storable e => Source S eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Storable
  • Source D eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Pull
  • Source B eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Source BL eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Prim e => Source P eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Primitive
  • Unbox e => Source U eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Unboxed
classclass Size r where
#

Arrays that have information about their size availible in constant time.

Instances9Size, …
  • Size DIDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Interleaved
  • Size DDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Pull
  • Size DLDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Push
  • Size BDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Size BLDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Size BNDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Size PDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Primitive
  • Size SDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Storable
  • Size UDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Unboxed
classclass Index ix => Shape r ix where
#

The shape of an array. It is different from Size in that it can be applicable to non-square matrices and might not be available in constant time.

Methods

  • linearSizeHint :: Array r ix e -> LengthHint

    O(1) - Check what do we know about the number of elements without doing any work

  • linearSize :: Array r ix e -> Sz1

    O(n) - possibly iterate over the whole array before producing the answer

  • outerSize :: Array r ix e -> Sz ix

    O(n) - Rectangular size of an array that is inferred from looking at the first row in each dimensions. For rectangular arrays this is the same as size

  • maxLinearSize :: Array r ix e -> Maybe Sz1

    O(1) - Get the possible maximum linear size of an immutabe array. If the lookup of size in constant time is not possible, Nothing will be returned. This value will be used as the initial size of the mutable array into which the loading will happen.

  • isNull :: Array r ix e -> Bool

    O(1) - Check whether an array is empty or not.

    Examples
    Example5 expressions
    import Data.Massiv.ArrayisNull $ range Seq (Ix2 10 20) (11 :. 21)FalseisNull $ range Seq (Ix2 10 20) (10 :. 21)TrueisNull (empty :: Array D Ix5 Int)TrueisNull $ sfromList []True
Instances14Shape, …
  • Shape DS Ix1Defined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Stream
  • Shape L Ix1Defined in massiv-1.0.5.0 · Data.Massiv.Core.List
  • Shape L Ix2Defined in massiv-1.0.5.0 · Data.Massiv.Core.List
  • Index ix => Shape DI ixDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Interleaved
  • Index ix => Shape D ixDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Pull
  • Index ix => Shape DL ixDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Push
  • Index ix => Shape DW ixDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Windowed
  • Index ix => Shape B ixDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Index ix => Shape BL ixDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Index ix => Shape BN ixDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Index ix => Shape P ixDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Primitive
  • Index ix => Shape S ixDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Storable
  • Index ix => Shape U ixDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Unboxed
  • (Shape L (Ix (n - 1)), Index (IxN n)) => Shape L (IxN n)Defined in massiv-1.0.5.0 · Data.Massiv.Core.List
classclass Load r ix e => StrideLoad r ix e where
#

Methods

Instances11StrideLoad, …
classclass Source r e => Manifest r e where
#

Manifest arrays are backed by actual memory and values are looked up versus computed as it is with delayed arrays. Because manifest arrays are located in memory their contents can be mutated once thawed into MArray. The process of changed a mutable MArray back into an immutable Array is called freezing.

Instances6Manifest
  • NFData e => Manifest BN eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Storable e => Manifest S eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Storable
  • Manifest B eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Manifest BL eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Prim e => Manifest P eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Primitive
  • Unbox e => Manifest U eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Unboxed
typetype Mutable r e = Manifest r e
#

Deprecated. In favor of Manifest

Starting with massiv-1.0 Mutable and Manifest are synonymous. Since massiv-1.1 it is deprecated and will be removed in massiv-1.2

datadata L
#
Instances13Strategy, Load, Stream, Shape, Ragged, IsList, …
classclass Typeable r => Strategy r where
#
Instances12Strategy, …
  • Strategy DIDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Interleaved
  • Strategy DDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Pull
  • Strategy DLDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Push
  • Strategy DSDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Stream

    For now only Seq strategy.

  • Strategy DWDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Windowed
  • Strategy BDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Strategy BLDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Strategy BNDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Strategy PDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Primitive
  • Strategy SDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Storable
  • Strategy UDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Unboxed
  • Strategy LDefined in massiv-1.0.5.0 · Data.Massiv.Core.List
datadata Comp
#

Computation strategy to use when scheduling work.

Constructors

  • Seq

    Sequential computation

  • ParOn ![Int]

    Schedule workers to run on specific capabilities. Specifying an empty list ParOn [] or using Par will result in utilization of all available capabilities.

  • ParN !Word16

    Specify the number of workers that will be handling all the jobs. Difference from ParOn is that workers can jump between cores. Using ParN 0 will result in using all available capabilities.

Instances5Eq, Show, Semigroup, Monoid, NFData
  • Eq CompDefined in scheduler-2.0.1.0 · Control.Scheduler.Computation
  • Show CompDefined in scheduler-2.0.1.0 · Control.Scheduler.Computation
  • Semigroup CompDefined in scheduler-2.0.1.0 · Control.Scheduler.Computation
  • Monoid CompDefined in scheduler-2.0.1.0 · Control.Scheduler.Computation
  • NFData CompDefined in scheduler-2.0.1.0 · Control.Scheduler.Computation
patternpattern Par :: Comp
#

Parallel computation using all available cores. Same as ParOn []

patternpattern Par' :: Comp
#

Parallel computation using all available cores. Same as ParN 0

methodsetComp :: Comp -> Array r ix e -> Array r ix e
#

Set computation strategy for this array

Example
Example5 expressions
:set -XTypeApplicationsimport Data.Massiv.Arraya = singleton @DL @Ix1 @Int 0aArray DL Seq (Sz1 1)  [ 0 ]setComp (ParN 6) a -- use 6 capabilitiesArray DL (ParN 6) (Sz1 1)  [ 0 ]
datadata WorkerStates ws
#

Each worker is capable of keeping it's own state, that can be share for different schedulers, but not at the same time. In other words using the same WorkerStates on Control.Scheduler.withSchedulerS concurrently will result in an error. Can be initialized with initWorkerStates

Numeric

3 declarations
classclass (Size r, Num e) => FoldNumeric r e where
#
Instances7FoldNumeric, …
  • Num e => FoldNumeric D eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Pull
  • Num e => FoldNumeric B eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Num e => FoldNumeric BL eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (NFData e, Num e) => FoldNumeric BN eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (Storable e, Num e) => FoldNumeric S eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Storable
  • (Prim e, Num e) => FoldNumeric P eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Primitive
  • (Unbox e, Num e) => FoldNumeric U eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Unboxed
classclass FoldNumeric r e => Numeric r e where
#
Instances7Numeric, …
  • Num e => Numeric D eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Delayed.Pull
  • Num e => Numeric B eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • Num e => Numeric BL eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (NFData e, Num e) => Numeric BN eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Boxed
  • (Storable e, Num e) => Numeric S eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Storable
  • (Prim e, Num e) => Numeric P eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Primitive
  • (Unbox e, Num e) => Numeric U eDefined in massiv-1.0.5.0 · Data.Massiv.Array.Manifest.Unboxed

Exceptions

11 declarations
classclass Monad m => MonadThrow (m :: Type -> Type) where
#

A class for monads in which exceptions may be thrown.

Instances should obey the following law:

throwM e >> x = throwM e

In other words, throwing an exception short-circuits the rest of the monadic computation.

Methods

  • throwM :: (HasCallStack, Exception e) => e -> m a

    Throw an exception. Note that this throws when this action is run in the monad m, not when it is applied. It is a generalization of Control.Exception's throwIO.

    Should satisfy the law:

    throwM e >> f = throwM e
  • rethrowM :: Exception e => ExceptionWithContext e -> m a

    A utility to use when rethrowing exceptions, no new backtrace will be attached when rethrowing an exception but you must supply the existing context.

    It is a generalization of Control.Exception's rethrowIO and is only defined using base-4.21 (GHC 9.12) or later.

Instances20MonadThrow, …
datadata IndexException where
#

Exceptions that get thrown when there is a problem with an index, size or dimension.

Constructors

Instances4Eq, Show, Exception, NFData
datadata SizeException where
#

Exception that indicates an issue with an array size.

Constructors

Instances4Eq, Show, Exception, NFData
datadata ShapeException
#

Exception that can happen upon conversion of a ragged type array into the rectangular kind. Which means conversion from lists is susceptible to this exception.

Constructors

Instances3Eq, Show, Exception
classclass (Typeable e, Show e) => Exception e where
#

Any type that you wish to throw or catch as an exception must be an instance of the Exception class. The simplest case is a new exception type directly below the root:

data MyException = ThisException | ThatException
    deriving Show

instance Exception MyException

The default method definitions in the Exception class do what we need in this case. You can now throw and catch ThisException and ThatException as exceptions:

*Main> throw ThisException `catch` \e -> putStrLn ("Caught " ++ show (e :: MyException))
Caught ThisException

In more complicated examples, you may wish to define a whole hierarchy of exceptions:

---------------------------------------------------------------------
-- Make the root exception type for all the exceptions in a compiler

data SomeCompilerException = forall e . Exception e => SomeCompilerException e

instance Show SomeCompilerException where
    show (SomeCompilerException e) = show e

instance Exception SomeCompilerException

compilerExceptionToException :: Exception e => e -> SomeException
compilerExceptionToException = toException . SomeCompilerException

compilerExceptionFromException :: Exception e => SomeException -> Maybe e
compilerExceptionFromException x = do
    SomeCompilerException a <- fromException x
    cast a

---------------------------------------------------------------------
-- Make a subhierarchy for exceptions in the frontend of the compiler

data SomeFrontendException = forall e . Exception e => SomeFrontendException e

instance Show SomeFrontendException where
    show (SomeFrontendException e) = show e

instance Exception SomeFrontendException where
    toException = compilerExceptionToException
    fromException = compilerExceptionFromException

frontendExceptionToException :: Exception e => e -> SomeException
frontendExceptionToException = toException . SomeFrontendException

frontendExceptionFromException :: Exception e => SomeException -> Maybe e
frontendExceptionFromException x = do
    SomeFrontendException a <- fromException x
    cast a

---------------------------------------------------------------------
-- Make an exception type for a particular frontend compiler exception

data MismatchedParentheses = MismatchedParentheses
    deriving Show

instance Exception MismatchedParentheses where
    toException   = frontendExceptionToException
    fromException = frontendExceptionFromException

We can now catch a MismatchedParentheses exception as MismatchedParentheses, SomeFrontendException or SomeCompilerException, but not other types, e.g. IOException:

*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeFrontendException))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeCompilerException))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: IOException))
*** Exception: MismatchedParentheses

Methods

Instances41Exception, …
datadata SomeException
#

The SomeException type is the root of the exception type hierarchy. When an exception of type e is thrown, behind the scenes it is encapsulated in a SomeException.

Instances2Show, Exception
typetype HasCallStack = IP "callStack" CallStack
#

Request a CallStack.

NOTE: The implicit parameter ?callStack :: CallStack is an implementation detail and should not be considered part of the CallStack API, we may decide to change the implementation in the future.

Stateful Monads

3 declarations
classclass MonadIO m => MonadUnliftIO (m :: Type -> Type) where
#

Monads which allow their actions to be run in IO.

While MonadIO allows an IO action to be lifted into another monad, this class captures the opposite concept: allowing you to capture the monadic context. Note that, in order to meet the laws given below, the intuition is that a monad must have no monadic state, but may have monadic context. This essentially limits MonadUnliftIO to ReaderT and IdentityT transformers on top of IO.

Laws. For any function run provided by withRunInIO, it must meet the monad transformer laws as reformulated for MonadUnliftIO:

  • run . return = return
  • run (m >>= f) = run m >>= run . f

Instances of MonadUnliftIO must also satisfy the following laws:

Identity law

withRunInIO (\run -> run m) = m

Inverse law

withRunInIO (\_ -> m) = liftIO m

As an example of an invalid instance, a naive implementation of MonadUnliftIO (StateT s m) might be

withRunInIO inner =
  StateT $ \s ->
    withRunInIO $ \run ->
      inner (run . flip evalStateT s)

This breaks the identity law because the inner run m would throw away any state changes in m.

Instances3MonadUnliftIO
classclass Monad m => MonadIO (m :: Type -> Type) where
#

Monads in which IO computations may be embedded. Any monad built by applying a sequence of monad transformers to the IO monad will be an instance of this class.

Instances should satisfy the following laws, which state that liftIO is a transformer of monads:

Methods

  • liftIO :: IO a -> m a

    Lift a computation from the IO monad. This allows us to run IO computations in any monadic stack, so long as it supports these kinds of operations (i.e. IO is the base monad for the stack).

    Example
    import Control.Monad.Trans.State -- from the "transformers" library
    
    printState :: Show s => StateT s IO ()
    printState = do
      state <- get
      liftIO $ print state

    Had we omitted liftIO, we would have ended up with this error:

    • Couldn't match type ‘IO’ with ‘StateT s IO’
     Expected type: StateT s IO ()
       Actual type: IO ()

    The important part here is the mismatch between StateT s IO () and IO ().

    Luckily, we know of a function that takes an IO a and returns an (m a): liftIO, enabling us to run the program and see the expected results:

    > evalStateT printState "hello"
    "hello"
    
    > evalStateT printState 3
    3
    
Instances18MonadIO, …
classclass Monad m => PrimMonad (m :: Type -> Type) where
#

Class of monads which can perform primitive state-transformer actions.

Associated types

Instances18PrimMonad, …