From 583607f51dac5b1d0a97d97ed6594498b1ecc731 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 20 May 2024 21:14:03 +0200 Subject: Rename 'test' component to 'example' --- example/Main.hs | 29 +++++++++++++++++++++++++++++ ox-arrays.cabal | 4 ++-- test/Main.hs | 29 ----------------------------- 3 files changed, 31 insertions(+), 31 deletions(-) create mode 100644 example/Main.hs delete mode 100644 test/Main.hs diff --git a/example/Main.hs b/example/Main.hs new file mode 100644 index 0000000..76c75c2 --- /dev/null +++ b/example/Main.hs @@ -0,0 +1,29 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE TypeApplications #-} +module Main where + +import Data.Array.Nested + + +arr :: Ranked 2 (Shaped [2, 3] (Double, Int)) +arr = rgenerate (3 :$: 4 :$: ZSR) $ \(i :.: j :.: ZIR) -> + sgenerate (SNat @2 :$$ SNat @3 :$$ ZSS) $ \(k :.$ l :.$ ZIS) -> + let s = 24*i + 6*j + 3*k + l + in (fromIntegral s, s) + +foo :: (Double, Int) +foo = arr `rindex` (2 :.: 1 :.: ZIR) `sindex` (1 :.$ 1 :.$ ZIS) + +bad :: Ranked 2 (Ranked 1 Double) +bad = rgenerate (3 :$: 4 :$: ZSR) $ \(i :.: j :.: ZIR) -> + rgenerate (i :$: ZSR) $ \(k :.: ZIR) -> + let s = 24*i + 6*j + 3*k + in fromIntegral s + +main :: IO () +main = do + print arr + print foo + print (rtranspose [1,0] arr) + -- print bad diff --git a/ox-arrays.cabal b/ox-arrays.cabal index a144629..d39d5e5 100644 --- a/ox-arrays.cabal +++ b/ox-arrays.cabal @@ -20,12 +20,12 @@ library default-language: Haskell2010 ghc-options: -Wall -test-suite test +test-suite example type: exitcode-stdio-1.0 main-is: Main.hs build-depends: ox-arrays, base - hs-source-dirs: test + hs-source-dirs: example default-language: Haskell2010 ghc-options: -Wall diff --git a/test/Main.hs b/test/Main.hs deleted file mode 100644 index 76c75c2..0000000 --- a/test/Main.hs +++ /dev/null @@ -1,29 +0,0 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE GADTs #-} -{-# LANGUAGE TypeApplications #-} -module Main where - -import Data.Array.Nested - - -arr :: Ranked 2 (Shaped [2, 3] (Double, Int)) -arr = rgenerate (3 :$: 4 :$: ZSR) $ \(i :.: j :.: ZIR) -> - sgenerate (SNat @2 :$$ SNat @3 :$$ ZSS) $ \(k :.$ l :.$ ZIS) -> - let s = 24*i + 6*j + 3*k + l - in (fromIntegral s, s) - -foo :: (Double, Int) -foo = arr `rindex` (2 :.: 1 :.: ZIR) `sindex` (1 :.$ 1 :.$ ZIS) - -bad :: Ranked 2 (Ranked 1 Double) -bad = rgenerate (3 :$: 4 :$: ZSR) $ \(i :.: j :.: ZIR) -> - rgenerate (i :$: ZSR) $ \(k :.: ZIR) -> - let s = 24*i + 6*j + 3*k - in fromIntegral s - -main :: IO () -main = do - print arr - print foo - print (rtranspose [1,0] arr) - -- print bad -- cgit v1.2.3-70-g09d2