packages feed

numhask-array 0.0.1 → 0.0.2

raw patch · 4 files changed

+28/−4 lines, 4 filesdep +deepseq

Dependencies added: deepseq

Files

numhask-array.cabal view
@@ -1,5 +1,5 @@ name: numhask-array-version: 0.0.1+version: 0.0.2 synopsis:   See readme.md description:@@ -22,6 +22,9 @@   Simple cabal-version:   >=1.14+tested-with:+  GHC == 8.0.1,+  GHC == 8.2.1 extra-source-files:   readme.md   stack.yaml@@ -41,6 +44,7 @@     base >= 4.7 && < 5,     numhask >= 0.1.2 && < 0.2,     adjunctions >= 4.0 && < 5,+    deepseq >= 1.4.2.0 && < 2,     distributive >= 0.4 && < 0.6,     ghc-typelits-natnormalise >= 0.4 && < 0.6,     protolude >= 0.1 && < 0.3,
src/NumHask/Array.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveFoldable #-} {-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-}@@ -23,8 +24,12 @@   , SomeArray(..)   , row   , col+  , unsafeRow+  , unsafeCol   , slice+  , unsafeSlice   , index+  , unsafeIndex   , foldAlong   , mapAlong   , concatenate@@ -44,10 +49,13 @@ import Data.Singletons.TypeLits import GHC.Exts import GHC.Show+import GHC.Generics (Generic1)+-- import Control.DeepSeq (NFData1) import NumHask.Array.Constraints import NumHask.Prelude hiding (All, Map, (><), mmult, show, row, col, zipWith, transpose) import qualified Data.Vector as V import qualified NumHask.Prelude as P+import Data.Kind  -- $setup -- >>> :set -XDataKinds@@ -66,7 +74,7 @@ --  [[13, 14, 15, 16], --   [17, 18, 19, 20], --   [21, 22, 23, 24]]]-newtype Array (r :: [Nat]) a = Array (V.Vector a) deriving (Functor, Eq, Foldable)+newtype Array (r :: [Nat]) a = Array (V.Vector a) deriving (Functor, Eq, Foldable, Generic, Generic1, NFData)  -- | an n-dimensional array where shape is specified at the value level data SomeArray a =@@ -103,7 +111,7 @@     ([], x)     ns -instance forall r. (SingI r) => Distributive (Array (r :: [Nat])) where+instance forall r. (SingI r) => Distributive (Array r) where   distribute f =     Array $ V.generate n $ \i -> fmap (\(Array v) -> V.unsafeIndex v i) f     where@@ -167,6 +175,9 @@ instance (Show a, SingI r) => Show (Array (r :: [Nat]) a) where   show = show . someArray +-- instance NFData (Array (r :: [Nat]) a) where+    -- nrf (Array v) = Array (nrf v)+ -- ** Operations -- | outer product --@@ -303,6 +314,10 @@ -- >>> foldAlong (Proxy :: Proxy 1) (\_ -> ([0..3] :: Array '[4] Int)) a -- [[0, 1, 2, 3], --  [0, 1, 2, 3]]+--+-- todo: resolution of a primitive and a scalar eg+--        Expected type: Array '[10] Int -> Array '[] Int+--        Actual type: Array '[10] (Array '[] Int) -> Array '[] Int foldAlong ::      forall s vw uvw uw w a.      ( SingI s
src/NumHask/Array/Constraints.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-}@@ -39,7 +40,9 @@ import Data.Singletons.TH (promote) import Data.Singletons.TypeLits (Nat) import qualified Protolude as P+import GHC.Err (error) +#if ( __GLASGOW_HASKELL__ < 801 ) instance P.Eq Nat where   x == y = P.not (x P./= y)   x /= y = P.not (x P.== y)@@ -49,9 +52,10 @@   x < y = P.not (x P./= y) P.&& P.not (x P.> y)   x <= y = (x P.== y) P.|| P.not (x P.> y)   x >= y = (x P.== y) P.|| P.not (x P.< y)+#endif  (!!) :: [a] -> Nat -> a-[] !! _ = P.error "Data.Singletons.List.!!: index too large"+[] !! _ = error "Data.Singletons.List.!!: index too large" (x:xs) !! n =   if n P.== 0     then x
stack.yaml view
@@ -5,4 +5,5 @@  extra-deps:   - numhask-0.1.2+  # - deepseq-1.4.3.0