blob: 23638131997e7e50cb957f800aeaa9bd9672991b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeApplications #-}
module Main where
import Data.Array.Nested
arr :: Ranked I2 (Shaped [2, 3] (Double, Int))
arr = rgenerate (3 :$: 4 :$: ZSR) $ \(i :.: j :.: ZIR) ->
sgenerate @[2, 3] $ \(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 I2 (Ranked I1 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
|