# HG changeset patch # User Kazuma Takeda # Date 1486468250 -32400 # Node ID a797817238621e660f3abf9c5c7193954bb0defe # Parent 56de71ae6f7e13866f324b9990331e16346b58b3 Add bind function to Either.cs Rewrite use bind. diff -r 56de71ae6f7e -r a79781723862 Main/jungle-main/store/transformer/PutAttribute.cs --- a/Main/jungle-main/store/transformer/PutAttribute.cs Sat Jan 28 19:12:18 2017 +0900 +++ b/Main/jungle-main/store/transformer/PutAttribute.cs Tue Feb 07 20:50:50 2017 +0900 @@ -15,7 +15,6 @@ public PutAttribute(object _value) { key = _value.ToString(); - Debug.Log (key); value = _value; } diff -r 56de71ae6f7e -r a79781723862 Main/jungle-main/transaction/DefaultJungleTreeEditor.cs --- a/Main/jungle-main/transaction/DefaultJungleTreeEditor.cs Sat Jan 28 19:12:18 2017 +0900 +++ b/Main/jungle-main/transaction/DefaultJungleTreeEditor.cs Tue Feb 07 20:50:50 2017 +0900 @@ -31,7 +31,7 @@ - private Either _edit(NodePath _path, NodeEditor _e) + private Either _edit(NodePath _path, NodeEditor _e) { Either either = editor.edit (root, _path, _e); if (either.isA ()) @@ -67,7 +67,7 @@ return _edit (_path, appendChildAt); } - public Either deleteChildAt(NodePath _path, int _pos) { + public Either deleteChildAt(NodePath _path, int _pos) { DeleteChildAt deleteChildAt = new DeleteChildAt(_pos); return _edit(_path,deleteChildAt); } @@ -99,12 +99,12 @@ } public Either edit(NodePath _path, NodeEditor _editor) { - return _edit(_path,_editor); + return _edit(_path, _editor); } - public Either commit() { + public Either commit() { Either either = this.txManager.commit(this.root, this.log); - if(either.isA()){ + if(either.isA()) { return DefaultEither.newA(either.a()); } diff -r 56de71ae6f7e -r a79781723862 Main/jungle-main/util/DefaultEither.cs --- a/Main/jungle-main/util/DefaultEither.cs Sat Jan 28 19:12:18 2017 +0900 +++ b/Main/jungle-main/util/DefaultEither.cs Tue Feb 07 20:50:50 2017 +0900 @@ -3,16 +3,6 @@ private A theA; private B theB; - public void SetB (B b) { - this.theB = b; - } - - public void SetA (A a) { - this.theA = a; - } - - public delegate B Func (B b); - public DefaultEither(A _theA, B _theB){ theA = _theA; theB = _theB; @@ -51,12 +41,18 @@ return theB != null; } - public Either fmap(System.Func f, Either e) { - if (e.isA ()) { - return e; + public Either fmap(System.Func f) { + if (isA ()) { + return this; } - this.SetB (f (e.b())); - return this; + return newB(f(b())); } + public Either bind (System.Func> f) { + if (isA ()) { + return this; + } + + return f (b ()); + } } diff -r 56de71ae6f7e -r a79781723862 Main/jungle-main/util/Either.cs --- a/Main/jungle-main/util/Either.cs Sat Jan 28 19:12:18 2017 +0900 +++ b/Main/jungle-main/util/Either.cs Tue Feb 07 20:50:50 2017 +0900 @@ -4,5 +4,6 @@ bool isA(); B b(); bool isB(); - Either fmap (System.Func f, Either e); + Either fmap (System.Func f); + Either bind (System.Func> f); }