mllib The spec value describes the action of the argument, and whether it expects a following parameter. "parse specs f use" parses the arguments given by Sys.argv according to the argument processing specifications "specs". Arguments begin with "-". Non-arguments are passed to "f" in order. "use" is printed as part of the usage line if an error occurs. Permitted arguments are specified using triples: (arg, action, help). Actions are: Unit(f): call f, no subseq. arg Set(br): set ref to 'true', no subseq. arg. Clear(br): set ref to 'false, no subseq. arg. String(f): pass the subseq. arg to f Int(f): pass the subseq. arg to f Float(f): pass the subseq. arg to f Rest(f): pass all subseq. args to f in order "usage specs use" prints the help for each argument. A simple command-line argument processor. Big_int compatability module for arbitrary sized integers. Add second buffer to the first. Read the given number of bytes as ASCII and add the resulting string to the buffer. Warning: this assumes an ASCII encoding for the I/O channel, i.e. it uses Pervasives.really_input and then use ascii_to_string to produce the string to add. Add character to the buffer. Add string to the buffer. Given a string, start position and length add that substring to the buffer. Clears the buffer. Gets the string built from the buffer. Create a buffer with suggested size. Number of characters in the buffer. Clears the buffer (same as Buffer.clear). Imperative buffers for building strings, a shallow interface to [[System.Text.StringBuilder]] Apply a function to each element of the collection, threading an 'accumulator' argument through the computation. If the elements are "i0...iN" then computes "f (... (f s i0)...) iN" Apply a function to each element of the collection, threading an 'accumulator' argument through the computation. If the elements are "i0...iN" then computes "f i0 (...(f iN s))". Apply the given function to each element of the collection. Apply the given function to each element of the collection. The integer passed to the function indicates the index of element. Build a new collection whose elements are the results of applying the given function to each of the elements of the collection. Build a new collection whose elements are the results of applying the given function to each of the elements of the collection. The integer index passed to the function indicates the index of element being transformed. Build a collection from the given list Build a list from the given collection Byte arrays. Arrays of bytes are guaranteed to be type-compatible with the C# byte[] type, regardless of the version of .NET used. "dirname" and "basename" decompose a filename into a directory name and a filename, i.e. "concat (dirname s) (basename s) = s" "check_suffix f s" returns true if filename "f" ends in suffix "s", e.g. check_suffix "abc.ml" ".ml" returns true. "chop_extension f" removes the extension, if any, from the given filename. Assuming "check_suffix f s" holds, "chop_suffix f s" returns the filename "f" with the suffix "s" removed. "concat a b" returns System.IO.Path.Combine(a,b), i.e. the two names conjoined by the appropriate directory separator character for this architecture. The name used for the current directory on this OS. "dirname" and "basename" decompose a filename into a directory name and a filename, i.e. "concat (dirname s) (basename s) = s" Return true if the filename has a "." extension Returns true if the path is relative to the current directory but does not begin with an explicit "." or ".." Is the path is relative to the current directory or absolute. "parent_dir_name" returns the name for the directory above the current directory on this OS. "quote s" is designed for use to quote a filename when using it for a system command. It returns ("\'" ^ s ^ "\'"). "temp_file f s" returns a hitherto unused new file name. "f" and "s" are hints as to a suitable file name and suffix for the file. Common filename operations. This module is included to make it possible to cross-compile code with other ML compilers. See also [[System.IO.Path]] HashTable: Hash tables using structural "hash" and "equals" functions. A collection of operations for creating and using hash tables based on particular type-tracked hash/equality functions. Generated by the Hashtbl.Make and Hashtbl.MakeTagged functors. This type is for use when you wish to specify a comparison function once and carry around an object that is a provider of (i.e. a factory for) hashtables that utilize that comparison function. The 'tag' type parameter is used to track information about the comparison function, which helps ensure that you don't mixup maps created with different comparison functions For use when not opening module, e.g. Hashtbl.t Build a collection of operations for creating and using hashtables based on the given hash/equality functions. This returns a record that contains the functions you use to create and manipulate tables of this kind. The returned value is much like an ML module. You should call Make once for each new pair of key/value types. You may need to constrain the result to be an instantiation of Provider. let MyStringHashProvider : Provider<string,int> = Hashtbl.Make(myStringHash,myStringEq) Same as Make, except track the comparison function being used through an additional type parameter. To use this function accurately you need to define a new named class that implements IEqualityComparer and pass an instance of that class as the first argument. For example: type MyHasher = class new() = { } interface IEqualityComparer<string> with member self.GetHashCode(x) = ... member self.Equals(x,y) = ... end end let MyStringHashProvider : Hashtbl.Provider<string,int> = Hashtbl.MakeTagged(new MyStringHasher()) Add key and data to the table. Empty the table. Create a copy of the table. Remember they are imperative and get mutated. Create a hash table with the suggested initial size. Inlined to enable generation of efficient hash routines for the key type in the common case. Lookup key's data in the table. Raises exception is key not in table, if this could happen you should be using tryfind. Return all bindings for the given key Fold over all bindings Hash on the structure of a value according to the F# structural hashing conventions. See Pervasives.hash Hash on the identity of an object. See Pervasives.hashq. Apply the given function to each binding in the hash table Test for the existence of any bindings for the given key Create a hash table using the given data Create a hash table using the given data Create hash table using the given data Inlined to enable generation of efficient hash routines for the key type in the common case. Remove the latest binding for the given key Replace the latest binding for the given key Print statistics on a given hash table to the given output channel Lookup the key's data in the table Imperative hash tables. Shallow interface to [[Microsoft.FSharp.Collections]]. HashTable: Hash tables using the structural "hash" and "equals" functions. These tables can be used with keys of any type, but you should check that structural hashing and equality are correct for your key type. Structural hashing is efficient but not a suitable choice in all circumstances, e.g. may not hash efficiently on non-reference types and deeply-structured types. Better efficiency is typically achieved if key types are F#-generated types. These hash tables may map items to multiple keys (see find_all). The implementations are not safe for concurrent reading/writing, and so users of these tables should take an appropriate lock before reading/writing if used in a concurrent setting. Position information stored for lexing tokens ASCII LexBuffers carrying OCaml-compatible position information. The type "lexbuf" is opaque, but has an internal position information field that can be updated by setting "lexbuf.EndPos", for example if you wish to update the other fields in that position data before or during lexing. You will need to do this if you wish to maintain accurate line-count information. If you do this and wish to maintain strict cross-compiling compatibility with other langauges you may need code to conditionally use lexbuf_set_curr_p when compiling F# code. Remove all input, though don't discard the except the current lexeme Fuel a lexer using the given BinaryReader. Fuel a lexer from an array of bytes Fuel a lexer using the given in_channel. The bytes are read using Pervasives.input. If the in_channel is a textual channel the bytes are presented to the lexer by decoding the characters using System.Text.Encoding.ASCII. Fuel a lexer from function that fills an array of bytes up to the given length, returning the number of bytes filled. Fuel a lexer from a string, converted to ascii using [[System.Text.Encoding.ASCII.GetBytes]] Fuel a lexer using the given TextReader or StreamReader. The characters read are decoded to bytes using the given encoding (e.g. System.Text.Encoding.ASCII) and the bytes presented to the lexer. The encoding used to decode the characters is associated with the expectations of the lexer (e.g. a lexer may be constructed to accept only ASCII or pseudo-UTF8 bytes) and will typically be different to the encoding used to decode the file. same as lexeme_end_p Return the matched string Return the bytes for the matched string Return a character from the matched string, innterpreting the bytes using an ASCII encoding Return absolute positions into the entire stream of characters Return the positions stored in the lexbuf for the matched string Return absolute positions into the entire stream of characters Return the positions stored in the lexbuf for the matched string Return the matched string interpreting the bytes using the given Unicode text encoding Lexing: ML-like lexing support This file maintains rough compatibility for lexbuffers used by some ML laxer generators. The lexbuf carries an associated pair of positions. Beware that only the "cnum" (absolute character number) field is automatically updated as each lexeme is matched. Upon each successful match the prior end position is transferred to be the start position and a new start position is allocated with an updated pos_cnum field. Reference/physical equality. True if boxed versions of the inputs are reference-equal, OR if both are value types and the implementation of Object.Equals for the type of the first argument returns true on the boxed versions of the inputs. In normal use on reference types or non-mutable value types this function has the following properties: - returns 'true' for two F# values where mutation of data in mutable fields of one affects mutation of data in the other - will return 'true' if (=) returns true - hashq will return equal hashes if (==) returns 'true' The use on mutable value types is not recommended. Negation of Obj.eq (i.e. reference/physical inequality) Same as Pervasives.unbox This function is included to make it possible to cross-compile code with other ML compilers. It may be deprecated and/or removed in a future release. Same as Pervasives.box This function is included to make it possible to cross-compile code with other ML compilers. It may be deprecated and/or removed in a future release. You can initialize error recovery by raising the Parse_error exception. Parsing: parser support for parsers produced by fsyacc. Parsers generated by fsyacc provide location information within parser actions. However that information is not available globally, but rather is accessed via the functions available on the following local variable which is available in all parser actions: parseState : 'a Microsoft.FSharp.Tools.FsYacc.IParseState However, this is not compatible with the parser specifications used with ocamlyacc and similar tools, which make a single parser state available globally. If you wish to use a global parser state (e.g. so your code will cross-compile with OCaml) then you can use the functions in this file. You will need to either generate the parser with '--ml-compatibility' option or add the code Parsing.set_parse_state parseState; at the start of each action of your grammar. The functions below simply report the results of corresponding calls to the latest object specified by a call to set_parse_state. Note that there could be unprotected multi-threaded concurrent access for the parser information, so you should not in general use these functions if there may be more than one parser active, and should instead use the functions directly available from the parseState object. Formatting specifications specialized to channel formats A pseudo-abstraction over binary and textual input channels. OCaml-compatible channels conflate binary and text IO, and for this reasons their use from F# is somewhat deprecated (direct use of System.IO StreamReader, TextReader and BinaryReader objects is preferred, e.g. see System.IO.File.OpenText). Well-written OCaml-compatible code that simply opens either a channel in text or binary mode and then does text or binary I/O using the OCaml-compatible functions below will work, though care must be taken with regard to end-of-line characters (see input_char below). This library pretends that an in_channel is just a System.IO.TextReader. Channel values created using open_in_bin maintain a private System.IO.BinaryReader, which will be used whenever you do I/O using this channel. InChannel.of_BinaryReader and InChannel.of_StreamReader allow you to build input channels out of the corresponding .NET abstractions. This type is present primarily for compatibility with other versions of ML. When not cross-compiling we recommend using the .NET I/O libraries An pseudo-abstraction over binary and textual output channels. OCaml-compatible channels conflate binary and text IO, and for this reasons their use from F# is somewhat deprecated The direct use of System.IO StreamWriter, TextWriter and BinaryWriter objects is preferred, e.g. see System.IO.File.CreateText). Well-written OCaml code that simply opens either a channel in text or binary mode and then does text or binary I/O using the OCaml functions will work, though care must be taken with regard to end-of-line characters (see output_char below). This library pretends that an out_channel is just a System.IO.TextWriter. Channels created using open_out_bin maintain a private System.IO.BinaryWriter, which will be used whenever do I/O using this channel. Formatting specifications specialized to string-producing formats Close the channel Close the given output channel This value is present primarily for compatibility with other versions of ML The smallest value that when added to 1.0 gives a different value to 1.0 Flush all pending output on the channel to the physical output device. Return the length of the input channel Attempt to input the given number of bytes from the channel, writing them into the buffer at the given start position. Does not block if the bytes are not available. The use of this function with a channel performing byte-to-character translation (e.g. one created with open_in, open_in_utf8 or open_in_encoded, or one or built from a StreamReader or TextReader) is not recommended. Instead, open the channel using open_in_bin or InChannel.of_BinaryReader. If used with a StreamReader channel, i.e. one created using open_in, open_in_utf8 or open_in_encoded, or one or built from a StreamReader, this function reads bytes directly from the underlying BaseStream. This may not be appropriate if any other input techniques are being used on the channel. If used with a TextReader channel (e.g. stdin), this function reads characters from the stream and then fills some of the byte array with the decoding of these into bytes, where the decoding is performed using the System.Text.Encoding.Default encoding Raise End_of_file (= System.IO.EndOfStreamException) if end of file reached. Input a binary integer from a binary channel. Compatible with output_binary_int. Input a single byte. For text channels this only accepts characters with a UTF16 encoding that fits in a byte, e.g. ASCII. Raise End_of_file (= System.IO.EndOfStreamException) if end of file reached. Input a single character. Raise End_of_file (= System.IO.EndOfStreamException) if end of file reached. Attempt to input characters from a channel. Does not block if inpout is not available. Raise End_of_file (= System.IO.EndOfStreamException) if end of file reached. No CRLF translation is done on input, even in text mode. That is, if an input file has '\r\n' (CRLF) line terminators both characters will be seen in the input. Input a single line. Raise End_of_file (= System.IO.EndOfStreamException) if end of file reached. Input a single serialized value from a binary stream. Raise End_of_file (= System.IO.EndOfStreamException) if end of file reached. Negation on integers of the 'int' type This value is present primarily for compatibility with other versions of ML The highest representable positive value in the 'float' type The highest representable value in the 'int' type This value is present primarily for compatibility with other versions of ML The lowest non-denormalized positive IEEE64 float The lowest representable value in the 'int' type This value is present primarily for compatibility with other versions of ML This value is present primarily for compatibility with other versions of ML This value is present primarily for compatibility with other versions of ML This value is present primarily for compatibility with other versions of ML Negation of the '==' operator, see also Obj.eq This value is present primarily for compatibility with other versions of ML. In F# the overloaded operators may be used. Reference/physical equality. True if boxed versions of the inputs are reference-equal, OR if both are value types and the implementation of Object.Equals for the type of the first argument returns true on the boxed versions of the inputs. In normal use on reference types or non-mutable value types this function has the following properties: - returns 'true' for two F# values where mutation of data in mutable fields of one affects mutation of data in the other - will return 'true' if (=) returns true - hashq will return equal hashes if (==) returns 'true' The use on mutable value types is not recommended. This value is present primarily for compatibility with other versions of ML. In F# the overloaded operators may be used. This value is present primarily for compatibility with other versions of ML This value is present primarily for compatibility with other versions of ML. In F# the overloaded operators may be used. This value is present primarily for compatibility with other versions of ML. In F# the overloaded operators may be used. This value is present primarily for compatibility with other versions of ML. In F# the overloaded operators may be used. Open the given file to read. In the absence of an explicit encoding (e.g. using Open_encoding) open_in uses the default text encoding (System.Text.Encoding.Default). If you want to read a file regardless of encoding then you should use binary modes. Note that .NET's "new StreamReader" function defaults to use a utf8 encoding, and also attempts to determine an automatic encoding by looking for "byteorder-marks" at the head of a text file. This function does not do this. No CR-LF translation is done on input. Open the given file to read in binary-mode Open the given file to read in text-mode using the given encoding Open the given file in the mode specified by the given flags Open the given file to read in text-mode using the UTF8 encoding Open the given file to write in text-mode using the System.Text.Encoding.Default encoding See output_char for a description of CR-LF translation done on output. Open the given file to write in binary-mode Open the given file to write in text-mode using the given encoding Open the given file to write in the mode according to the specified flags Open the given file to write in text-mode using the UTF8 encoding Return the length of the output channel. Raise an exception if not an app Write the given range of bytes to the output channel. Write the given integer to the output channel in binary format. Only valid on binary channels. Write the given byte to the output channel. No CRLF translation is performed. Write all the given bytes to the output channel. No CRLF translation is performed. Write the given Unicode character to the output channel. No CRLF translation is done on output. That is, if the output character is '\n' (LF) characters they will not be written as '\r\n' (CRLF) characters, regardless of whether the underlying operating system or output stream uses CRLF as the default line-feed character. Write the given Unicode string to the output channel. See output_char for the treatment of '\n' characters within the string. Serialize the given value to the output channel. Report the current position in the input channel Return the current position in the output channel, measured from the start of the channel. Not valid on all channels. n-1 (no overflow checking) Print a character to the stderr stream Read a floating point number from the console. Read an integer from the console. Read a line from the console, without the end-of-line character. Reads bytes from the channel. Blocks if the bytes are not available. For text channels this only accepts characters with a UTF16 encoding that fits in a byte, e.g. ASCII. Raise End_of_file (= System.IO.EndOfStreamException) if end of file reached. Reads bytes from the channel. Blocks if the bytes are not available. For text channels this only accepts UTF-16 bytes with an encoding less than 256. Raise End_of_file (= System.IO.EndOfStreamException) if end of file reached. Set the current position in the output channel, measured from the start of the channel. Set the binary mode to true or false. If the binary mode is changed from "true" to "false" then a StreamReader is created to read the binary stream. The StreamReader uses the default text encoding System.Text.Encoding.Default Set the binary mode. If the binary mode is changed from "true" to "false" then a StreamWriter is created to write the binary stream. The StreamWriter uses the default text encoding System.Text.Encoding.Default. A channel based on System.Console.Error. A channel based on System.Console.In. A channel based on System.Console.Out. n+1 (no overflow checking) The exception thrown by 'assert' failures. A future release of F# may map this exception to a corresponding .NET exception. The exception thrown by [[invalid_arg]] and misues of F# library functions A future release of F# may map this exception to a corresponding .NET exception. Non-exhaustive match failures will raise Match failures A future release of F# may map this exception to a corresponding .NET exception. Link .NET IO with the out_channel/in_channel model Wrap a stream by creating a StreamReader for the stream and then wrapping is as an input channel. A text encoding must be given, e.g. System.Text.Encoding.UTF8 Link .NET IO with the out_channel/in_channel model Link .NET IO with the out_channel/in_channel model Access the underlying stream-based objects for the channel Link .NET IO with the out_channel/in_channel model Access the underlying stream-based objects for the channel Access the underlying stream-based objects for the channel Link .NET IO with the out_channel/in_channel model Wrap a stream by creating a StreamWriter for the stream and then wrapping is as an output channel. A text encoding must be given, e.g. System.Text.Encoding.UTF8 Link .NET IO with the out_channel/in_channel model Link .NET IO with the out_channel/in_channel model Access the underlying stream-based objects for the channel Access the underlying stream-based objects for the channel Access the underlying stream-based objects for the channel Access the underlying stream-based objects for the channel The type of simple immutable lists The type of None/Some options The type of pointers to mutable reference cells Absolute value of the given integer Structural comparison Decrement a mutable reference cell containing an integer Exit the current hardware isolated process, if security settings permit, otherwise raise an exception. Calls System.Environment.Exit. Throw a 'Failure' exception The "hash" function is a structural hash function. It is designed to return equal hash values for items that are equal according to the polymorphic equality function Pervasives.(=) (i.e. the standard "=" operator). The exact behaviour of the function can be adjusted on a type-by-type basis by implementing the IStructuralHash interface for each type. Increment a mutable reference cell containing an integer Throw an Invalid_argument exception Maximum based on structural comparison Minimum based on structural comparison Concatenate two lists. Assign to a mutable reference cell Concatenate two strings. The overlaoded operator '+' may also be used. Dereference a mutable reference cell Structural equality Structural greater-than Structural greater-than-or-equal Structural inequality Structural less-than comparison Structural less-than-or-equal comparison Throw an exception Create a mutable reference cell The exception thrown by [[failure]] and many other F# functions A future release of F# may map this exception to a corresponding .NET exception. Pervasives: Additional OCaml-compatible bindings Compatibility module to display data about exceptions. This module is only included to make it possible to cross-compile code with other ML compilers. The usual argv command line array. Gives the command line arguments as returned by System.Environment.GetCommandLineArgs(). Sets the current working directory for the process using [[System.IO.Directory.SetCurrentDirectory]] Run the command and return it's exit code. Warning: 'command' currently attempts to execute the string using the 'cmd.exe' shell processor. If it is not present on the system then the operation will fail. Use System.Diagnostics.Process directly to run commands in a portable way, which involves specifying the program to run and the arguments independently. Path of the current executable, using
 System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory,
                           System.AppDomain.CurrentDomain.FriendlyName)  
 
Returns true if a file currently exists, using System.IO.File.Exists(s). Returns the current working directory for the process using [[System.IO.Directory.GetCurrentDirectory]] System.Environment.GetEnvironmentVariable, raising [[Not_found]] if the variable is not defined. Deletes a file using System.IO.File.Delete(s). Eename a file on disk using System.IO.File.Move Time consumed by the main thread. (for approximate timings). Generally returns only the processor time used by the main thread of the application. The number of bits in the "int" type. Sys: Basic system operations (for ML compatibility) This module is only included to make it possible to cross-compile code with other ML compilers. It may be deprecated and/or removed in a future release. You may wish to use .NET functions directly instead.