1 /++ User-Defined Effects.
2 
3 	Mathematical total function (Koka's `total`) is already present in D via the
4 	`pure` qualifier.
5 
6 	See_Also: http://dpldocs.info/this-week-in-d/Blog.Posted_2022_08_15.html
7 	See_Also: https://koka-lang.github.io/koka/doc/book.html#sec-semantics-of-effects
8 	See_Also: https://koka-lang.github.io/koka/doc/book.html#why-effects
9  +/
10 module nxt.effects;
11 
12 @safe:
13 
14 /++ UDA of (member) function whose returned value is (internally) cached in
15 	RAM.
16 
17 	Cache is stored by default in `this`.
18 
19 	TODO: Can we realize caching and `in bool reload` automatically using a
20     mixin generating the wrapper function automatically?
21  +/
22 enum caches_return_value;
23 
24 /++ UDA of (member) function whose returned value is (externally) cached
25 	(to disk).
26  +/
27 enum caches_return_value_to_disk;
28 
29 /++ UDA of function that writes to `stdout` or `stderr`.
30 	In Koka this is `console`.
31  +/
32 enum writes_to_console;
33 
34 /++ UDA of function that (dynamically) allocates memory either with
35 	GC or `malloc()`. +/
36 enum allocates_on_heap;
37 
38 /++ UDA of function that allocates memory with the built-in GC. +/
39 enum allocates_on_gc_heap;
40 
41 /++ UDA of function that has non-deterministic behaviour.
42 	Typically reads an extern resource such as the system clock.
43 	In Koka this is `ndet`.
44 	+/
45 enum non_deterministic;
46 private alias ndet = non_deterministic;	// Koka-compliant alias.
47 
48 /++ UDA of function that may throw an `Exception|Error`.
49 	In Koka this is `exn`.
50 	+/
51 enum throws;
52 private alias exn = throws;	// Koka-compliant alias.
53 
54 /++ UDA of function that never terminates.
55 	In Koka this is `div`.
56 	+/
57 enum never_terminates;
58 private alias non_terminating = never_terminates;
59 private alias divergent = never_terminates;
60 private alias div = non_terminating; // Koka-compliant alias.