kotools / types

Explicit types for Kotlin Multiplatform.
https://types.kotools.org
MIT License
90 stars 6 forks source link

✨ Simplify constructors for `Zero` #676

Closed LVMVRQUXL closed 3 months ago

LVMVRQUXL commented 3 months ago

📝 Description

For aligning with our design goals on less is more, we want to provide only constructors for creating an instance of the Zero type in a natural way. These constructors should be accessible from all Kotlin platforms and Java.

Here's the Application Programming Interface (API) goal that we want to achieve with this issue:

class Zero {
    constructor() // Already introduced in v4.5.1.
    constructor(number: Any)
}

These constructors should replace all factory functions introduced previously for the Zero type.

Also, the Zero.Companion.PATTERN property being used only by the constructor(Any) function of the Zero type, we want to remove it from the public experimental API and merge its documentation into this constructor's documentation.

✅ Checklist

LVMVRQUXL commented 3 months ago

After resolving this issue, we will be able to introduce the ZeroAsStringSerializer type in the types-kotlinx-serialization subproject for serializing the Zero type as String. This could be useful for communicating an already formatted zero like 0.00.

LVMVRQUXL commented 3 months ago

Using RegExr might be a solution for storing and documenting the regular expression used by the constructor(Any) function.

LVMVRQUXL commented 3 months ago

Superseded by #681.