src/Pure/General/source.ML
changeset 6640 d2e8342bf5c3
parent 6181 128646d4a975
child 6681 08a084c79d8b
equal deleted inserted replaced
6639:d399db16964c 6640:d2e8342bf5c3
    15   val exhaust: ('a, 'b) source -> 'a list
    15   val exhaust: ('a, 'b) source -> 'a list
    16   val mapfilter: ('a -> 'b option) -> ('a, 'c) source -> ('b, ('a, 'c) source) source
    16   val mapfilter: ('a -> 'b option) -> ('a, 'c) source -> ('b, ('a, 'c) source) source
    17   val filter: ('a -> bool) -> ('a, 'b) source -> ('a, ('a, 'b) source) source
    17   val filter: ('a -> bool) -> ('a, 'b) source -> ('a, ('a, 'b) source) source
    18   val of_list: 'a list -> ('a, 'a list) source
    18   val of_list: 'a list -> ('a, 'a list) source
    19   val of_string: string -> (string, string list) source
    19   val of_string: string -> (string, string list) source
    20   val of_file: Path.T -> (string, string list) source * Position.T
       
    21   val decorate_prompt_fn: (string -> string) ref
    20   val decorate_prompt_fn: (string -> string) ref
    22   val of_stream: TextIO.instream -> TextIO.outstream -> (string, unit) source
    21   val of_stream: TextIO.instream -> TextIO.outstream -> (string, unit) source
    23   val tty: (string, unit) source
    22   val tty: (string, unit) source
    24   val source': 'a -> 'b * ('b -> bool) -> ('a * 'b list -> 'c list * ('a * 'b list)) ->
    23   val source': 'a -> 'b * ('b -> bool) -> ('a * 'b list -> 'c list * ('a * 'b list)) ->
    25     ('a * 'b list -> 'd * ('a * 'b list)) option ->
    24     ('a * 'b list -> 'd * ('a * 'b list)) option ->
   107 fun drain_list _ xs = (take (limit, xs), drop (limit, xs));
   106 fun drain_list _ xs = (take (limit, xs), drop (limit, xs));
   108 
   107 
   109 fun of_list xs = make_source [] xs default_prompt drain_list;
   108 fun of_list xs = make_source [] xs default_prompt drain_list;
   110 val of_string = of_list o explode;
   109 val of_string = of_list o explode;
   111 
   110 
   112 fun of_file raw_path =
       
   113   let val path = Path.expand raw_path
       
   114   in (of_string (File.read path), Position.line_name 1 (quote (Path.pack path))) end;
       
   115 
       
   116 
   111 
   117 (* stream source *)
   112 (* stream source *)
   118 
   113 
   119 val decorate_prompt_fn = ref (fn s:string => s);
   114 val decorate_prompt_fn = ref (fn s:string => s);
   120 
   115