remove debugging statements

This commit is contained in:
Paul Chiusano 2018-09-01 10:53:27 -04:00
parent 58b9b37573
commit 26f06a644a
2 changed files with 6 additions and 12 deletions

View File

@ -11,7 +11,7 @@
module Unison.Type where module Unison.Type where
import Debug.Trace -- import Debug.Trace
import Control.Monad (join) import Control.Monad (join)
import Data.Functor.Identity (runIdentity) import Data.Functor.Identity (runIdentity)
import Data.Functor.Const (Const(..), getConst) import Data.Functor.Const (Const(..), getConst)
@ -365,7 +365,6 @@ generalize t = foldr (forall (ABT.annotation t)) t $ Set.toList (ABT.freeVars t)
-- we leave the signature alone as it's unclear what transformation the user might -- we leave the signature alone as it's unclear what transformation the user might
-- want. The user is responsible for using effect variables as they wish. -- want. The user is responsible for using effect variables as they wish.
generalizeEffects :: forall v a . Var v => Int -> AnnotatedType v a -> AnnotatedType v a generalizeEffects :: forall v a . Var v => Int -> AnnotatedType v a -> AnnotatedType v a
generalizeEffects arity t | traceShow ("generalizeEffects"::String, arity, t) False = undefined
generalizeEffects _arity t | usesEffects t = t generalizeEffects _arity t | usesEffects t = t
generalizeEffects arity t = generalizeEffects arity t =
let let
@ -387,7 +386,7 @@ generalizeEffects arity t =
t' = go (arity - 1) t t' = go (arity - 1) t
tr = if Set.member e (ABT.freeVars t') then forall at e t' tr = if Set.member e (ABT.freeVars t') then forall at e t'
else t' else t'
in traceShow ("generalizeEffects"::String, arity, tr) tr in tr
usesEffects :: Var v => AnnotatedType v a -> Bool usesEffects :: Var v => AnnotatedType v a -> Bool
usesEffects t = getAny . getConst $ ABT.visit go t where usesEffects t = getAny . getConst $ ABT.visit go t where

View File

@ -671,7 +671,6 @@ synthesize e = scope (InSynthesize e) $ do
body <- pure $ ABT.bindInheritAnnotation body (Term.var() arg) body <- pure $ ABT.bindInheritAnnotation body (Term.var() arg)
withEffects0 [et] $ check body ot withEffects0 [et] $ check body ot
ctx <- getContext ctx <- getContext
traceM $ "et = " ++ show (apply ctx et)
pure $ Type.arrow l it (Type.effect l (apply ctx <$> [et]) ot) pure $ Type.arrow l it (Type.effect l (apply ctx <$> [et]) ot)
go (Term.LetRecNamed' [] body) = synthesize body go (Term.LetRecNamed' [] body) = synthesize body
go (Term.LetRec' letrec) = do go (Term.LetRec' letrec) = do
@ -868,11 +867,7 @@ annotateLetRecBindings letrec = do
bindingArities = Term.arity . snd <$> bindings bindingArities = Term.arity . snd <$> bindings
appendContext $ context (Marker e1 : map existential es ++ zipWith Ann vs bindingTypes) appendContext $ context (Marker e1 : map existential es ++ zipWith Ann vs bindingTypes)
-- check each `bi` against `ei`; sequencing resulting contexts -- check each `bi` against `ei`; sequencing resulting contexts
Foldable.for_ (zip bindings bindingTypes) $ \((_,b), t) -> do Foldable.for_ (zip bindings bindingTypes) $ \((_,b), t) -> check b t
traceM "starting binding check"
check b t
t2 <- applyM t
traceM $ "t = " ++ show t2
-- compute generalized types `gt1, gt2 ...` for each binding `b1, b2...`; -- compute generalized types `gt1, gt2 ...` for each binding `b1, b2...`;
-- add annotations `v1 : gt1, v2 : gt2 ...` to the context -- add annotations `v1 : gt1, v2 : gt2 ...` to the context
(_, _, ctx2) <- breakAt (Marker e1) <$> getContext (_, _, ctx2) <- breakAt (Marker e1) <$> getContext
@ -978,7 +973,7 @@ check e0 t0 = scope (InCheck e0 t0) $ do
-- | `subtype ctx t1 t2` returns successfully if `t1` is a subtype of `t2`. -- | `subtype ctx t1 t2` returns successfully if `t1` is a subtype of `t2`.
-- This may have the effect of altering the context. -- This may have the effect of altering the context.
subtype :: forall v loc . (Var v, Ord loc) => Type v loc -> Type v loc -> M v loc () subtype :: forall v loc . (Var v, Ord loc) => Type v loc -> Type v loc -> M v loc ()
subtype tx ty | True && traceShow ("subtype"::String, tx, ty) False = undefined subtype tx ty | debugEnabled && traceShow ("subtype"::String, tx, ty) False = undefined
subtype tx ty = scope (InSubtype tx ty) $ subtype tx ty = scope (InSubtype tx ty) $
do ctx <- getContext; go (ctx :: Context v loc) tx ty do ctx <- getContext; go (ctx :: Context v loc) tx ty
where -- Rules from figure 9 where -- Rules from figure 9
@ -1042,7 +1037,7 @@ subtype tx ty = scope (InSubtype tx ty) $
-- a subtype of the given type, updating the context -- a subtype of the given type, updating the context
-- in the process. -- in the process.
instantiateL :: (Var v, Ord loc) => B.Blank loc -> v -> Type v loc -> M v loc () instantiateL :: (Var v, Ord loc) => B.Blank loc -> v -> Type v loc -> M v loc ()
instantiateL _ v t | True && traceShow ("instantiateL"::String, v, t) False = undefined instantiateL _ v t | debugEnabled && traceShow ("instantiateL"::String, v, t) False = undefined
instantiateL blank v t = scope (InInstantiateL v t) $ do instantiateL blank v t = scope (InInstantiateL v t) $ do
getContext >>= \ctx -> case Type.monotype t >>= solve ctx v of getContext >>= \ctx -> case Type.monotype t >>= solve ctx v of
Just ctx -> setContext ctx -- InstLSolve Just ctx -> setContext ctx -- InstLSolve
@ -1099,7 +1094,7 @@ instantiateL blank v t = scope (InInstantiateL v t) $ do
-- a supertype of the given type, updating the context -- a supertype of the given type, updating the context
-- in the process. -- in the process.
instantiateR :: (Var v, Ord loc) => Type v loc -> B.Blank loc -> v -> M v loc () instantiateR :: (Var v, Ord loc) => Type v loc -> B.Blank loc -> v -> M v loc ()
instantiateR t _ v | True && traceShow ("instantiateR"::String, t, v) False = undefined instantiateR t _ v | debugEnabled && traceShow ("instantiateR"::String, t, v) False = undefined
instantiateR t blank v = scope (InInstantiateR t v) $ instantiateR t blank v = scope (InInstantiateR t v) $
getContext >>= \ctx -> case Type.monotype t >>= solve ctx v of getContext >>= \ctx -> case Type.monotype t >>= solve ctx v of
Just ctx -> setContext ctx -- InstRSolve Just ctx -> setContext ctx -- InstRSolve