Skip to content

Commit

Permalink
Merge branch 'master' of github.com:toothbrush/apa-proj2
Browse files Browse the repository at this point in the history
  • Loading branch information
norm2782 committed Jul 8, 2011
2 parents 9b258fd + 0194cea commit 475f2cc
Show file tree
Hide file tree
Showing 23 changed files with 18 additions and 84 deletions.
3 changes: 1 addition & 2 deletions doc/main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ \subsection{Type System}
} \\
~&~\\
$ [$\emph{t-nil}$] $& \inference{
{\Gamma},C |- \<nil>\ : \tau^{\varphi_1}
& C |- \varphi \sqsupseteq \pi
C |- \varphi \sqsupseteq \pi
}
{
{\Gamma},C |- \<nil>_\pi : [\tau^{\varphi_1}]^{\varphi}
Expand Down
1 change: 0 additions & 1 deletion examples/app.hm

This file was deleted.

1 change: 0 additions & 1 deletion examples/assignment.hm

This file was deleted.

4 changes: 0 additions & 4 deletions examples/case-list.hm

This file was deleted.

4 changes: 0 additions & 4 deletions examples/case.hm

This file was deleted.

4 changes: 0 additions & 4 deletions examples/conditional.hm

This file was deleted.

1 change: 0 additions & 1 deletion examples/const.hm

This file was deleted.

3 changes: 0 additions & 3 deletions examples/generalise-test.hm

This file was deleted.

1 change: 0 additions & 1 deletion examples/identity.hm

This file was deleted.

1 change: 0 additions & 1 deletion examples/inf.hm

This file was deleted.

1 change: 0 additions & 1 deletion examples/letidid.hm

This file was deleted.

4 changes: 0 additions & 4 deletions examples/list-fn.hm

This file was deleted.

1 change: 0 additions & 1 deletion examples/list.hm

This file was deleted.

6 changes: 0 additions & 6 deletions examples/poisoning-case.hm

This file was deleted.

21 changes: 0 additions & 21 deletions examples/poisoning.hm

This file was deleted.

1 change: 0 additions & 1 deletion examples/recursion.hm

This file was deleted.

1 change: 0 additions & 1 deletion examples/recursion2.hm

This file was deleted.

1 change: 0 additions & 1 deletion examples/singleton.hm

This file was deleted.

4 changes: 0 additions & 4 deletions examples/slide.hm

This file was deleted.

3 changes: 0 additions & 3 deletions examples/tuple.hm

This file was deleted.

5 changes: 3 additions & 2 deletions src/APA2/AG/DataTypes.ag
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,12 @@ instance Show Qual where
show (Qual c q) = show c ++ " => " ++ show q

tyAnn :: (Show a1, Show a) => a -> a1 -> [Char]
tyAnn t a = "(" ++ show t ++ ":" ++ show a ++ ")"
tyAnn t a = "(" ++ show t ++ (colonOpt $ show a) ++ ")"

tyAnnCont :: Show a => Map AnnVar SAnn -> a -> AnnVar -> [Char]
tyAnnCont con t a = "(" ++ show t ++ (colonOpt $ a `from` con) ++ ")"

colonOpt :: String -> String
colonOpt [] = ""
colonOpt xs = " : " ++ xs

Expand All @@ -147,7 +148,7 @@ instance Show Ty where
show (List t an) = "(List " ++ show t ++ ") " ++ (colonOpt $ show an)

tyLayout :: Map AnnVar SAnn -> Ty -> String
tyLayout _ (TyVar a) = "" -- a - we probably don't want to see this here.
tyLayout _ (TyVar a) = a -- we probably don't want to see this here.
tyLayout con (Arr t a t' a') = tyAnnCont con t ((fromSAnn a) `from` con) ++ " ➔ " ++ tyAnnCont con t' ((fromSAnn a') `from` con)
tyLayout _ Nat = "Nat"
tyLayout _ Bool = "Bool"
Expand Down
4 changes: 4 additions & 0 deletions src/APA2/AG/Infer.ag
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ SEM MH
lhs.expressions = [(@loc.ty,@copy)]

| Nil
lhs.annotDict = DM.singleton ("L" ++ show @loc.ppoint) @loc.copy
loc.alpha : UNIQUEREF counter
loc.betaf1 : UNIQUEREF counter
loc.betaf2 : UNIQUEREF counter
Expand Down Expand Up @@ -113,6 +114,9 @@ SEM MH

loc.betaf1' = freshAnnVar @loc.betaf1
loc.betaf2' = freshAnnVar @loc.betaf2
lhs.annotDict = DM.singleton ("L" ++ show @loc.ppoint) @loc.copy
`DM.union` @e1.annotDict
`DM.union` @e2.annotDict
loc.pi = mkProgramPoint "L" @loc.ppoint

loc.listTy = List @e1.ty @e1.annotation
Expand Down
27 changes: 10 additions & 17 deletions src/Components.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,38 +46,31 @@ debugFile fl = do
debugInference :: MH -> IO ()
debugInference tm =
do
let (ty, annotation, subst, constraints, exprs, debug, annots) = w tm
putStrLn ("Program: \n " ++ show tm)
print tm
putStrLn ""
let (_, annotation, subst, constraints, _, debug, annots) = w tm
putStrLn "Substitution:"
print subst
putStrLn ""
putStrLn "Ty:"
let solved = worklist constraints
let ty' = applySubst (solutionSubst constraints) (applySubst subst ty)
putStrLn $ ("("++ tyLayout solved ty' ++ ") :::: " ++ ((fromSAnn annotation) `from` solved))
putStrLn ""
putStrLn "Top level annotation: "
print annotation
putStrLn ""
let solved = worklist constraints
let ppoint = DM.findWithDefault (AnnVar "the empty set") (fromSAnn annotation) solved
putStr $ "... which maps to: " ++ show ppoint ++ "\n"
putStr $ DS.fold (\x->(++) (
x ++ " is in fact \"" ++ show (annots DM.! x) ++ "\"\n"
) ) ""
(toSet ppoint)
putStrLn "Annotation dictionary:"
putStrLn (ppMap annots)
putStrLn ""
putStrLn "Constraints: "
print (DS.toList constraints)
putStrLn "\nNew_Constraints: "
printAnalysis solved
putStrLn ""
putStrLn "Expressions: "
printExpressions solved (applySubst (solutionSubst constraints) (applySubst subst exprs))
putStrLn ""
putStrLn "\nNew_Constraints (after solving): "
printAnalysis solved
putStrLn "DEBUG OUTPUT ACCUMULATED IN AG:"
putStrLn debug
putStr horiz
putStrLn "DEBUG OUTPUT FINISHED. NORMAL OUTPUT TO FOLLOW: \n"
analysisResult tm

-- | Prints an analysis result
analysisResult :: MH -> IO ()
Expand Down Expand Up @@ -105,7 +98,7 @@ solutionSubst cs =

-- | Prints a list of expressions
-- Don't print the whole program again, this happens earlier.
--printExpressions :: Show a => [(a, MH)] -> IO ()
printExpressions :: Map AnnVar SAnn -> [(Ty, MH)] -> IO ()
printExpressions _ [] = putStr "\n"
printExpressions con (_:exprs) = mapM_ (\(a,e) -> case e of
CaseAlt _ _ -> putStr ""
Expand Down

0 comments on commit 475f2cc

Please sign in to comment.