Changeset 17


Ignore:
Timestamp:
Oct 27, 2013, 9:55:17 PM (12 years ago)
Author:
gobi
Message:

copyu

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 
    15{-# LANGUAGE TypeFamilies, MultiParamTypeClasses, FlexibleInstances, 
    26             IncoherentInstances, RankNTypes, ScopedTypeVariables, 
  • sizechecking/Examples.hs

    r14 r17  
     1-- 
     2-- Copyright (C) 2012 Attila Gobi - http://kp.elte.hu/sizechecking 
     3-- 
     4 
    15{-# LANGUAGE ScopedTypeVariables, ExistentialQuantification, Rank2Types #-} 
    26module Examples where 
  • sizechecking/Lambda.hs

    r15 r17  
     1-- 
     2-- Copyright (C) 2012 Attila Gobi - http://kp.elte.hu/sizechecking 
     3-- 
     4 
    15module Lambda where 
    26 
  • sizechecking/Setup.hs

    r11 r17  
     1-- 
     2-- Copyright (C) 2012 Attila Gobi - http://kp.elte.hu/sizechecking 
     3-- 
     4 
    15import Distribution.Simple 
    26main = defaultMain 
  • sizechecking/SizedExp.hs

    r14 r17  
    22             IncoherentInstances, RankNTypes, ScopedTypeVariables, 
    33             FlexibleContexts,UndecidableInstances #-} 
     4-- 
     5-- Copyright (C) 2012 Attila Gobi - http://kp.elte.hu/sizechecking 
     6-- 
    47 
    58module SizedExp  where 
    6 --    ( 
    7 --        SizedExp(..), ($), unQ, prove 
    8 --    ) where 
    99 
    10 import Lambda as L  
    11 import Constraints  
     10import Lambda as L 
     11import Constraints 
    1212import Data.Supply 
    1313import Control.Arrow 
     
    1515 
    1616class 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)) -> 
    1919        a -> (Size se b, d) 
    2020 
     
    5656fresh :: TypeKind -> Supply Int -> L 
    5757fresh sig var = fresh' sig [] var 
    58     where  
     58    where 
    5959    fresh' U _ _ = Unsized 
    6060    fresh' V l var = appall (supplyValue var) l 
     
    7474 
    7575freshvars :: (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  
     76freshvars supply q = freshvars' (unify (freshvars s1) (freshvars2 s2)) 
     77    where 
    7878    (s1, s2, s3) = split3 supply 
    7979    freshvars' :: (Unify Q a b) => (a -> (Size Q b, L -> L)) -> (Size Q c -> a) -> (Size Q (c -> b), L -> L) 
    8080    freshvars' u exp = (QSynt $ sizeof x, \l -> f $ App l fv) 
    8181        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 
    8483            return [([], fv)] 
    8584        fv = fresh (tk q) s3 
     
    10099            match1 (cond, ltype) = do 
    101100                    x <- sizeof l 
    102 --                    putStrLn $ "ORIGINAL is " ++ show x 
    103 --                    putStrLn $ "[MATCH] ==> " ++ show ltype 
    104101                    let lt = rall$  App (AAbs 18 5 $ Var 18) ltype 
    105 --                    putStrLn $ " --- NIL  ---" ++ show lt 
    106102                    nils <- sizeof nil 
    107 --                    print nils 
    108103                    let nilc = foldr addConstraint nils $ Zero lt:cond 
    109104                    let tx = rall $ App (AAbs 18 5 $ App (Var 5) (Op (Var 18) '-' (Num 1))) ltype 
    110105                    let txs = rall $App (AAbs 18 5 $ List (Op (Var 18) '-' (Num 1)) (Var 5)) ltype 
    111 --                    putStrLn $ " --- CONS --- "++ show tx ++" <-> "++ show txs 
    112106                    conss <- sizeof $ cons (QSynt$return [([], tx)]) (QSynt$return [([], txs)]) 
    113 --                    print conss 
    114107                    let consc = foldr addConstraint conss $ lt `GEC` Num 1:cond 
    115 --                    print "END MATCH" 
    116 --                    print  $ nilc ++ consc 
    117108                    return $ nilc ++ consc 
    118         in QSynt $ sizeof l >>= concatMapM match1  
     109        in QSynt $ sizeof l >>= concatMapM match1 
    119110 
    120     iff _ l1 l2 = QSynt $ do  
     111    iff _ l1 l2 = QSynt $ do 
    121112        ll1 <- sizeof l1 
    122113        ll2 <- sizeof l2 
     
    137128                rr (GEC a b) = rall a `GEC` rall b 
    138129                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 
    143132                return $ map (\(c,l2) -> Condition (map rr c) ll (rall l2)) l3 
    144133 
  • sizechecking/Test.hs

    r11 r17  
     1-- 
     2-- Copyright (C) 2012 Attila Gobi - http://kp.elte.hu/sizechecking 
     3-- 
     4 
    15module Main where 
    26import Examples (runTests) 
Note: See TracChangeset for help on using the changeset viewer.