Skip to content

the case for Namespace Casing #65

@arcnmx

Description

@arcnmx

So my std wrapper makes a few design decisions in contrast to nix-stdʼs:

  1. 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
  2. "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?
  3. 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?
  4. more succinct names are used for modules and functions:
    • std.function is std.Fn
    • Str rather than string
    • List.One vs list.singleton
  5. 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
      • same goes for show
  6. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions