Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use source CE overload #83

Merged

Conversation

TheAngryByrd
Copy link
Collaborator

I was investigating how FSharp.Control.FusionTasks was handling it's binding overloads and I came across an overload I was not familiar with, the Source method. I came across this StackOverflow post that explained it.

So, the Source method lets you transform whatever inputs the query can work on into some "internal representation" of the data source. On the opposite end, the Run method turns the data from this internal representation into ordinary value.

Basically this means it will change from on type to another. Effectively this will remove the need for all the insane amount of overloads.

@baronfel
Copy link

baronfel commented Jun 5, 2020

I'd mark them all inline, per our other stacktrace work, but other than that I love it.

@TheAngryByrd
Copy link
Collaborator Author

I'd mark them all inline, per our other stacktrace work, but other than that I love it.

Good call

@TheAngryByrd TheAngryByrd marked this pull request as ready for review June 5, 2020 15:55
These tests are ignored since asserting against them is very brittle. I'm open to ideas but for now I'd rather manually review them
@TheAngryByrd
Copy link
Collaborator Author

Stacktraces with inlining the Source members:

System.Exception: Intentional failure
   at AsyncResultCETests.failureAsync@419.Invoke(Unit unitVar) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 419
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 398
   at AsyncResultCETests.mainExeuctorAsync@425-8.Invoke(AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 425
   at AsyncResultCETests.mainExeuctorAsync@425-14.Invoke(AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 425
   at AsyncResultCETests.mainExeuctorAsync@424-2.Invoke(AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 424
   at AsyncResultCETests.mainExeuctorAsync@424-18.Invoke(AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 424
   at AsyncResultCETests.AsyncResultCE Stack Trace Tests@442-2.Invoke(AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 442
   at <StartupCode$FSharp-Core>.$Async.StartChild@1666-5.Invoke(AsyncActivation`1 ctxt) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 1666
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 109

Without:

System.Exception: Intentional failure
   at AsyncResultCETests.failureAsync@419.Invoke(Unit unitVar) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 419
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 398
   at AsyncResultCETests.mainExeuctorAsync@425-8.Invoke(AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 425
   at <StartupCode$FSharp-Core>.$Async.Return@1066.Invoke(AsyncActivation`1 ctxt) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 1066
   at AsyncResultCETests.mainExeuctorAsync@424-12.Invoke(AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 424
   at AsyncResultCETests.AsyncResultCE Stack Trace Tests@442-2.Invoke(AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 442
   at <StartupCode$FSharp-Core>.$Async.StartChild@1666-5.Invoke(AsyncActivation`1 ctxt) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 1666
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 109

@TheAngryByrd TheAngryByrd merged commit 0dd5098 into demystifyfp:master Jun 5, 2020
TheAngryByrd pushed a commit that referenced this pull request Jun 5, 2020
- Uses Source Computation Expression overloads to help with maintainability. Credits [Jimmy Byrd](https://github.com/TheAngryByrd) - (#83)
@TheAngryByrd TheAngryByrd mentioned this pull request Dec 2, 2021
@TheAngryByrd TheAngryByrd deleted the use-source-ce-overload branch January 11, 2022 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants