Copyright | (c) Evgeny Poberezkin |
---|---|
License | MIT |
Maintainer | evgeny@poberezkin.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
This package provides "orphan" IsList
instances for Array
s
with Integral
indices up to 5 dimensions to allow initializing
Array
s from [nested] lists using OverloadedLists
GHC extension.
Examples:
>>>
["one","two","three"] :: Array Int String
array (0,2) [(0,"one"),(1,"two"),(2,"three")]
>>>
[[0,1,2], [10,11,12]] :: Array (Int, Int) Int
array ((0,0),(1,2)) [((0,0),0),((0,1),1),((0,2),2),((1,0),10),((1,1),11),((1,2),12)]
If any of the nested lists contains different number of elements for the same dimension, the array creation will fail.
>>>
[[1],[2,3]] :: Array (Int, Int) Int
array *** Exception: Error in array index
Documentation
The IsList
class and its methods are intended to be used in
conjunction with the OverloadedLists extension.
Since: base-4.7.0.0
Instances
fromList :: IsList l => [Item l] -> l #
The fromList
function constructs the structure l
from the given
list of Item l
toList :: IsList l => l -> [Item l] #
The toList
function extracts a list of Item l
from the structure l
.
It should satisfy fromList . toList = id.
Orphan instances
IsList (Array Int e) Source # | |
IsList (Array Int8 e) Source # | |
IsList (Array Int16 e) Source # | |
IsList (Array Int32 e) Source # | |
IsList (Array Int64 e) Source # | |
IsList (Array Integer e) Source # | |
IsList (Array Natural e) Source # | |
IsList (Array Word e) Source # | |
IsList (Array Word8 e) Source # | |
IsList (Array Word16 e) Source # | |
IsList (Array Word32 e) Source # | |
IsList (Array Word64 e) Source # | |
(Integral i, Integral j, Ix i, Ix j) => IsList (Array (i, j) e) Source # | |
(Integral i, Integral j, Integral k, Ix i, Ix j, Ix k) => IsList (Array (i, j, k) e) Source # | |
(Integral i, Integral j, Integral k, Integral m, Ix i, Ix j, Ix k, Ix m) => IsList (Array (i, j, k, m) e) Source # | |
(Integral i, Integral j, Integral k, Integral m, Integral n, Ix i, Ix j, Ix k, Ix m, Ix n) => IsList (Array (i, j, k, m, n) e) Source # | |