-
Notifications
You must be signed in to change notification settings - Fork 276
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
Float Like A Butterfly: Introduce PresenceBox, TryBox, and ParamTryBox. #1876
base: main
Are you sure you want to change the base?
Commits on Jul 7, 2017
-
Introduce PresenceBox, TryBox, and ParamTryBox.
These three intermediary types allow APIs and consumers of boxes to indicate that they expect a particular subset of Box types. This is useful to restrict types to what is expected, while still being able to interoperate with APIs designed to interact with many all Box types. For example, you can declare that a function expectes a PresenceBox to ensure that interactors guarantee either a Full or Empty is passed. Or, you can specify that your function returns a TryBox so callers only need to worry about handling a Full or a Failure. Lastly, ParamTryBox allows indicating that a given situation will only get a Full or a ParamFailure with a particular error type. A lot of tests and additional API conversions are required to fully bring this vision to fruition, but this is the foundation for that work.
Configuration menu - View commit details
-
Copy full SHA for 9b09bf1 - Browse repository at this point
Copy the full SHA 9b09bf1View commit details
Commits on Jul 8, 2017
-
Make pass and $ return self.type.
This allows us to make sure that we don't lose the specific type of the Box when doing a pass operation. This was less important when the only supertype was `Box`, but now that we can have the more specific `PresenceBox`, `TryBox`, and `ParamTryBox`, preserving those supertypes is more important.
Configuration menu - View commit details
-
Copy full SHA for b1b3035 - Browse repository at this point
Copy the full SHA b1b3035View commit details
Commits on Jul 9, 2017
-
Tweak collect and collectFirst typing for PresenceBox.
In particular, collect and collectFirst will always return a PresenceBox when invoked on a PresenceBox. This is not the case for the other subtypes.
Configuration menu - View commit details
-
Copy full SHA for 671a958 - Browse repository at this point
Copy the full SHA 671a958View commit details -
Tweak typing in flatMap, map, flatten, filter, filterNot, isA, and asA.
In particular, cases where each of these can guarantee a subtype of Box have reimplementations that do so. PresenceBox also adds a specialization of withFilter, which is used in for comprehensions, that ensures that typing carries through.
Configuration menu - View commit details
-
Copy full SHA for 592e94e - Browse repository at this point
Copy the full SHA 592e94eView commit details -
Adjust typing on a few Box singleton functions.
These can now have more specific types.
Configuration menu - View commit details
-
Copy full SHA for f22afbe - Browse repository at this point
Copy the full SHA f22afbeView commit details -
Scaladoc updates for a few places in Box.
Also added a blurb to the Box scaladocs regarding the Box subtypes.
Configuration menu - View commit details
-
Copy full SHA for 9b906eb - Browse repository at this point
Copy the full SHA 9b906ebView commit details -
Configuration menu - View commit details
-
Copy full SHA for 90ad32f - Browse repository at this point
Copy the full SHA 90ad32fView commit details
Commits on Aug 5, 2017
-
Drop attempt at flatten type specialization.
Due to the way Scala resolves method overloads with implicit parameters, I haven't been able to find a good way of defining that a TryBox that contains a TryBox should flatten to a TryBox, and a PresenceBox that contains a PresenceBox should flatten to a PresenceBox. Unfortunately Scala seems to resolve the overload of flatten based solely on class hierarchy and number of parameters, and then fails the compile if it can't plug the proper implicits in, rather than using the available implicit evidence to choose between overloads. Since we rely entirely on implicit evidence to know what we can do with the contained type of the box, there's no way (that I could find) to express diverging return types based on the contained type :( Instead, TryBox and PresenceBox each have their own flattenTry and flattenPresence methods, respectively, which will only compile if their contents match the container type. This means the caller has to choose the appropriate one to call, but at least it ensures you *can* flatten that way if you really want to.
Configuration menu - View commit details
-
Copy full SHA for a8f1402 - Browse repository at this point
Copy the full SHA a8f1402View commit details
Commits on Sep 17, 2017
-
Configuration menu - View commit details
-
Copy full SHA for ccb507b - Browse repository at this point
Copy the full SHA ccb507bView commit details -
Add preliminary BoxTypingSpec.
This spec is designed to test that Box's various methods produce the expected resulting types.
Configuration menu - View commit details
-
Copy full SHA for f20573c - Browse repository at this point
Copy the full SHA f20573cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 12012bd - Browse repository at this point
Copy the full SHA 12012bdView commit details
Commits on Sep 25, 2017
-
Fix Full flatMap for ParamTryBox.
The existing definition wasn't actually catching for all ParamTryBoxes.
Configuration menu - View commit details
-
Copy full SHA for 69bfa97 - Browse repository at this point
Copy the full SHA 69bfa97View commit details -
Configuration menu - View commit details
-
Copy full SHA for 86f3503 - Browse repository at this point
Copy the full SHA 86f3503View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8679ca2 - Browse repository at this point
Copy the full SHA 8679ca2View commit details -
Move flattenPresence/flattenTry specs into their own examples.
Also add some scaladocs to those two methods.
Configuration menu - View commit details
-
Copy full SHA for 28d5d57 - Browse repository at this point
Copy the full SHA 28d5d57View commit details -
Drop ??? definitions of collect and map.
We do this by dropping the concrete definitions of these two methods in Box, preferring instead to lean 100% on late binding to resolve the correct concrete definition of the method based on the concrete type it is being invoked on.
Configuration menu - View commit details
-
Copy full SHA for 4b8fb17 - Browse repository at this point
Copy the full SHA 4b8fb17View commit details -
Configuration menu - View commit details
-
Copy full SHA for f58523f - Browse repository at this point
Copy the full SHA f58523fView commit details