Commits

Yit Phang Khoo committed 0a140c1

Move basic API into its own module.

  • Participants
  • Parent commits 550165e

Comments (0)

Files changed (3)

Source/Adapton.mlpack

 Adapton/All
+Adapton/BasicSA
 Adapton/Default
 Adapton/EagerSATotalOrder
 Adapton/Exceptions

Source/Adapton/BasicSA.ml

+(** Functor that provides a basic polymorphic API for a self-adjusting module. *)
+
+module Make (M : Signatures.SAType) : sig
+    type 'a aref
+    val aref : 'a -> 'a aref
+    val get : 'a aref -> 'a
+    val set : 'a aref -> 'a -> unit
+
+    type 'a athunk
+    val force : 'a athunk -> 'a
+    val thunk : (unit -> 'a) -> 'a athunk
+    val memo : ('fn -> 'arg -> 'a) -> ('arg -> 'a athunk as 'fn)
+end = struct
+    module P = PolySA.Make (M)
+
+    type 'a aref = 'a P.thunk
+    let aref x = P.const x
+    let get m = P.force m
+    let set m x = P.update_const m x
+
+    type 'a athunk = 'a P.thunk
+    let force m = P.force m
+    let thunk f = P.thunk f
+    let memo f = P.memo f
+end

Source/Adapton/PolySA.ml

             fun a b c d -> (memo4 a b c d, (module S))
 
     let tweak_gc = M.tweak_gc
-
-    module Basic : sig
-        type 'a aref
-        val aref : 'a -> 'a aref
-        val get : 'a aref -> 'a
-        val set : 'a aref -> 'a -> unit
-
-        type 'a athunk
-        val force : 'a athunk -> 'a
-        val thunk : (unit -> 'a) -> 'a athunk
-        val memo : ('fn -> 'arg -> 'a) -> ('arg -> 'a athunk as 'fn)
-    end = struct
-        type 'a aref = 'a thunk
-        let aref x = const x
-        let get m = force m
-        let set m x = update_const m x
-
-        type 'a athunk = 'a thunk
-        let force m = force m
-        let thunk f = thunk f
-        let memo f = memo f
-    end
 end