Module Util (.ml)

module Util: sig .. end
Various utility functions


Various utility functions
type ('a, 'b) either = 
| Left of 'a
| Right of 'b
Paramaterized variable typing for building binary ASTs
See also For more details on paramterized typing
val either_split : ('a, 'b) either list -> 'a list * 'b list
Split a list of 'a 'b either values into a pair of 'a list and 'b list
Parameters:
eithers : ('a, 'b) either list
val filter_option : 'a option list -> 'a list
Reduce a list of options to the values in the Some constructors
Parameters:
list : 'a option list
val option_as_list : 'a option -> 'a list
Parameters:
?? : 'a option
val decide_option : 'a -> bool -> 'a option
Parameters:
x : 'a
?? : bool
val lexical_compare : 'a list -> 'a list -> int
Lexically compare two lists of comparable items
Parameters:
list1 : 'a list
list2 : 'a list
val find_all_min : ('a -> 'a -> int) -> 'a list -> 'a list
Loop through a list and find all the items that are minimum with respect to the total ordering cmp. (If an item is found to be a minimum, any item that is found to be equal to the item is in the returned list.) Note can return any size list.
Returns A list of one or more items deemed to be the minimum by cmp.
Parameters:
cmp : 'a -> 'a -> int
A comparator function
alist : 'a list
A list of items
val (|->) : ('a, 'b) either -> ('a -> ('c, 'b) either) -> ('c, 'b) either
Either monad stuffage
Returns The result of func if we're on the left side, or the error if we're on the right
Parameters:
value : ('a, 'b) either
A monad
func : 'a -> ('c, 'b) either
A function to run on a monad
val seq : ('a, 'b) either ->
('a -> ('a, 'b) either) list -> ('a, 'b) either
Sequence a bunch of monadic actions together, piping results together
Parameters:
init : ('a, 'b) either
actions : ('a -> ('a, 'b) either) list
val get_statement_count : Ast.stmt list -> int
Return the length of a block -- i.e. the total number of statements (recursively) in it
Returns An int encoding the length of a block
Parameters:
stmt_list : Ast.stmt list
A list of stmt type objects