diff --git a/examples/LWT.fram b/examples/LWT.fram deleted file mode 100644 index 1e7f645..0000000 --- a/examples/LWT.fram +++ /dev/null @@ -1,102 +0,0 @@ -(* This example shows another implementation of cooperative threads, this - time using first class labels. In opposite to LWT_lexical example, this - implementation does not lead to memory leaks, because the newly created - thread do not share an unreachable continuation with the parent thread. *) - -import List - -(* We start with defining the standard State effect, together with default - functions for accessing the state. See LWT_lexical example for more - explanation. *) -data State (effect E) X = State of - { get : Unit ->[E] X - , put : X ->[E] Unit - , update : {Row} -> (X ->[E|Row] X) ->[E|Row] Unit - } - -implicit `st {E_st} : State E_st _ - -let get x = - let (State { get }) = `st in - get x - -let put x = - let (State { put }) = `st in - put x - -let update f = - let (State { update }) = `st in - update f - -(* The type of threads: a thunk with given effect row *) -data Thread R = Thread of (Unit ->[|R] Unit) - -(* The standard handler of a state, used by the scheduler *) -handle {effect=Sched} (`st : State Sched (List (Thread [Sched,IO]))) = - let get = effect x / r => fn s => r s s - let put = effect s / r => fn _ => r () s - let update f = put (f (get ())) in - State { get, put, update } - return x => fn _ => x - finally c => c [] - -(* The global label of an LWT effect. *) -label {effect=LWT} lwt_lbl - -(* The signature of LWT capability. It has two functions: yield that - voluntarily pass control to another thread, and spawn for creating new - threads. *) -data LWT_S = LWT of - { yield : Unit ->[LWT,IO] Unit - , spawn : (Unit ->[LWT,IO] Unit) ->[LWT,IO] Unit - } - -(* Both operations can be accessed via methods of an lwt object *) -method yield {self = LWT {yield}} = yield -method spawn {self = LWT {spawn}} = spawn - -(* Run the scheduler: just pick the next thread from the queue *) -let sched () = - match get () with - | [] => () - | Thread thr :: q => let _ = put q in thr () - end - -(* Put a thread to the scheduler queue *) -let enqueue thr = - update (fn q => List.append q [Thread thr]) - -(* Here, we handle LWT effect. Note that the handler does not provide any - capability. It only plays a role of the delimiter (reset0) on given label. -*) -handle {label=lwt_lbl} _ = () - return _ => sched () - -(* LWT capability. The problematic spawn operation puts a new delimiter with - the same label. *) -let lwt = LWT - { yield = effect _ / r => - let _ = enqueue r in - sched () - , spawn = effect f / r => - let _ = enqueue r in - handle {label=lwt_lbl} _ = () - return _ => sched () - in - f () - } - -(* Example code using LWT interface. Methods yield and spawn are accessible - via the `lwt` object. *) -let startThread (name : String) = lwt.spawn (fn _ => - let _ = printStrLn (name + "1") in - let _ = lwt.yield () in - let _ = printStrLn (name + "2") in - let _ = lwt.yield () in - let _ = printStrLn (name + "3") in - let _ = lwt.yield () in - printStrLn (name + " exited")) - -let _ = startThread "A" -let _ = startThread "B" -let _ = startThread "C" diff --git a/test/err/tc_0003_escapingType.fram b/test/err/tc_0003_escapingType.fram deleted file mode 100644 index 1301323..0000000 --- a/test/err/tc_0003_escapingType.fram +++ /dev/null @@ -1,9 +0,0 @@ -data Box X = Box of X -label l -data A = A -let foo (Box A) = () -handle {label=l} _ = () - return _ => foo - finally c => c (Box A) -// @stderr: Type variable -// @stderr: escapes diff --git a/test/ok/ok0063_firstClassLabel.fram b/test/ok/ok0063_firstClassLabel.fram deleted file mode 100644 index 43b5e3f..0000000 --- a/test/ok/ok0063_firstClassLabel.fram +++ /dev/null @@ -1,2 +0,0 @@ -label lbl -handle {label=lbl} _ = () diff --git a/test/ok/ok0065_effectName.fram b/test/ok/ok0065_effectName.fram deleted file mode 100644 index ffcc7a9..0000000 --- a/test/ok/ok0065_effectName.fram +++ /dev/null @@ -1,6 +0,0 @@ -label {effect=E} l - -handle {effect=E1,label=l} (f : Unit ->[E] (Unit ->[E1] Unit)) = - effect _ _ / r => r () - -let _ = f () () diff --git a/test/test_suite b/test/test_suite index 8cf6689..116fc2e 100644 --- a/test/test_suite +++ b/test/test_suite @@ -10,7 +10,6 @@ run_with_flags simple_run_tests "-no-prelude -no-stdlib" function simple_examples { simple_test examples/Tick.fram simple_test examples/LWT_lexical.fram - simple_test examples/LWT.fram simple_test examples/Prolog.fram simple_test examples/Pythagorean.fram simple_test examples/Modules/Main.fram