1(* ========================================================================= *) 2(* PRESERVING SHARING OF ML VALUES *) 3(* Copyright (c) 2005 Joe Hurd, distributed under the BSD License *) 4(* ========================================================================= *) 5 6signature Sharing = 7sig 8 9(* ------------------------------------------------------------------------- *) 10(* Option operations. *) 11(* ------------------------------------------------------------------------- *) 12 13val mapOption : ('a -> 'a) -> 'a option -> 'a option 14 15val mapsOption : ('a -> 's -> 'a * 's) -> 'a option -> 's -> 'a option * 's 16 17(* ------------------------------------------------------------------------- *) 18(* List operations. *) 19(* ------------------------------------------------------------------------- *) 20 21val map : ('a -> 'a) -> 'a list -> 'a list 22 23val revMap : ('a -> 'a) -> 'a list -> 'a list 24 25val maps : ('a -> 's -> 'a * 's) -> 'a list -> 's -> 'a list * 's 26 27val revMaps : ('a -> 's -> 'a * 's) -> 'a list -> 's -> 'a list * 's 28 29val updateNth : int * 'a -> 'a list -> 'a list 30 31val setify : ''a list -> ''a list 32 33(* ------------------------------------------------------------------------- *) 34(* Function caching. *) 35(* ------------------------------------------------------------------------- *) 36 37val cache : ('a * 'a -> order) -> ('a -> 'b) -> 'a -> 'b 38 39(* ------------------------------------------------------------------------- *) 40(* Hash consing. *) 41(* ------------------------------------------------------------------------- *) 42 43val hashCons : ('a * 'a -> order) -> 'a -> 'a 44 45end 46