Changeset 17
- Timestamp:
- Oct 27, 2013, 9:55:17 PM (12 years ago)
- Location:
- sizechecking
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sizechecking/Constraints.hs
r15 r17 1 -- 2 -- Copyright (C) 2012 Attila Gobi - http://kp.elte.hu/sizechecking 3 -- 4 1 5 {-# LANGUAGE TypeFamilies, MultiParamTypeClasses, FlexibleInstances, 2 6 IncoherentInstances, RankNTypes, ScopedTypeVariables, -
sizechecking/Examples.hs
r14 r17 1 -- 2 -- Copyright (C) 2012 Attila Gobi - http://kp.elte.hu/sizechecking 3 -- 4 1 5 {-# LANGUAGE ScopedTypeVariables, ExistentialQuantification, Rank2Types #-} 2 6 module Examples where -
sizechecking/Lambda.hs
r15 r17 1 -- 2 -- Copyright (C) 2012 Attila Gobi - http://kp.elte.hu/sizechecking 3 -- 4 1 5 module Lambda where 2 6 -
sizechecking/Setup.hs
r11 r17 1 -- 2 -- Copyright (C) 2012 Attila Gobi - http://kp.elte.hu/sizechecking 3 -- 4 1 5 import Distribution.Simple 2 6 main = defaultMain -
sizechecking/SizedExp.hs
r14 r17 2 2 IncoherentInstances, RankNTypes, ScopedTypeVariables, 3 3 FlexibleContexts,UndecidableInstances #-} 4 -- 5 -- Copyright (C) 2012 Attila Gobi - http://kp.elte.hu/sizechecking 6 -- 4 7 5 8 module SizedExp where 6 -- (7 -- SizedExp(..), ($), unQ, prove8 -- ) where9 9 10 import Lambda as L 11 import Constraints 10 import Lambda as L 11 import Constraints 12 12 import Data.Supply 13 13 import Control.Arrow … … 15 15 16 16 class TS b => (Unify se a b) where 17 unify :: (forall a b c. (TS c, Unify se a b) => c -> (Size se c -> a) -> (Size se (c -> b), d)) -> 18 (b -> Size se b -> (Size se b, d)) -> 17 unify :: (forall a b c. (TS c, Unify se a b) => c -> (Size se c -> a) -> (Size se (c -> b), d)) -> 18 (b -> Size se b -> (Size se b, d)) -> 19 19 a -> (Size se b, d) 20 20 … … 56 56 fresh :: TypeKind -> Supply Int -> L 57 57 fresh sig var = fresh' sig [] var 58 where 58 where 59 59 fresh' U _ _ = Unsized 60 60 fresh' V l var = appall (supplyValue var) l … … 74 74 75 75 freshvars :: (TS c, Unify Q a b) => Supply Int -> c -> (Size Q c -> a) -> (Size Q (c -> b), L -> L) 76 freshvars supply q = freshvars' (unify (freshvars s1) (freshvars2 s2)) 77 where 76 freshvars supply q = freshvars' (unify (freshvars s1) (freshvars2 s2)) 77 where 78 78 (s1, s2, s3) = split3 supply 79 79 freshvars' :: (Unify Q a b) => (a -> (Size Q b, L -> L)) -> (Size Q c -> a) -> (Size Q (c -> b), L -> L) 80 80 freshvars' u exp = (QSynt $ sizeof x, \l -> f $ App l fv) 81 81 where 82 (x, f) = u $ exp $ QSynt $ do 83 -- putStrLn $ "[Bind] var="++ show fv ++" of type "++ show (tk q) 82 (x, f) = u $ exp $ QSynt $ do 84 83 return [([], fv)] 85 84 fv = fresh (tk q) s3 … … 100 99 match1 (cond, ltype) = do 101 100 x <- sizeof l 102 -- putStrLn $ "ORIGINAL is " ++ show x103 -- putStrLn $ "[MATCH] ==> " ++ show ltype104 101 let lt = rall$ App (AAbs 18 5 $ Var 18) ltype 105 -- putStrLn $ " --- NIL ---" ++ show lt106 102 nils <- sizeof nil 107 -- print nils108 103 let nilc = foldr addConstraint nils $ Zero lt:cond 109 104 let tx = rall $ App (AAbs 18 5 $ App (Var 5) (Op (Var 18) '-' (Num 1))) ltype 110 105 let txs = rall $App (AAbs 18 5 $ List (Op (Var 18) '-' (Num 1)) (Var 5)) ltype 111 -- putStrLn $ " --- CONS --- "++ show tx ++" <-> "++ show txs112 106 conss <- sizeof $ cons (QSynt$return [([], tx)]) (QSynt$return [([], txs)]) 113 -- print conss114 107 let consc = foldr addConstraint conss $ lt `GEC` Num 1:cond 115 -- print "END MATCH"116 -- print $ nilc ++ consc117 108 return $ nilc ++ consc 118 in QSynt $ sizeof l >>= concatMapM match1 109 in QSynt $ sizeof l >>= concatMapM match1 119 110 120 iff _ l1 l2 = QSynt $ do 111 iff _ l1 l2 = QSynt $ do 121 112 ll1 <- sizeof l1 122 113 ll2 <- sizeof l2 … … 137 128 rr (GEC a b) = rall a `GEC` rall b 138 129 rr (LTC a b) = rall a `LTC` rall b 139 in do 140 l3 <- sizeof sexp 141 -- print l 142 -- print ll 130 in do 131 l3 <- sizeof sexp 143 132 return $ map (\(c,l2) -> Condition (map rr c) ll (rall l2)) l3 144 133 -
sizechecking/Test.hs
r11 r17 1 -- 2 -- Copyright (C) 2012 Attila Gobi - http://kp.elte.hu/sizechecking 3 -- 4 1 5 module Main where 2 6 import Examples (runTests)
Note: See TracChangeset
for help on using the changeset viewer.