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

SCM Repository

[smlnj] View of /sml/branches/SMLNJ/src/MLRISC/library/annotations.sml
ViewVC logotype

View of /sml/branches/SMLNJ/src/MLRISC/library/annotations.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 245 - (download) (annotate)
Sat Apr 17 18:47:12 1999 UTC (21 years, 1 month ago) by monnier
File size: 920 byte(s)
version 110.16
structure Annotations : ANNOTATIONS =
struct

   type annotation = exn
   type annotations = annotation list

   exception COMMENT of string

   fun toString(COMMENT s) = s
     | toString e          = "<"^exnName e^">"

   (*
    * Look ma, a real use of generative exceptions!
    *)
   fun 'a new() =
   let exception Annotation of 'a
       fun get [] = NONE
         | get (Annotation x::_) = SOME x
         | get (_::l) = get l
       fun put(x,[]) = [Annotation x]
         | put(x,Annotation _::l) = Annotation x::l
         | put(x,y::l) = y::put(x,l)
       fun rmv [] = []
         | rmv (Annotation _::l) = rmv l
         | rmv (x::l) = x::rmv l
   in  { get=get, put=put, rmv=rmv }
   end

   fun get f []     = NONE
     | get f (x::l) = case f x of NONE => get f l | x => x  

   fun rmv f [] = []
     | rmv f (x::l) = if f x then rmv f l else x::rmv f l

   fun put(x,l) = x::l 

end

(* 
 * $Log$
 *)

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