aboutsummaryrefslogtreecommitdiff
path: root/test/Main.hs
blob: 8257ff0aef1a3b23d06013e8114be0f7a4665552 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{-# 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 = 24*i + 6*j + 3*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
  print (rtranspose [1,0] arr)