-
Notifications
You must be signed in to change notification settings - Fork 4
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
Make Option
and List
structures more consistent with each other
#19
Comments
Some of these discrepancies are historical. BTW, which |
|
I don't understand how
They have different types. |
@MatthewFluet What about |
@jonsterling Sure, |
@MatthewFluet Ah, I see what you mean—I think the sense in which @eduardoleon meant "special case" was "factors through". My personal view is, I would caution against going too deep down the rabbit hole of trying to define basis library structures in terms of a collection of algebraic and categorical signatures, like monad, etc. As was learned the hard way in Haskell, this style eventually force arbitrary decisions which rely on a unicity of structure which simply is not justified (e.g. what is the relation between the units of the monad and the lax monoidal / applicative structure?). My preference would be to keep that stuff out of the basic |
I don't think that would be a problem in SML, since you can always define a separate structure that reuses the same types.
Inside the same structure, the units should agree. (Or, in fact, there should only be one unit common to both.) In different structures, they might be different. |
Sure—my point was not about problems with coherence; I was suggesting that we don't want to privilege one over the other by embedding it in the basis structure. |
Presumably the purpose of aligning these modules with each other is so you can write code (functors) that are generic over both via treating What should be done instead (though probably not in the Basis Library) is having a separate adapter module Aside from that, some situations require flexibility that typeclasses can't provide and instead need |
The
option
andlist
datatypes have a lot in common of each other. Both support the following operations:The above list of operations is far from exhaustive.
Unfortunately, the API exposed by the Basis Library introduces unnecessary discrepancies:
Option
hasOption.isSome
, butList
hasList.null
Option
hasOption.join
, butList
hasList.concat
List
hasList.mapPartial
, rather thanList.concatMap
List
also make sense foroption
s, butOption
doesn't provide themWould it be possible to fix these discrepancies?
The text was updated successfully, but these errors were encountered: