blob: 2972eca22fa189ca58fff52bff04653f3015b04b (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleContexts #-}
module T9662 where
data Exp a = Exp
data (a:.b) = a:.b
type family Plain e :: *
type instance Plain (Exp a) = a
type instance Plain (a:.b) = Plain a :. Plain b
class (Plain (Unlifted pattern) ~ Tuple pattern) => Unlift pattern where
type Unlifted pattern
type Tuple pattern
modify :: (Unlift pattern) =>
pattern ->
(Unlifted pattern -> a) ->
Exp (Tuple pattern) -> Exp (Plain a)
modify p f = undefined
data Atom a = Atom
atom :: Atom a
atom = Atom
instance (Unlift pa, int ~ Atom Int) => Unlift (pa :. int) where
type Unlifted (pa :. int) = Unlifted pa :. Exp Int
type Tuple (pa :. int) = Tuple pa :. Int
data Shape sh = Shape
backpermute ::
(Exp sh -> Exp sh') ->
(Exp sh' -> Exp sh) ->
Shape sh -> Shape sh'
backpermute = undefined
test :: Shape (sh:.k:.m:.n) -> Shape (sh:.m:.n:.k)
test =
backpermute
(modify (atom:.atom:.atom:.atom)
(\(sh:.k:.m:.n) -> (sh:.m:.n:.k)))
id
-- With this arg instead of just 'id', it worked
-- (modify (atom:.atom:.atom:.atom)
-- (\(ix:.m:.n:.k) -> (ix:.k:.m:.n)))
|