# ***************************************************************************
#
# Some utility functions needed for tk.
#
# This class is organized as follows: a few functions (like fst and
# snd) live on its toplevel. All other functions are in packages
# ListUtil (for functions on lists), string_util (for functions on strings),
# and file_util (functions for file access). This is in order to allow
# the class basic_utilities being opened in most of tk's modules, without
# running into danger of hiding existing identifiers.
#
# Originally, this module was based on the gofer prelude, but most of the
# functions there are in the new standard basis library.
#
# $Date: 2001/03/30 13:39:00 $
# $Revision: 3.0 $
# Author: bu/cxl (Last modification by $Author: 2cxl $)
#
# (C) 1998, Bremen Institute for Safe Systems, Universitaet Bremen
#
# **************************************************************************
# Compiled by:
#
src/lib/tk/src/tk.sublibapi Basic_Utilities {
fst: (X, Y) -> X;
snd: (X, Y) -> Y;
pair: ((Z -> X), (Z -> Y)) -> Z -> (X, Y);
eq: _X -> _X -> Bool;
upto: (Int, Int) -> List( Int );
inc: Ref( Int ) -> Int; # Increment and return new value.
curry: ((X, Y) -> Z) -> X -> Y -> Z;
uncurry: (X -> Y -> Z) -> (X, Y) -> Z;
twist: ((X, Y) -> Z) -> (Y, X) -> Z;
# The empty action
k0: X -> Void;
package list_util:
api {
getx: (X -> Bool) -> List(X) -> Exception -> X;
update_val: (X -> Bool) -> X -> List(X) -> List(X);
drop_while: (X -> Bool) -> List(X) -> List(X);
break: (X -> Bool) -> List(X) -> (List(X), List(X));
sort: ((X, X) -> Bool) -> List(X) -> List(X);
prefix: List( _X ) -> List( _X ) -> Bool;
join: List(X) -> List( List(X)) -> List(X);
#
# join y [x_1, ..., x_n] == x1@y@x2@...@y@x_n
};
package string_util:
api {
words: String -> List( String );
# Specialized utility functions:
#
join: String -> List( String ) -> String;
break_at_dot: String -> (String, String);
to_int: String -> Int;
from_int: Int -> String;
adapt_string: String -> String;
all: (Char -> Bool) -> String -> Bool;
is_dot: Char -> Bool;
is_comma: Char -> Bool;
is_linefeed: Char -> Bool;
is_open_paren: Char -> Bool;
is_close_paren: Char -> Bool;
};
package file_util:
api {
execute: (String, List( String )) -> (file::Input_Stream, file::Output_Stream);
exec: (String, List( String )) -> Bool;
# user name and current date in a readable format
who_am_i: Void -> String;
what_time_is_it: Void -> String;
};
};