Skip to content

Algebraic Effects? #3

@OvermindDL1

Description

@OvermindDL1

As it's currently implemented it doesn't seem to be an Algebraic Effects system, it seems more to be an Implicit Witness system (not that mine went much further at all since I hadn't performed CPS yet and thus why it was never published to hex.pm).

Something as simple as making a memoizer via effects does not seem possible (nor anything even remotely more complex) with this library as it stands.

Like given something like this:

def print_succ(x) do
  IO.puts("input change #{x}")
  Memo.cut()
  IO.puts("Succ of #{x} is #{x+1}")
end

Then running this within the memoizer effect:

print_succ(0)
print_succ(0)
print_succ(0)
print_succ(1)
print_succ(1)

Should print:

input change 0
Succ of 0 is 1
Succ of 0 is 1
Succ of 0 is 1
input change 1
Succ of 1 is 2
Succ of 1 is 2

As long as this specific example can be created generically then 90% of algebraic effects will be implementable (the remaining parts relying on things like returnable continuations, which although can be done is not used by this example, this example only rely's on cloneable continuations, which is easier to implement then returnable continuations and is the form that most algebraic effect systems do as it is the minimal viable setup for an algebraic effects system).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions