Code Monkey home page Code Monkey logo

session-csharp's People

Contributors

curegit avatar keigoi avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

keigoi

session-csharp's Issues

Fluent API補助メソッド

Session Continue((Session, Value) session, out T value)
のような拡張メソッドを用意すると
(await s.Send(v).Receive()).Continue(out var value).Send(...)
非同期受信をこのようにチェーンできる

Session Let(Session session, out T var, T value)
のような拡張メソッドを用意すると
s.Receive(out var v).Let(out var r, Sqrt(v)).Send(r).Send(Sqrt(r)).Close()
チェーンの途中で変数宣言ができる

非継続渡しの消極的選択メソッド

非継続渡しの消極的選択メソッドを実装したい。

分岐先を表すコンストラクタと分岐先のセッションをもつバリアントを用意するのが理想。

Choice <a, b> = Left of a | Right of b

コンスタントをinternalにした抽象クラスを用いると、派生クラスの作成を制限できる。
バリアントの代わりとなる。

namespace SessionTypes.Binary
{
	public abstract class Choice<L, R> where L : SessionType where R : SessionType
	{
		internal Choice() { }
	}

	public sealed class Left<L, R> : Choice<L, R> where L : SessionType where R : SessionType
	{
	}

	public sealed class Right<L, R> : Choice<L, R> where L : SessionType where R : SessionType
	{
	}
}

しかしダウンキャストのために型をパラメータ含めて書く必要がある。

switch (c2.Follow())
{
	case Left<Respond<int, Close>, Respond<string, Close>> left:
		break;
	case Right<Respond<int, Close>, Respond<string, Close>> right:
		break;
}

非継続渡しの消極的選択メソッドとFluent APIをあわせると、名前変えを抑えつつ手続き的な制御構造と親和に書けるので、需要は大きい。
もっと思考を要する。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.