A code generator providing Haskell-inspired functional programming utilities for Go, with built-in immutable and type-safe slice operations.
Hasgo is a Go library and code generator that provides Haskell-inspired functional programming utilities for working with slices. It solves the problem of writing repetitive, imperative slice manipulation code by offering a rich set of immutable, type-safe operations like map, filter, fold, and more, enabling more declarative and expressive Go code.
Go developers who appreciate functional programming paradigms and want to write more declarative, immutable, and expressive code when working with slices, especially those familiar with Haskell or similar languages.
Developers choose Hasgo because it brings the elegance and power of Haskell's functional utilities to Go in a type-safe and idiomatic way, reducing boilerplate code and offering a rich set of operations that are immutable and nil-safe by design.
Haskell-flavoured functions for Go :smiley:
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Offers over 40 Haskell-inspired functions like map, filter, and fold, enabling expressive and declarative slice manipulations without boilerplate code, as detailed in the function table.
Avoids interface{} and ensures all operations are strongly typed and nil-safe, adhering to the README's focus on immutability and strong typing without compromises.
Includes pre-defined Strings and Ints types, allowing immediate use without code generation, as mentioned in the installation and types sections.
Can generate functions for any custom type via code generation, extending utility beyond built-in types, though this requires an extra step.
For custom types, users must run the code generator, adding complexity to the build process and requiring additional tooling, which the README acknowledges as necessary for extension.
Only ints and strings are supported out-of-the-box; other types like floats need manual generation, limiting quick adoption and increasing setup time.
Immutable operations create new slices, leading to increased memory allocations and copying that may not suit performance-critical applications, a inherent trade-off of the design.