So my std wrapper makes a few design decisions in contrast to nix-stdʼs:
- modules use upper-case for namespace reasons: so
std.list becomes std.List
- because itʼs too easy to (accidentally) shadow the
std.xxx modules with local variables and function argument names
- just look at how
imports = { ... } is often used in std for this reason
- and
_optional = std.optional
- "methods" vs "constructors" and sub-namespaces are similarly distinguished:
Set.Optional vs set.optional for example
- this one seems less important? but I think there may be some value in it
list.functor may also benefit from being List.Functor?
- splits up
std.num into std.Int, std.Float and std.Complex
- the
std.num.complex sort of "sub-namespace" convention may or may not be desirable?
- more succinct names are used for modules and functions:
std.function is std.Fn
Str rather than string
List.One vs list.singleton
- types are accessable via the associated module:
std.Str.Type as an alias for std.Ty.string
std.Set.Of as an alias for std.Ty.attrsOf
std.Set.check as an alias for std.Ty.attrs.check
- modules themselves are also
__functors that perform coercion:
std.Str 5 == "5"
std.List 5 == std.List [5] == [5]
While Iʼm not necessarily proposing that these changes be adopted, I figure I should at least bring attention to them for reference and discussion, as they were things that generally came to me as improvements or pain points as I started using std more for projects.
So my std wrapper makes a few design decisions in contrast to nix-stdʼs:
std.listbecomesstd.Liststd.xxxmodules with local variables and function argument namesimports = { ... }is often used in std for this reason_optional = std.optionalSet.Optionalvsset.optionalfor examplelist.functormay also benefit from beingList.Functor?std.numintostd.Int,std.Floatandstd.Complexstd.num.complexsort of "sub-namespace" convention may or may not be desirable?std.functionisstd.FnStrrather thanstringList.Onevslist.singletonstd.Str.Typeas an alias forstd.Ty.stringstd.Set.Ofas an alias forstd.Ty.attrsOfstd.Set.checkas an alias forstd.Ty.attrs.checkshow__functors that perform coercion:std.Str 5 == "5"std.List 5 == std.List [5] == [5]While Iʼm not necessarily proposing that these changes be adopted, I figure I should at least bring attention to them for reference and discussion, as they were things that generally came to me as improvements or pain points as I started using std more for projects.