Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/branches/primop-branch-2/src/compiler/ElabData/types/typesutil.sml
ViewVC logotype

Diff of /sml/branches/primop-branch-2/src/compiler/ElabData/types/typesutil.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1962, Fri Jul 7 21:32:42 2006 UTC revision 1967, Mon Jul 10 22:27:13 2006 UTC
# Line 189  Line 189 
189        (f x) :: ((shareMap f l) handle SHARE => l)        (f x) :: ((shareMap f l) handle SHARE => l)
190        handle SHARE => x :: (shareMap f l)        handle SHARE => x :: (shareMap f l)
191    
192  (*** This function should be merged with instantiatePoly soon --zsh ***)  (*** This function should be merged with instantiatePoly soon --zsh
193         dbm: don't agree! ***)
194  fun applyTyfun(TYFUN{arity,body},args) =  fun applyTyfun(TYFUN{arity,body},args) =
195    let fun subst(IBOUND n) = List.nth(args,n)    let fun subst(IBOUND n) = List.nth(args,n)
196          | subst(CONty(tyc,args)) = CONty(tyc, shareMap subst args)          | subst(CONty(tyc,args)) = CONty(tyc, shareMap subst args)
# Line 202  Line 203 
203        else body        else body
204    end    end
205    
206    fun applyPoly(POLYty{tyfun,...}, args) =
207        applyTyfun(tyfun, args)
208      | applyPoly _ = bug "TypesUtil.applyPoly"
209    
210  fun mapTypeFull f =  fun mapTypeFull f =
211      let fun mapTy ty =      let fun mapTy ty =
212              case ty              case ty
# Line 254  Line 259 
259       in eq(prune ty, prune ty')       in eq(prune ty, prune ty')
260      end      end
261    
262    fun equalTypeP(POLYty{sign=s1,tyfun=TYFUN{body=b1,...}},
263                   POLYty{sign=s2,tyfun=TYFUN{body=b2,...}}) =
264        if s1 = s2 then equalType(b1,b2) else false
265      | equalTypeP(POLYty _, t2) = false
266      | equalTypeP(t1, POLYty _) = false
267      | equalTypeP(t1,t2) = equalType(t1,t2)
268    
269  local  local
270    (* making dummy argument lists to be used in equalTycon *)    (* making dummy argument lists to be used in equalTycon *)
271      val generator = Stamps.newGenerator()      val generator = Stamps.newGenerator()
# Line 521  Line 533 
533                    | _ => equalType(spec,actual))                    | _ => equalType(spec,actual))
534      end handle CompareTypes => false      end handle CompareTypes => false
535    
 (* matchTypes -- one-way matching of actual to spec type; yields  
                  list of instantiation metavariables  
    Parameters:  
         spec -- specification type  
         actual -- actual type  
    Returns:  
         (specGenericTvs, -- spec metavariables that are generalized  
                             in the match  
          actParamTvs) -- metavariables in actual type that are instantiations  
                         of spec metavariables in match  
    Invariant: specGenericTvs are always instantiated but  
               actInstTvs are never generalized (because they are only  
               meaningful in this function and are immediately generalized  
               away.  
    Comments: compareTypes does pruning so there is no need to prune in  
              this function or anywhere else that uses compareTypes or  
              matchTypes.  
   
    matchTypes is used in SigMatch for matching structures (matchStr1) only  
   
    dbm:This doesn't work. After instantiating spec and actual, have to do  
      a one-way match of spec (specinst) against (more general) actual (actinst),  
      and this match should instantiate the tyvars in actParamTvs to capture  
      the parameters that instantiate actual to produce specinst.  
  *)  
 (*  
 fun matchTypes (specTy, actualTy) =  
     (* If specTy is an instance of actualTy,  
        then match, otherwise give up. *)  
     if compareTypes(specTy, actualTy) then  
         (* compareTypes should have already determined that the  
            two types match. *)  
         let  
             val (actinst, actParamTvs) = instantiatePoly actualTy  
             val (specinst, specGenericTvs) = instantiatePoly specTy  
         in  
             (* These metavariable lists may be empty if either actualTy  
                or specTy are monomorphic *)  
             (specGenericTvs, actParamTvs)  
         end  
     else ([], [])  
 *)  
536  (* matchInstTypes: ty * ty -> (tyvar list * tyvar list) option  (* matchInstTypes: ty * ty -> (tyvar list * tyvar list) option
537   * The first argument is a spec type (e.g. from a signature spec),   * The first argument is a spec type (e.g. from a signature spec),
538   * while the second is a potentially more general actual type. The   * while the second is a potentially more general actual type. The

Legend:
Removed from v.1962  
changed lines
  Added in v.1967

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0