diff options
author | Tom Smeding <t.j.smeding@uu.nl> | 2024-04-03 15:06:52 +0200 |
---|---|---|
committer | Tom Smeding <t.j.smeding@uu.nl> | 2024-04-03 15:06:52 +0200 |
commit | ffa91484573a2c2be3f6ae2190c768e7a77e8b5c (patch) | |
tree | 361f08f2f65eda1128c5d03da2a45305d66e0351 /test/Main.hs | |
parent | 6520c4e4bc39b7315f4f9416fe68b883cfdde8ec (diff) |
Simple usage example
Diffstat (limited to 'test/Main.hs')
-rw-r--r-- | test/Main.hs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/Main.hs b/test/Main.hs new file mode 100644 index 0000000..156e0a5 --- /dev/null +++ b/test/Main.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE TypeApplications #-} +module Main where + +import Data.Array.Nested + + +arr :: Ranked N2 (Shaped [N2, N3] (Double, Int)) +arr = rgenerate (3 ::: 4 ::: IZR) $ \(i ::: j ::: IZR) -> + sgenerate @[N2, N3] (2 ::$ 3 ::$ IZS) $ \(k ::$ l ::$ IZS) -> + let s = i + j + k + l + in (fromIntegral s, s) + +foo :: (Double, Int) +foo = arr `rindex` (2 ::: 1 ::: IZR) `sindex` (1 ::$ 1 ::$ IZS) + +main :: IO () +main = do + print arr + print foo |