Rev | Line | |
---|
[15] | 1 | {-# Language GADTs, |
---|
| 2 | FlexibleInstances, |
---|
| 3 | FlexibleContexts, |
---|
| 4 | ScopedTypeVariables, |
---|
| 5 | TypeFamilies, |
---|
| 6 | NoMonomorphismRestriction, |
---|
| 7 | OverlappingInstances #-} |
---|
| 8 | |
---|
| 9 | module SE where |
---|
| 10 | |
---|
| 11 | import LL |
---|
| 12 | |
---|
| 13 | class SizeExp l where |
---|
| 14 | type List l :: * -> * |
---|
| 15 | list :: l Int -> l (Arr l Int b) -> l (List l b) |
---|
| 16 | aabs :: (l Int -> l (Arr l Int a) -> l b) -> l (Arr l (List l a) b) |
---|
| 17 | shift :: l (Arr l Int a) -> l Int -> l (Arr l Int a) -> l (Arr l Int a) |
---|
| 18 | undef :: l Bottom |
---|
| 19 | unsized :: l () |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | instance SizeExp R where |
---|
| 23 | type List R = RList |
---|
| 24 | undef = R $ Bottom |
---|
| 25 | unsized = R $ () |
---|
| 26 | list s f = R $ RList (unR s, unR . (unR f) . R ) |
---|
| 27 | aabs e = R $ ( \(RList (s,f)) -> (e (R s) (R (R . f . unR))) ) . unR |
---|
| 28 | shift a s c = R $ \i -> if (unR i)<(unR s) then unR a i else unR c i |
---|
| 29 | |
---|
| 30 | x = aabs (\s _ -> s) `app` list (lit 0) (labs $ \_ -> undef) |
---|
| 31 | --y = list 0 $ labs $ \_ -> undef |
---|
| 32 | --conss = labs $ \x -> aabs $ \ys yf -> list (ys + 1) $ shift yf ys (labs $ \_ -> x) |
---|
| 33 | --concats = aabs $ \xs xf -> (aabs $ \ys yf -> list (xs+ys) $ shift xf xs yf) |
---|
| 34 | --maps = labs $ \x -> aabs $ \ys yf -> list ys ( x `app` yf ) |
---|
| 35 | --l0 = list (lit 0) (labs $ \_ -> unsized) |
---|
| 36 | --l1 = list (lit 1) (labs $ \_ -> unsized) |
---|
| 37 | --l2 = list (lit 2) (labs $ \_ -> unsized) |
---|
| 38 | --l00 = list (lit 0) (labs $ \_ -> list (lit 0) (labs $ \_ -> unsized)) |
---|
| 39 | --l10 = list (lit 1) (labs $ \_ -> list (lit 0) (labs $ \_ -> unsized)) |
---|
| 40 | --l01 = list (lit 0) (labs $ \_ -> list (lit 1) (labs $ \_ -> unsized)) |
---|
| 41 | --l11 = list (lit 1) (labs $ \_ -> list (lit 1) (labs $ \_ -> unsized)) |
---|
| 42 | --l12 = list (lit 1) (labs $ \_ -> list (lit 2) (labs $ \_ -> unsized)) |
---|
Note: See
TracBrowser
for help on using the repository browser.