source: sizechecking_branches/SE.hs @ 29

Last change on this file since 29 was 15, checked in by gobi, 13 years ago

new solver

File size: 1.6 KB
Line 
1{-# Language GADTs,
2        FlexibleInstances,
3        FlexibleContexts,
4        ScopedTypeVariables,
5        TypeFamilies,
6        NoMonomorphismRestriction,
7        OverlappingInstances #-}
8
9module SE where
10
11import LL
12
13class 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
22instance 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
30x = 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.