src/Pure/unify.ML
changeset 12262 11ff5f47df6e
parent 12231 4a25f04bea61
child 12527 d6c91bc3e49c
equal deleted inserted replaced
12261:ee14db2c571d 12262:11ff5f47df6e
   184        in Envir.Envir{asol=asol,maxidx=maxidx',iTs=iTs'} end
   184        in Envir.Envir{asol=asol,maxidx=maxidx',iTs=iTs'} end
   185        handle Type.TUNIFY => raise CANTUNIFY;
   185        handle Type.TUNIFY => raise CANTUNIFY;
   186 
   186 
   187 fun test_unify_types(args as (T,U,_)) =
   187 fun test_unify_types(args as (T,U,_)) =
   188 let val sot = Sign.string_of_typ (!sgr);
   188 let val sot = Sign.string_of_typ (!sgr);
   189     fun warn() = writeln("Potential loss of completeness: "^sot U^" = "^sot T);
   189     fun warn() = tracing ("Potential loss of completeness: "^sot U^" = "^sot T);
   190     val env' = unify_types(args)
   190     val env' = unify_types(args)
   191 in if is_TVar(T) orelse is_TVar(U) then warn() else ();
   191 in if is_TVar(T) orelse is_TVar(U) then warn() else ();
   192    env'
   192    env'
   193 end;
   193 end;
   194 
   194 
   558   let fun pdp (rbinder,t,u) =
   558   let fun pdp (rbinder,t,u) =
   559         let fun termT t = Sign.pretty_term (!sgr)
   559         let fun termT t = Sign.pretty_term (!sgr)
   560                               (Envir.norm_term env (rlist_abs(rbinder,t)))
   560                               (Envir.norm_term env (rlist_abs(rbinder,t)))
   561             val bsymbs = [termT u, Pretty.str" =?=", Pretty.brk 1,
   561             val bsymbs = [termT u, Pretty.str" =?=", Pretty.brk 1,
   562                           termT t];
   562                           termT t];
   563         in writeln(Pretty.string_of(Pretty.blk(0,bsymbs))) end;
   563         in tracing(Pretty.string_of(Pretty.blk(0,bsymbs))) end;
   564   in  writeln msg;  seq pdp dpairs  end;
   564   in  tracing msg;  seq pdp dpairs  end;
   565 
   565 
   566 
   566 
   567 (*Unify the dpairs in the environment.
   567 (*Unify the dpairs in the environment.
   568   Returns flex-flex disagreement pairs NOT IN normal form. 
   568   Returns flex-flex disagreement pairs NOT IN normal form. 
   569   SIMPL may raise exception CANTUNIFY. *)
   569   SIMPL may raise exception CANTUNIFY. *)
   586 		 else ();
   586 		 else ();
   587 		 Seq.pull (Seq.it_right (add_unify (tdepth+1))
   587 		 Seq.pull (Seq.it_right (add_unify (tdepth+1))
   588 			   (MATCH (env',dp, frigid'@flexflex), reseq)))
   588 			   (MATCH (env',dp, frigid'@flexflex), reseq)))
   589 	  end
   589 	  end
   590 	  handle CANTUNIFY => 
   590 	  handle CANTUNIFY => 
   591 	    (if tdepth > !trace_bound then writeln"Failure node" else ();
   591 	    (if tdepth > !trace_bound then tracing"Failure node" else ();
   592 	     Seq.pull reseq));
   592 	     Seq.pull reseq));
   593      val dps = map (fn(t,u)=> ([],t,u)) tus
   593      val dps = map (fn(t,u)=> ([],t,u)) tus
   594   in sgr := sg;
   594   in sgr := sg;
   595      add_unify 1 ((env,dps), Seq.empty) 
   595      add_unify 1 ((env,dps), Seq.empty) 
   596   end;
   596   end;