Code Monkey home page Code Monkey logo

core's Introduction

Functional Programming Core Libraries for Go

This repository contains core libraries for functional programming (FP) in Go. Below is a description of the packages herein:

  • fn - functions and structures for working with functions. For example, you can use Compose to join two functions together, and Curry to split them apart.
  • slice - fundamental operations on slices. For example, you can get the head (first element) or tail (everything but the first element) of a slice each with a function call.

FP Theory

This repository aims to draw on FP theory to introduce useful functionality to the Go ecosystem. As such, you'll likely not see data structures or containers like Option, Functor, etc... here. You will, however, see the practical applications of the functionality those concepts. \

For example, this repository provides convenient Map and FlatMap functionality over slices, which would generally be under the purview of functors and monads, respectively.

Note: Work in Progress

This repository is a work in progress, and is subject to change. This is primarily because it relies heavily on Go's Generics feature, which itself is changing. As generics evolves, this library will do so to take advantage of developments in Generics as appropriate.

To use the code herein, you'll need the Go toolchain at least at version 1.17, and you'll need to build with the -gcflags=-G=3. For example, to run the tests herein:

go test -gcflags=-G=3 ./...

At the current version of Go, you'll get an error that looks like the below, and prevents even tests from passing. That's expected and as the generics feature progresses, it will go away.

internal compiler error: Cannot export a generic function (yet).

Resources and Learning

Not many resources exist for learning how to apply FP concepts to Go. To learn more about the concepts herein, please see the following:

Contributing

If you're interested, please contribute any way you wish. Here are some ideas:

  • Submit an issue with a question, comment, or anything else
  • Make a change and submit a pull request. Even if you aren't a "FP person" or don't know what you're doing, I want to hear what you think, and sometimes the best way to do that is through code :)
  • Ping me on Twitter @arschles

core's People

Contributors

arschles avatar tehsphinx avatar jonathangb avatar leonklingele avatar

Watchers

Sam Zaydel avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.