Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Sep 10, 2019. It is now read-only.
/Narvalo.NETPublic archive

Commitd5fb576

Browse files
author
Chtoucas
committed
Use a ValueTuple instead of StateObject.
1 parent113b657 commitd5fb576

File tree

16 files changed

+54
-87
lines changed

16 files changed

+54
-87
lines changed

‎src/Narvalo.Common/Collections/Dictionary$.cs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ public static Maybe<TValue> MayGetValue<TKey, TValue>(
2727

2828
if(key==null){returnMaybe<TValue>.None;}
2929

30-
TValuevalue;
31-
return@this.TryGetValue(key,outvalue)?Maybe.Of(value):Maybe<TValue>.None;
30+
return@this.TryGetValue(key,outTValuevalue)?Maybe.Of(value):Maybe<TValue>.None;
3231
}
3332
}
3433
}

‎src/Narvalo.Common/Internal/TryParser$.cs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ internal static class TryParserExtensions
1212

1313
if(value==null){returnnull;}
1414

15-
Tresult;
16-
return@this.Invoke(value,outresult)?result:(T?)null;
15+
return@this.Invoke(value,outTresult)?result:(T?)null;
1716
}
1817

1918
publicstaticMaybe<T>MayInvoke<T>(thisTryParser<T>@this,stringvalue)whereT:class
@@ -22,8 +21,7 @@ public static Maybe<T> MayInvoke<T>(this TryParser<T> @this, string value) where
2221

2322
if(value==null){returnMaybe<T>.None;}
2423

25-
Tresult;
26-
return@this.Invoke(value,outresult)?Maybe.Of(result):Maybe<T>.None;
24+
return@this.Invoke(value,outTresult)?Maybe.Of(result):Maybe<T>.None;
2725
}
2826
}
2927
}

‎src/Narvalo.Finance/Bic.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public static string FromBic(string value)
181181
}
182182
else
183183
{
184-
varretval=value.Substring(StartIndex,Length);
184+
stringretval=value.Substring(StartIndex,Length);
185185
returnCheckContent(retval)?retval:null;
186186
}
187187
}
@@ -203,7 +203,7 @@ private static class CountryPart
203203
publicstaticstringFromBic(stringvalue)
204204
{
205205
Demand.True(value.Length>=StartIndex+Length);
206-
varretval=value.Substring(StartIndex,Length);
206+
stringretval=value.Substring(StartIndex,Length);
207207
returnCheckContent(retval)?retval:null;
208208
}
209209

@@ -223,7 +223,7 @@ private static class InstitutionPart
223223

224224
publicstaticstringFromBic(stringvalue,BicVersionversion)
225225
{
226-
varretval=value.Substring(StartIndex,Length);
226+
stringretval=value.Substring(StartIndex,Length);
227227

228228
returnCheckContent(retval,version)?retval:null;
229229
}
@@ -247,7 +247,7 @@ private static class LocationPart
247247
publicstaticstringFromBic(stringvalue)
248248
{
249249
Demand.True(value.Length>=StartIndex+Length);
250-
varretval=value.Substring(StartIndex,Length);
250+
stringretval=value.Substring(StartIndex,Length);
251251
returnCheckContent(retval)?retval:null;
252252
}
253253

‎src/Narvalo.Futures/Applicative/StateObject`.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ namespace Narvalo.Applicative
66
usingSystem.Collections;
77
usingSystem.Collections.Generic;
88

9+
[Obsolete]
910
publicstaticclassStateObject
1011
{
1112
publicstaticStateObject<T,TState>Create<T,TState>(Tvalue,TStatestate)
1213
=>newStateObject<T,TState>(value,state);
1314
}
1415

1516
// To be replaced by ValueTuple<T, TState> when available.
17+
[Obsolete]
1618
publicpartialstructStateObject<T,TState>:IEquatable<StateObject<T,TState>>,IStructuralEquatable
1719
{
1820
publicStateObject(Tresult,TStatestate)

‎src/Narvalo.Futures/Applicative/Stateful.cs‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ namespace Narvalo.Applicative
44
{
55
usingSystem;
66

7-
// Func<TState,StateObject<T, TState>>
8-
publicdelegateStateObject<T,TState>Stateful<T,TState>(TStatestate);
7+
// Func<TState,(T, TState)>
8+
publicdelegate(Tresult,TStatestate)Stateful<T,TState>(TStatestate);
99

1010
// Provides the core Monad methods.
1111
publicstaticpartialclassStateful
@@ -15,14 +15,14 @@ public static Stateful<TNext, TState> Bind<T, TNext, TState>(
1515
Func<T,Stateful<TNext,TState>>binder)
1616
=> state=>
1717
{
18-
StateObject<T,TState>obj=@this(state);
18+
varobj=@this(state);
1919

20-
returnbinder(obj.Result).Invoke(obj.State);
20+
returnbinder(obj.result).Invoke(obj.state);
2121
};
2222

2323
// Initialize a stateful computation from a given value.
2424
publicstaticStateful<T,TState>Of<T,TState>(Tvalue)
25-
=> state=>StateObject.Create(value,state);
25+
=> state=>(value,state);
2626

2727
publicstaticStateful<T,TState>Flatten<T,TState>(Stateful<Stateful<T,TState>,TState>square)
2828
=>square.Bind(Stubs<Stateful<T,TState>>.Identity);
@@ -32,15 +32,15 @@ public static Stateful<T, TState> Flatten<T, TState>(Stateful<Stateful<T, TState
3232
publicstaticpartialclassStateful
3333
{
3434
publicstaticStateful<TState,TState>Get<TState>()
35-
=> state=>StateObject.Create(state,state);
35+
=> state=>(state,state);
3636

3737
publicstaticStateful<Unit,TState>Put<TState>(TStatenewState)
38-
=> state=>StateObject.Create(Unit.Default,newState);
38+
=> state=>(Unit.Default,newState);
3939

4040
publicstaticStateful<Unit,TState>Modify<TState>(Func<TState,TState>func)
41-
=> state=>StateObject.Create(Unit.Default,func(state));
41+
=> state=>(Unit.Default,func(state));
4242

4343
publicstaticStateful<TResult,TState>Gets<TState,TResult>(Func<TState,TResult>func)
44-
=> state=>StateObject.Create(func(state),state);
44+
=> state=>(func(state),state);
4545
}
4646
}

‎src/Narvalo.Futures/Applicative/Stateful.g.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// behavior and will be lost if the code is regenerated.
77
//
88
// Runtime Version: 4.0.30319.42000
9-
// Microsoft.VisualStudio.TextTemplating:14.0
9+
// Microsoft.VisualStudio.TextTemplating:15.0
1010
// </auto-generated>
1111
//------------------------------------------------------------------------------
1212

‎src/Narvalo.Futures/Narvalo.Futures.csproj‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
<ReferenceInclude="System" />
1212
<ReferenceInclude="System.ComponentModel.Composition" />
1313
<ReferenceInclude="System.Configuration" />
14+
<ReferenceInclude="System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
15+
<HintPath>..\..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
16+
</Reference>
1417
<ReferenceInclude="System.Xml" />
1518
<ReferenceInclude="System.Xml.Linq" />
1619
</ItemGroup>
@@ -106,6 +109,7 @@
106109
</ItemGroup>
107110
<ItemGroup>
108111
<NoneInclude="Narvalo.Futures.Version.props" />
112+
<NoneInclude="packages.config" />
109113
</ItemGroup>
110114
<ItemGroup>
111115
<ServiceInclude="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<packageid="System.ValueTuple"version="4.3.0"targetFramework="net461" />
4+
</packages>

‎src/Narvalo.Fx/Applicative/Either`2.cs‎

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,13 @@ private Either() { }
5252
[DebuggerTypeProxy(typeof(Either<,>.Left_.DebugView))]
5353
privatesealedpartialclassLeft_:Either<TLeft,TRight>,IEquatable<Left_>
5454
{
55-
publicLeft_(TLeftvalue)
56-
{
57-
Left=value;
58-
}
55+
publicLeft_(TLeftvalue)=>Left=value;
5956

6057
publicoverrideboolIsLeft=>true;
6158

6259
internaloverrideTLeftLeft{get;}
6360

64-
internaloverrideTRightRight{get{thrownewInvalidOperationException("XXX");}}
61+
internaloverrideTRightRight=>thrownewInvalidOperationException("XXX");
6562

6663
publicoverrideMaybe<TLeft>LeftOrNone()=>Maybe.Of(Left);
6764

@@ -97,10 +94,7 @@ private sealed class DebugView
9794
{
9895
privatereadonlyEither<TLeft,TRight>_inner;
9996

100-
publicDebugView(Either<TLeft,TRight>inner)
101-
{
102-
_inner=inner;
103-
}
97+
publicDebugView(Either<TLeft,TRight>inner)=>_inner=inner;
10498

10599
publicTLeftLeft=>_inner.Left;
106100
}
@@ -112,22 +106,19 @@ public DebugView(Either<TLeft, TRight> inner)
112106
[DebuggerTypeProxy(typeof(Either<,>.Right_.DebugView))]
113107
privatesealedpartialclassRight_:Either<TLeft,TRight>,IEquatable<Right_>
114108
{
115-
publicRight_(TRightvalue)
116-
{
117-
Right=value;
118-
}
109+
publicRight_(TRightvalue)=>Right=value;
119110

120111
publicoverrideboolIsLeft=>false;
121112

122-
internaloverrideTLeftLeft{get{thrownewInvalidOperationException("XXX");}}
113+
internaloverrideTLeftLeft=>thrownewInvalidOperationException("XXX");
123114

124115
internaloverrideTRightRight{get;}
125116

126117
publicoverrideMaybe<TLeft>LeftOrNone()=>Maybe<TLeft>.None;
127118

128119
publicoverrideMaybe<TRight>RightOrNone()=>Maybe.Of(Right);
129120

130-
publicoverrideEither<TRight,TLeft>Swap(){thrownewInvalidOperationException("XXX");}
121+
publicoverrideEither<TRight,TLeft>Swap()=>thrownewInvalidOperationException("XXX");
131122

132123
publicoverrideEither<TRight,TLeft>SwapUnchecked()=>Either<TRight,TLeft>.OfLeft(Right);
133124

@@ -157,10 +148,7 @@ private sealed class DebugView
157148
{
158149
privatereadonlyEither<TLeft,TRight>_inner;
159150

160-
publicDebugView(Either<TLeft,TRight>inner)
161-
{
162-
_inner=inner;
163-
}
151+
publicDebugView(Either<TLeft,TRight>inner)=>_inner=inner;
164152

165153
publicTRightRight=>_inner.Right;
166154
}
@@ -188,12 +176,12 @@ private partial class Left_
188176
{
189177
publicoverrideTLeftToLeft()=>Left;
190178

191-
publicoverrideTRightToRight(){thrownewInvalidCastException("XXX");}
179+
publicoverrideTRightToRight()=>thrownewInvalidCastException("XXX");
192180
}
193181

194182
privatepartialclassRight_
195183
{
196-
publicoverrideTLeftToLeft(){thrownewInvalidCastException("XXX");}
184+
publicoverrideTLeftToLeft()=>thrownewInvalidCastException("XXX");
197185

198186
publicoverrideTRightToRight()=>Right;
199187
}

‎src/Narvalo.Fx/Applicative/Fallible.cs‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,7 @@ private sealed class DebugView
6565
{
6666
privatereadonlyFallible_inner;
6767

68-
publicDebugView(Fallibleinner)
69-
{
70-
_inner=inner;
71-
}
68+
publicDebugView(Fallibleinner)=>_inner=inner;
7269

7370
publicboolIsSuccess=>_inner.IsSuccess;
7471

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp