dfinity / motoko-base

The Motoko base library
Apache License 2.0
483 stars 99 forks source link

Each primitive module should export an eponymous type #89

Open crusso opened 4 years ago

crusso commented 4 years ago

To avoid cylic definitions, requires a cycle breaking Types.mo (useful anyway) or motoko's special mo:prim to export all primitive types under their own name.

crusso commented 4 years ago

Actually, I'm now wondering if it would in fact be better to just uniformly call these Type, (Word32.Type etc.) to avoid the circularity, redundant Word32.Word32 and in anticipation of functors. @rossberg @nomeata @matthewhammer

nomeata commented 4 years ago

motoko's special mo:prim to export all primitive types under their own name

That seems reasonable and non-intrusive

rossberg commented 4 years ago

Hm, I'm sceptical. IME, it is more cryptic and less natural to most folks, and it gets in the way of import {...} = "..." (which we should add). OTOH, functors are not going to be relevant for Motoko anytime soon. And: not even SML does it. ;)

I remember a discussion on TC39, where some folks argued that this pattern demonstrates why ML modules are a practical failure...

nomeata commented 4 years ago

What are you sceptical about? Exporting Int.Type, Int.Int or anything at all?

rossberg commented 4 years ago

@nomeata, I mean Int.Type.

crusso commented 4 years ago

Fine, I'll go for the prim extension and add eponymous type components. We can always add *.Type later if it ever becomes useful