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 /smlnj-lib/trunk/Util/format-comb.sml
ViewVC logotype

Diff of /smlnj-lib/trunk/Util/format-comb.sml

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

revision 2920, Thu Dec 13 21:02:47 2007 UTC revision 2921, Tue Dec 18 04:18:29 2007 UTC
# Line 8  Line 8 
8   *   *
9   * See format-comb-sig.sml for details.   * See format-comb-sig.sml for details.
10   *)   *)
   
11  structure FormatComb :> FORMAT_COMB =  structure FormatComb :> FORMAT_COMB =
12    struct    struct
13    
# Line 16  Line 15 
15      type ('a, 'b) fragment = 'a format -> 'b format      type ('a, 'b) fragment = 'a format -> 'b format
16      type 'a glue           = ('a, 'a) fragment      type 'a glue           = ('a, 'a) fragment
17      type ('a, 't) element  = ('a, 't -> 'a) fragment      type ('a, 't) element  = ('a, 't -> 'a) fragment
18        type 'a gg = 'a glue * 'a glue
19    
20      type place = int * int -> int      type place = int * int -> int
21      fun left (a, i)   = a - i      fun left (a, i)   = a - i
# Line 81  Line 81 
81      fun nl fm         = text "\n" fm      fun nl fm         = text "\n" fm
82      fun tab fm        = text "\t" fm      fun tab fm        = text "\t" fm
83    
84      fun listg' ld sep rd g l =      fun seqg (foldr : ('x * 'a gg -> 'a gg) -> 'a gg -> 'c -> 'a gg) sep g s =
85          let fun loop [] = nothing          #2 (foldr (fn (x, (f, r)) => (sep, g x o f o r)) (nothing, nothing) s)
86                | loop [x] = g x      fun listg g l = text "[" o seqg List.foldr (text ", ") g l o text "]"
               | loop (h :: t) = g h o sep o loop t  
         in ld o loop l o rd  
         end  
     fun listg g l = listg' (text "[") (text ", ") (text "]") g l  
   
87      fun optiong g NONE = text "NONE"      fun optiong g NONE = text "NONE"
88        | optiong g (SOME a) = text "SOME(" o g a o text ")"        | optiong g (SOME a) = text "SOME(" o g a o text ")"
89    
90      fun list' ld sep rd e = elem (listg' ld sep rd (glue e))      fun seq foldr sep e = elem (seqg foldr sep (glue e))
91      fun list e = elem (listg (glue e))      fun list e = elem (listg (glue e))
92      fun option e = elem (optiong (glue e))      fun option e = elem (optiong (glue e))
93    

Legend:
Removed from v.2920  
changed lines
  Added in v.2921

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