Skip to content

Tags: thecsw/gana

Tags

v0.1.0

Toggle v0.1.0's commit message

Partially verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
Add Prelude subpackage (#15)

This is a draft PR of an (experimental?) design for a "fundamental"
package.

Imagine this subpackage as a collection of builtins. That is, to use it,
one would:
```go
import (
  . "github.com/thecsw/gana/prelude"
)
```
This will allow you to use functions such as `Some` without writing
`prelude.Some`.

Importing in to the local scope is looked down upon in Go, with the main
reason being future package versions can introduce new symbols that will
clash with your locally defined symbols.
I believe we can circumvent this by defining a strict spec of exported
symbols in `prelude`, keeping it to a minimum and anything new is a
major version bump (once we start versioning).

I have currently added the `Option` and `Result` types, along with some
defined methods and their relevant tests.

The current "reserved" symbols are: `Option`, `Some`, `SomeT`, `None`,
`NoneT`, `Maybe`, `Result`, `Ok`, `OkT`, `Err`, `ErrT`, `Try`.

I will continue experimenting with the ergonomics, and rewrite the rest
of the `gana` package to use these features "idiomatically" (me figuring
out what looks the best and changing this API).

---------

Co-authored-by: Sandy <16922860+thecsw@users.noreply.github.com>