From 88e67b02ecd7da583498cb5c2596f3940e679437 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Sun, 19 Apr 2026 17:40:42 +0200 Subject: [PATCH] start csys development with simple neuron implementation --- README.md | 21 ++++++++++++++++----- lib/csys/csys.ex | 8 ++++++++ test/core_test.exs | 3 ++- test/csys_test.exs | 17 +++++++++++++++++ 4 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 lib/csys/csys.ex create mode 100644 test/csys_test.exs diff --git a/README.md b/README.md index 7a99864..f7b2a94 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,27 @@ -# Xplore +# Scopes -**TODO: Add description** +Yet another implementation of the unfamous `scopes` framework. ## Installation -If [available in Hex](https://hex.pm/docs/publish), the package can be installed -by adding `xplore` to your list of dependencies in `mix.exs`: +You can use the development checkout from Git and reference it as a dependency +in `mix.exs` like this: ```elixir def deps do [ - {:xplore, "~> 0.1.0"} + {:scopes, path: "../ex-scopes"} + ] +end +``` + +If [available in Hex](https://hex.pm/docs/publish), the package can be installed +by adding `scopes` to your list of dependencies in `mix.exs`: + +```elixir +def deps do + [ + {:scopes, "~> 0.1.0"} ] end ``` diff --git a/lib/csys/csys.ex b/lib/csys/csys.ex new file mode 100644 index 0000000..6149237 --- /dev/null +++ b/lib/csys/csys.ex @@ -0,0 +1,8 @@ +defmodule Scopes.CSys do + #alias Scopes.Core.Actor + + def neuron(proc, scope) do + #{state, syns, env} = scope + fn msg -> proc.(msg, scope) end + end +end diff --git a/test/core_test.exs b/test/core_test.exs index 155ad4a..499dd00 100644 --- a/test/core_test.exs +++ b/test/core_test.exs @@ -7,11 +7,12 @@ defmodule Scopes.CoreTest do this = self() ac = Actor.create(fn msg -> send(this, msg) end) Actor.send(ac, "Hello Actor!") + assert_receive "Hello Actor!" Actor.become(ac, fn _msg -> send(this, "Goodbye") end) Actor.send(ac, "Hello Actor!") Actor.stop(ac) - assert_receive "Hello Actor!" assert_receive "Goodbye" + refute_received msg, "unhandled message(s): #{inspect msg}" end end end diff --git a/test/csys_test.exs b/test/csys_test.exs new file mode 100644 index 0000000..32b9d9f --- /dev/null +++ b/test/csys_test.exs @@ -0,0 +1,17 @@ +defmodule Scopes.CSysTest do + use ExUnit.Case, async: true + alias Scopes.Core.Actor + alias Scopes.CSys + + describe "basic:" do + test "minimal-neural-net" do + this = self() + zero = Actor.create(CSys.neuron( + fn msg, _scope -> send(this, msg) end, {nil, [], this})) + Actor.send(zero, "Hello Zero!") + Actor.stop(zero) + assert_receive "Hello Zero!" + refute_received msg, "unhandled message(s): #{inspect msg}" + end + end +end