{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
module Data.Massiv.Array.Manifest.List (
fromList,
fromListsM,
fromLists',
toList,
toLists,
toLists2,
toLists3,
toLists4,
) where
import Data.Massiv.Array.Manifest.Internal
import Data.Massiv.Array.Ops.Fold (foldrInner)
import Data.Massiv.Array.Ops.Fold.Internal (foldrFB)
import Data.Massiv.Core.Common
import Data.Massiv.Core.List
import qualified GHC.Exts as GHC (IsList (..), build)
fromList
:: forall r e
. Manifest r e
=> Comp
-> [e]
-> Vector r e
fromList :: forall r e. Manifest r e => Comp -> [e] -> Vector r e
fromList = forall r ix e.
(HasCallStack, Ragged L ix e, Manifest r e) =>
Comp -> [ListItem ix e] -> Array r ix e
fromLists'
{-# INLINE fromList #-}
fromListsM
:: forall r ix e m
. (Ragged L ix e, Manifest r e, MonadThrow m)
=> Comp
-> [ListItem ix e]
-> m (Array r ix e)
fromListsM :: forall r ix e (m :: * -> *).
(Ragged L ix e, Manifest r e, MonadThrow m) =>
Comp -> [ListItem ix e] -> m (Array r ix e)
fromListsM Comp
comp = forall r ix e r' (m :: * -> *).
(Manifest r e, Ragged r' ix e, MonadThrow m) =>
Array r' ix e -> m (Array r ix e)
fromRaggedArrayM forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall r ix e. Strategy r => Comp -> Array r ix e -> Array r ix e
setComp Comp
comp forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall ix e.
IsList (Array L ix e) =>
[ListItem ix e] -> Array L ix e
fromListToListArray
{-# INLINE fromListsM #-}
fromListToListArray
:: forall ix e
. GHC.IsList (Array L ix e)
=> [ListItem ix e]
-> Array L ix e
fromListToListArray :: forall ix e.
IsList (Array L ix e) =>
[ListItem ix e] -> Array L ix e
fromListToListArray = forall l. IsList l => [Item l] -> l
GHC.fromList
{-# INLINE fromListToListArray #-}
fromLists'
:: forall r ix e
. (HasCallStack, Ragged L ix e, Manifest r e)
=> Comp
-> [ListItem ix e]
-> Array r ix e
fromLists' :: forall r ix e.
(HasCallStack, Ragged L ix e, Manifest r e) =>
Comp -> [ListItem ix e] -> Array r ix e
fromLists' Comp
comp = forall r ix e r'.
(HasCallStack, Manifest r e, Ragged r' ix e) =>
Array r' ix e -> Array r ix e
fromRaggedArray' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall r ix e. Strategy r => Comp -> Array r ix e -> Array r ix e
setComp Comp
comp forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall ix e.
IsList (Array L ix e) =>
[ListItem ix e] -> Array L ix e
fromListToListArray
{-# INLINE fromLists' #-}
toList :: (Index ix, Source r e) => Array r ix e -> [e]
toList :: forall ix r e. (Index ix, Source r e) => Array r ix e -> [e]
toList !Array r ix e
arr = forall a. (forall b. (a -> b -> b) -> b -> b) -> [a]
GHC.build (\e -> b -> b
c b
n -> forall ix r e b.
(Index ix, Source r e) =>
(e -> b -> b) -> b -> Array r ix e -> b
foldrFB e -> b -> b
c b
n Array r ix e
arr)
{-# INLINE toList #-}
toLists
:: (Ragged L ix e, Shape r ix, Source r e)
=> Array r ix e
-> [ListItem ix e]
toLists :: forall ix e r.
(Ragged L ix e, Shape r ix, Source r e) =>
Array r ix e -> [ListItem ix e]
toLists = forall l. IsList l => l -> [Item l]
GHC.toList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall ix e r.
(Ragged L ix e, Shape r ix, Source r e) =>
Array r ix e -> Array L ix e
toListArray
{-# INLINE toLists #-}
toLists2 :: (Source r e, Index ix, Index (Lower ix)) => Array r ix e -> [[e]]
toLists2 :: forall r e ix.
(Source r e, Index ix, Index (Lower ix)) =>
Array r ix e -> [[e]]
toLists2 = forall ix r e. (Index ix, Source r e) => Array r ix e -> [e]
toList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall ix r e a.
(Index (Lower ix), Index ix, Source r e) =>
(e -> a -> a) -> a -> Array r ix e -> Array D (Lower ix) a
foldrInner (:) []
{-# INLINE toLists2 #-}
toLists3
:: (Source r e, Index ix, Index (Lower ix), Index (Lower (Lower ix))) => Array r ix e -> [[[e]]]
toLists3 :: forall r e ix.
(Source r e, Index ix, Index (Lower ix),
Index (Lower (Lower ix))) =>
Array r ix e -> [[[e]]]
toLists3 = forall ix r e. (Index ix, Source r e) => Array r ix e -> [e]
toList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall ix r e a.
(Index (Lower ix), Index ix, Source r e) =>
(e -> a -> a) -> a -> Array r ix e -> Array D (Lower ix) a
foldrInner (:) [] forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall ix r e a.
(Index (Lower ix), Index ix, Source r e) =>
(e -> a -> a) -> a -> Array r ix e -> Array D (Lower ix) a
foldrInner (:) []
{-# INLINE toLists3 #-}
toLists4
:: ( Source r e
, Index ix
, Index (Lower ix)
, Index (Lower (Lower ix))
, Index (Lower (Lower (Lower ix)))
)
=> Array r ix e
-> [[[[e]]]]
toLists4 :: forall r e ix.
(Source r e, Index ix, Index (Lower ix), Index (Lower (Lower ix)),
Index (Lower (Lower (Lower ix)))) =>
Array r ix e -> [[[[e]]]]
toLists4 = forall ix r e. (Index ix, Source r e) => Array r ix e -> [e]
toList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall ix r e a.
(Index (Lower ix), Index ix, Source r e) =>
(e -> a -> a) -> a -> Array r ix e -> Array D (Lower ix) a
foldrInner (:) [] forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall ix r e a.
(Index (Lower ix), Index ix, Source r e) =>
(e -> a -> a) -> a -> Array r ix e -> Array D (Lower ix) a
foldrInner (:) [] forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall ix r e a.
(Index (Lower ix), Index ix, Source r e) =>
(e -> a -> a) -> a -> Array r ix e -> Array D (Lower ix) a
foldrInner (:) []
{-# INLINE toLists4 #-}