PreviousUpNext

15.4.910  src/lib/src/issue-unique-id-wrapper-g.pkg

## issue-unique-id-g.pkg
#
# See also:
#
#     src/lib/src/issue-unique-id-g.pkg

# Compiled by:
#     src/lib/std/standard.lib


# The point of this package is to allow increased
# typesafety by allowing generation of multiple
# incompatible 'Id' types (via this generic)
# without actually duplicating the underlying code
# or generating duplicate id values.

# This generic is used in:
#
#    

stipulate
    include package   threadkit;                                # threadkit                     is from   src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.pkg
herein

    generic package issue_unique_id_wrapper_g ()                # 
    :               Issue_Unique_Id                             # Issue_Unique_Id               is from   src/lib/src/issue-unique-id.api
    {
        Id = Int;                                               # Exported as an opaque type to reduce risk of confusing ids with other ints.
        id_zero = 0;

        stipulate
            fun issue_unique_id' ()                             # A little trick because    fun issue_unique_id () = id_to_int (issue_unique_id());   would involve unwanted recursion.
                =
                id_to_int (issue_unique_id());                  # Use the issue_unique_id() from   src/lib/core/init/pervasive.pkg
        herein
            issue_unique_id = issue_unique_id';
        end;

        fun id_to_int (id: Id)
            =
            id;

        fun same_id (id1: Id,  id2: Id)
            =
            id1 == id2;
    };
end;

## Original code by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext