![]() | Library Documentation | Structures | Signatures | Identifiers | Packages | About |
UREF (pkg github.com/diku-dk/sml-uref)Unifiable references.
Unifiable references provide a Union/Find data type with a ref-like interface. A Union/Find structure consists of a type constructor 'a uref with operations for creating an element of type 'a uref (uRef), getting the contents of an element (!!), checking for equality of two elements (equal), and for unifying two elements (unify).structure URef : UREF (pkg github.com/diku-dk/sml-uref)
signature UREF = sig
type 'a uref
val uref : 'a -> 'a uref
val !! : 'a uref -> 'a
val ::= : 'a uref * 'a -> unit
val unify : ('a * 'a -> 'a) -> 'a uref * 'a uref -> unit
val eq : 'a uref * 'a uref -> bool
val compare : ('a * 'a -> order) -> 'a uref * 'a uref -> order
end
------------------------------------------------------------------- type 'a ref 'a uref ------------------------------------------------------------------- introduction ref uref elimination ! !! equality = eq updating := ::= unioning unify -------------------------------------------------------------------The main difference between 'a ref and 'a uref is in the unify operation. Without unify, 'a ref and 'a uref can be used interchangebly. An assignment to a reference changes only the contents of the reference, but not the reference itself. In particular, any two pointers that were different (in the sense of the equality predicate = returning false) before an assignment will still be so. Their contents may or may not be equal after the assignment, though. In contrast, applying the unify operation to two uref elements makes the two elements themselves equal (in the sense of the predicate equal returning true). As a consequence their contents will also be identical; the actual content is determined by a binary function parameter to unify. AUTHOR: This software was originally authored by Fritz Henglein. Simplifications have been made by Henning Niss (eliminating redundant matches) and Martin Elsman (removed some exposed functionality such as link and union. Copyright (c) 199x-2020 Fritz Henglein, Henning Niss, University of Copenhagen.