1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-12-07 23:03:15 +02:00

Compare commits

...

9 Commits

Author SHA1 Message Date
Dr. Carsten Leue
79834541bf fix: doc and parameter order
Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
2023-07-19 16:20:28 +02:00
Carsten Leue
34bf3635b9 Merge pull request #4 from IBM/cleue-getting-started-docs
doc: some docs
2023-07-18 16:52:49 +02:00
Oliver Rau
058026302b build: Make sure semantic release is installed
Signed-off-by: Oliver Rau <oliver.rau@de.ibm.com>
2023-07-18 16:10:05 +02:00
Oliver Rau
302a57820b build: Fix build.yml location
Signed-off-by: Oliver Rau <oliver.rau@de.ibm.com>
2023-07-18 16:06:29 +02:00
Carsten Leue
694a507fdd Merge pull request #2 from IBM/olira/feat/build
build: Add build scripts
2023-07-18 16:03:07 +02:00
Carsten Leue
980bbf40c5 Merge pull request #3 from IBM/cleue-add-doc
Cleue add doc
2023-07-18 15:58:24 +02:00
Dr. Carsten Leue
b25de3c7c3 doc: fix case
Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
2023-07-18 15:57:54 +02:00
Oliver Rau
7d9dedb80f build: Add build scripts
Signed-off-by: Oliver Rau <oliver.rau@de.ibm.com>
2023-07-18 15:57:29 +02:00
Dr. Carsten Leue
308fe48718 doc: try package doc
Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
2023-07-18 15:45:02 +02:00
299 changed files with 907 additions and 689 deletions

85
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,85 @@
name: fp-go CI
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
inputs:
dryRun:
description: 'Dry-Run'
default: 'true'
required: false
env:
# Currently no way to detect automatically
DEFAULT_BRANCH: main
GO_VERSION: 1.20.5 # renovate: datasource=golang-version depName=golang
NODE_VERSION: 18
DRY_RUN: true
jobs:
build:
runs-on: ubuntu-latest
steps:
# full checkout for semantic-release
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 0
- name: Set up go ${{env.GO_VERSION}}
uses: actions/setup-go@v4
with:
go-version: ${{env.GO_VERSION}}
-
name: Tests
run: |
go mod tidy
go test -v ./...
release:
needs: [build]
if: github.repository == 'IBM/fp-go' && github.event_name != 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write
issues: write
pull-requests: write
steps:
# full checkout for semantic-release
- name: Full checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 0
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3.7.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Set up go ${{env.GO_VERSION}}
uses: actions/setup-go@v4
with:
go-version: ${{env.GO_VERSION}}
# The dry-run evaluation is only made for non PR events. Manual trigger w/dryRun true, main branch and any tagged branches will set DRY run to false
- name: Check dry run
run: |
if [[ "${{github.event_name}}" == "workflow_dispatch" && "${{ github.event.inputs.dryRun }}" != "true" ]]; then
echo "DRY_RUN=false" >> $GITHUB_ENV
elif [[ "${{github.ref}}" == "refs/heads/${{env.DEFAULT_BRANCH}}" ]]; then
echo "DRY_RUN=false" >> $GITHUB_ENV
elif [[ "${{github.ref}}" =~ ^refs/heads/v[0-9]+(\.[0-9]+)?$ ]]; then
echo "DRY_RUN=false" >> $GITHUB_ENV
fi
- name: Semantic Release
run: |
npx -p conventional-changelog-conventionalcommits -p semantic-release semantic-release --dry-run ${{env.DRY_RUN}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

67
.releaserc Normal file
View File

@@ -0,0 +1,67 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/github",
{
"releasedLabels": false
}
]
],
"analyzeCommits": {
"releaseRules": [
{
"type": "build",
"release": "patch"
}
]
},
"preset": "conventionalcommits",
"presetConfig": {
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "perf",
"section": "Performance Improvements"
},
{
"type": "revert",
"section": "Reverts"
},
{
"type": "docs",
"section": "Documentation"
},
{
"type": "chore",
"section": "Miscellaneous Chores"
},
{
"type": "refactor",
"section": "Code Refactoring"
},
{
"type": "test",
"section": "Tests"
},
{
"type": "build",
"section": "Build System"
}
]
},
"tagFormat": "v${version}",
"branches": [
{
"name": "main"
}
]
}

View File

@@ -29,7 +29,7 @@ This library aims to provide a set of data types and functions that make it easy
#### 🧘🏽 Each package fulfils a single purpose
✔️ Each of the top level packages (e.g. Option, Either, Task, ...) fulfils the purpose of defining the respective data type and implementing the set of common operations for this data type.
✔️ Each of the top level packages (e.g. Option, Either, ReaderIOEither, ...) fulfils the purpose of defining the respective data type and implementing the set of common operations for this data type.
#### 🧘🏽 Handle errors explicitly
@@ -41,7 +41,7 @@ This library aims to provide a set of data types and functions that make it easy
#### 🧘🏽 Leave concurrency to the caller
✔️ All operations are synchronous by default, including `Task`. Concurrency must be coded by the consumer of these functions explicitly, but the implementation is ready to deal with concurrent usage.
✔️ All pure are synchronous by default. The I/O operations are asynchronous per default.
#### 🧘🏽 Before you launch a goroutine, know when it will stop
@@ -65,7 +65,7 @@ This library aims to provide a set of data types and functions that make it easy
#### 🧘🏽 Moderation is a virtue
✔️ The library does not implement its own goroutines and also does not require any expensive synchronization primitives. Coordination of Tasks is implemented via atomic counters without additional primitives. Channels are only used in the `Wait` function of a Task that should be invoked at most once in a complete application.
✔️ The library does not implement its own goroutines and also does not require any expensive synchronization primitives. Coordination of IO operations is implemented via atomic counters without additional primitives.
#### 🧘🏽 Maintainability counts
@@ -81,33 +81,57 @@ All monadic operations are implemented via generics, i.e. they offer a type safe
Downside is that this will result in different versions of each operation per type, these versions are generated by the golang compiler at build time (unlike type erasure in languages such as Java of TypeScript). This might lead to large binaries for codebases with many different types. If this is a concern, you can always implement type erasure on top, i.e. use the monadic operations with the `any` type as if generics were not supported. You loose type safety, but this might result in smaller binaries.
### Ordering of Generic Type Parameters
In go we need to specify all type parameters of a function on the global function definition, even if the function returns a higher order function and some of the type parameters are only applicable to the higher order function. So the following is not possible:
```go
func Map[A, B any](f func(A) B) [R, E any]func(fa ReaderIOEither[R, E, A]) ReaderIOEither[R, E, B]
```
Note that the parameters `R` and `E` are not needed by the first level of `Map` but only by the resulting higher order function. Instead we need to specify the following:
```go
func Map[R, E, A, B any](f func(A) B) func(fa ReaderIOEither[R, E, A]) ReaderIOEither[R, E, B]
```
which overspecifies `Map` on the global scope. As a result the go compiler will not be able to auto-detect these parameters, it can only auto detect `A` and `B` since they appear in the argument of `Map`. We need to explicitly pass values for these type parameters when `Map` is being used.
Because of this limitation the order of parameters on a function matters. We want to make sure that we define those parameters that cannot be auto-detected, first, and the parameters that can be auto-detected, last. This can lead to inconsistencies in parameter ordering, but we believe that the gain in convenience is worth it. The parameter order of `Ap` is e.g. different from that of `Map`:
```go
func Ap[B, R, E, A any](fa ReaderIOEither[R, E, A]) func(fab ReaderIOEither[R, E, func(A) B]) ReaderIOEither[R, E, B]
```
because `R`, `E` and `A` can be determined from the argument to `Ap` but `B` cannot.
### Use of the [~ Operator](https://go.googlesource.com/proposal/+/master/design/47781-parameterized-go-ast.md)
The FP library attempts to be easy to consume and one aspect of this is the definition of higher level type definitions instead of having to use their low level equivalent. It is e.g. more convenient and readable to use
```go
TaskEither[E, A]
ReaderIOEither[R, E, A]
```
than
```go
func(func(Either.Either[E, A]))
func(R) func() Either.Either[E, A]
```
although both are logically equivalent. At the time of this writing the go type system does not support generic type aliases, only generic type definition, i.e. it is not possible to write:
```go
type TaskEither[E, A any] = T.Task[ET.Either[E, A]]
type ReaderIOEither[R, E, A any] = RD.Reader[R, IOE.IOEither[E, A]]
```
only
```go
type TaskEither[E, A any] T.Task[ET.Either[E, A]]
type ReaderIOEither[R, E, A any] RD.Reader[R, IOE.IOEither[E, A]]
```
This makes a big difference, because in the second case the type `TaskEither[E, A any]` is considered a completely new type, not compatible to its right hand side, so it's not just a shortcut but a fully new type.
This makes a big difference, because in the second case the type `ReaderIOEither[R, E, A any]` is considered a completely new type, not compatible to its right hand side, so it's not just a shortcut but a fully new type.
From the implementation perspective however there is no reason to restrict the implementation to the new type, it can be generic for all compatible types. The way to express this in go is the [~](https://go.googlesource.com/proposal/+/master/design/47781-parameterized-go-ast.md) operator. This comes with some quite complicated type declarations in some cases, which undermines the goal of the library to be easy to use.
@@ -117,16 +141,16 @@ For that reason there exist sub-packages called `Generic` for all higher level t
Go does not support higher kinded types (HKT). Such types occur if a generic type itself is parametrized by another generic type. Example:
The `Map` operation for `Task` is defined as:
The `Map` operation for `ReaderIOEither` is defined as:
```go
func Map[A, B any](f func(A) B) func(Task[A]) Task[B]
func Map[R, E, A, B any](f func(A) B) func(fa ReaderIOEither[R, E, A]) ReaderIOEither[R, E, B]
```
and in fact the equivalent operations for all other mondas follow the same pattern, we could try to introduce a new type for `Task` (without a parameter) as a HKT, e.g. like so (made-up syntax, does not work in go):
and in fact the equivalent operations for all other mondas follow the same pattern, we could try to introduce a new type for `ReaderIOEither` (without a parameter) as a HKT, e.g. like so (made-up syntax, does not work in go):
```go
func Map[HKT, A, B any](f func(A) B) func(HKT[A]) HKT[B]
func Map[HKT, R, E, A, B any](f func(A) B) func(HKT[R, E, A]) HKT[R, E, B]
```
this would be the completely generic method signature for all possible monads. In particular in many cases it is possible to compose functions independent of the concrete knowledge of the actual `HKT`. From the perspective of a library this is the ideal situation because then a particular algorithm only has to be implemented and tested once.

View File

@@ -1,12 +1,12 @@
package array
import (
G "github.com/ibm/fp-go/array/generic"
F "github.com/ibm/fp-go/function"
"github.com/ibm/fp-go/internal/array"
M "github.com/ibm/fp-go/monoid"
O "github.com/ibm/fp-go/option"
"github.com/ibm/fp-go/tuple"
G "github.com/IBM/fp-go/array/generic"
F "github.com/IBM/fp-go/function"
"github.com/IBM/fp-go/internal/array"
M "github.com/IBM/fp-go/monoid"
O "github.com/IBM/fp-go/option"
"github.com/IBM/fp-go/tuple"
)
// From constructs an array from a set of variadic arguments

View File

@@ -4,11 +4,11 @@ import (
"strings"
"testing"
F "github.com/ibm/fp-go/function"
"github.com/ibm/fp-go/internal/utils"
O "github.com/ibm/fp-go/option"
S "github.com/ibm/fp-go/string"
T "github.com/ibm/fp-go/tuple"
F "github.com/IBM/fp-go/function"
"github.com/IBM/fp-go/internal/utils"
O "github.com/IBM/fp-go/option"
S "github.com/IBM/fp-go/string"
T "github.com/IBM/fp-go/tuple"
"github.com/stretchr/testify/assert"
)

View File

@@ -1,7 +1,7 @@
package array
import (
E "github.com/ibm/fp-go/eq"
E "github.com/IBM/fp-go/eq"
)
func equals[T any](left []T, right []T, eq func(T, T) bool) bool {

View File

@@ -1,10 +1,10 @@
package generic
import (
F "github.com/ibm/fp-go/function"
"github.com/ibm/fp-go/internal/array"
O "github.com/ibm/fp-go/option"
"github.com/ibm/fp-go/tuple"
F "github.com/IBM/fp-go/function"
"github.com/IBM/fp-go/internal/array"
O "github.com/IBM/fp-go/option"
"github.com/IBM/fp-go/tuple"
)
// Of constructs a single element array

View File

@@ -3,7 +3,7 @@ package generic
import (
"sort"
O "github.com/ibm/fp-go/ord"
O "github.com/IBM/fp-go/ord"
)
// Sort implements a stable sort on the array given the provided ordering

View File

@@ -1,8 +1,8 @@
package array
import (
F "github.com/ibm/fp-go/function"
M "github.com/ibm/fp-go/magma"
F "github.com/IBM/fp-go/function"
M "github.com/IBM/fp-go/magma"
)
func ConcatAll[A any](m M.Magma[A]) func(A) func([]A) A {

View File

@@ -5,7 +5,7 @@ import (
"github.com/stretchr/testify/assert"
M "github.com/ibm/fp-go/magma"
M "github.com/IBM/fp-go/magma"
)
var subInt = M.MakeMagma(func(first int, second int) int {

View File

@@ -1,8 +1,8 @@
package array
import (
"github.com/ibm/fp-go/internal/array"
M "github.com/ibm/fp-go/monoid"
"github.com/IBM/fp-go/internal/array"
M "github.com/IBM/fp-go/monoid"
)
func concat[T any](left, right []T) []T {

View File

@@ -3,7 +3,7 @@ package array
import (
"testing"
M "github.com/ibm/fp-go/monoid/testing"
M "github.com/IBM/fp-go/monoid/testing"
)
func TestMonoid(t *testing.T) {

View File

@@ -1,8 +1,8 @@
package array
import (
F "github.com/ibm/fp-go/function"
O "github.com/ibm/fp-go/option"
F "github.com/IBM/fp-go/function"
O "github.com/IBM/fp-go/option"
)
// We need to pass the members of the applicative explicitly, because golang does neither support higher kinded types nor template methods on structs or interfaces

View File

@@ -5,7 +5,7 @@ import (
"github.com/stretchr/testify/assert"
O "github.com/ibm/fp-go/option"
O "github.com/IBM/fp-go/option"
)
func TestSequenceOption(t *testing.T) {

View File

@@ -1,8 +1,8 @@
package array
import (
G "github.com/ibm/fp-go/array/generic"
O "github.com/ibm/fp-go/ord"
G "github.com/IBM/fp-go/array/generic"
O "github.com/IBM/fp-go/ord"
)
// Sort implements a stable sort on the array given the provided ordering

View File

@@ -3,7 +3,7 @@ package array
import (
"testing"
O "github.com/ibm/fp-go/ord"
O "github.com/IBM/fp-go/ord"
"github.com/stretchr/testify/assert"
)

View File

@@ -1,6 +1,6 @@
package array
import "github.com/ibm/fp-go/internal/array"
import "github.com/IBM/fp-go/internal/array"
func Traverse[A, B, HKTB, HKTAB, HKTRB any](
fof func([]B) HKTRB,

View File

@@ -3,7 +3,7 @@ package array
import (
"testing"
O "github.com/ibm/fp-go/option"
O "github.com/IBM/fp-go/option"
"github.com/stretchr/testify/assert"
)

View File

@@ -3,8 +3,8 @@ package bytes
import (
"bytes"
A "github.com/ibm/fp-go/array"
O "github.com/ibm/fp-go/ord"
A "github.com/IBM/fp-go/array"
O "github.com/IBM/fp-go/ord"
)
var (

View File

@@ -3,7 +3,7 @@ package bytes
import (
"testing"
M "github.com/ibm/fp-go/monoid/testing"
M "github.com/IBM/fp-go/monoid/testing"
)
func TestMonoid(t *testing.T) {

View File

@@ -380,8 +380,8 @@ func generateApplyHelpers(filename string, count int) error {
// print out some helpers
fmt.Fprintf(f, `
import (
F "github.com/ibm/fp-go/function"
T "github.com/ibm/fp-go/tuple"
F "github.com/IBM/fp-go/function"
T "github.com/IBM/fp-go/tuple"
)
`)

View File

@@ -5,7 +5,6 @@ import (
"log"
"os"
"path/filepath"
"time"
C "github.com/urfave/cli/v2"
)
@@ -84,34 +83,24 @@ func generateContextReaderIOEitherHelpers(filename string, count int) error {
// log
log.Printf("Generating code in [%s] for package [%s] with [%d] repetitions ...", filename, pkg, count)
// some header
fmt.Fprintln(f, "// Code generated by go generate; DO NOT EDIT.")
fmt.Fprintln(f, "// This file was generated by robots at")
fmt.Fprintf(f, "// %s\n", time.Now())
fmt.Fprintf(f, "package %s\n\n", pkg)
writePackage(f, pkg)
fmt.Fprintf(f, `
import (
"context"
G "github.com/ibm/fp-go/context/%s/generic"
G "github.com/IBM/fp-go/context/%s/generic"
)
`, pkg)
// some header
fmt.Fprintln(fg, "// Code generated by go generate; DO NOT EDIT.")
fmt.Fprintln(fg, "// This file was generated by robots at")
fmt.Fprintf(fg, "// %s\n", time.Now())
fmt.Fprintf(fg, "package generic\n\n")
writePackage(fg, "generic")
fmt.Fprintf(fg, `
import (
"context"
E "github.com/ibm/fp-go/either"
RE "github.com/ibm/fp-go/readerioeither/generic"
E "github.com/IBM/fp-go/either"
RE "github.com/IBM/fp-go/readerioeither/generic"
)
`)

View File

@@ -141,8 +141,8 @@ func generateEitherHelpers(filename string, count int) error {
fmt.Fprintf(f, `
import (
A "github.com/ibm/fp-go/internal/apply"
T "github.com/ibm/fp-go/tuple"
A "github.com/IBM/fp-go/internal/apply"
T "github.com/IBM/fp-go/tuple"
)
`)

16
cli/header.go Normal file
View File

@@ -0,0 +1,16 @@
package cli
import (
"fmt"
"os"
"time"
)
func writePackage(f *os.File, pkg string) {
// print package
fmt.Fprintf(f, "package %s\n\n", pkg)
// some header
fmt.Fprintln(f, "// Code generated by go generate; DO NOT EDIT.")
fmt.Fprintln(f, "// This file was generated by robots at")
fmt.Fprintf(f, "// %s\n", time.Now())
}

View File

@@ -53,8 +53,8 @@ func generateIdentityHelpers(filename string, count int) error {
fmt.Fprintf(f, `
import (
A "github.com/ibm/fp-go/internal/apply"
T "github.com/ibm/fp-go/tuple"
A "github.com/IBM/fp-go/internal/apply"
T "github.com/IBM/fp-go/tuple"
)
`)

View File

@@ -139,8 +139,8 @@ func generateOptionHelpers(filename string, count int) error {
fmt.Fprintf(f, `
import (
A "github.com/ibm/fp-go/internal/apply"
T "github.com/ibm/fp-go/tuple"
A "github.com/IBM/fp-go/internal/apply"
T "github.com/IBM/fp-go/tuple"
)
`)

View File

@@ -123,7 +123,7 @@ func generateReaderHelpers(filename string, count int) error {
fmt.Fprintf(f, `
import (
G "github.com/ibm/fp-go/%s/generic"
G "github.com/IBM/fp-go/%s/generic"
)
`, pkg)

View File

@@ -160,7 +160,7 @@ func generateReaderIOEitherHelpers(filename string, count int) error {
fmt.Fprintf(f, `
import (
G "github.com/ibm/fp-go/%s/generic"
G "github.com/IBM/fp-go/%s/generic"
)
`, pkg)
@@ -173,8 +173,8 @@ import (
fmt.Fprintf(fg, `
import (
E "github.com/ibm/fp-go/either"
RD "github.com/ibm/fp-go/reader/generic"
E "github.com/IBM/fp-go/either"
RD "github.com/IBM/fp-go/reader/generic"
)
`)

View File

@@ -346,8 +346,8 @@ func generateTupleHelpers(filename string, count int) error {
fmt.Fprintf(f, `
import (
M "github.com/ibm/fp-go/monoid"
O "github.com/ibm/fp-go/ord"
M "github.com/IBM/fp-go/monoid"
O "github.com/IBM/fp-go/ord"
)
`)

View File

@@ -12,4 +12,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Package context contains versions of monads that work with a golang [context.Context]
package context

View File

@@ -3,9 +3,9 @@ package generic
import (
"context"
E "github.com/ibm/fp-go/either"
ET "github.com/ibm/fp-go/either"
IOE "github.com/ibm/fp-go/ioeither/generic"
E "github.com/IBM/fp-go/either"
ET "github.com/IBM/fp-go/either"
IOE "github.com/IBM/fp-go/ioeither/generic"
)
// withContext wraps an existing IOEither and performs a context check for cancellation before delegating

View File

@@ -3,8 +3,8 @@ package ioeither
import (
"context"
G "github.com/ibm/fp-go/context/ioeither/generic"
IOE "github.com/ibm/fp-go/ioeither"
G "github.com/IBM/fp-go/context/ioeither/generic"
IOE "github.com/IBM/fp-go/ioeither"
)
// withContext wraps an existing IOEither and performs a context check for cancellation before delegating

View File

@@ -16,7 +16,7 @@
package reader
import (
R "github.com/ibm/fp-go/reader/generic"
R "github.com/IBM/fp-go/reader/generic"
)
// TraverseArray transforms an array

View File

@@ -18,7 +18,7 @@ package reader
import (
"context"
R "github.com/ibm/fp-go/reader/generic"
R "github.com/IBM/fp-go/reader/generic"
)
// these functions curry a golang function with the context as the firsr parameter into a either reader with the context as the last parameter

View File

@@ -3,7 +3,7 @@ package reader
import (
"context"
R "github.com/ibm/fp-go/reader/generic"
R "github.com/IBM/fp-go/reader/generic"
)
// these functions curry a golang function with the context as the firsr parameter into a either reader with the context as the last parameter

View File

@@ -3,7 +3,7 @@ package reader
import (
"context"
R "github.com/ibm/fp-go/reader/generic"
R "github.com/IBM/fp-go/reader/generic"
)
func MonadMap[A, B any](fa Reader[A], f func(A) B) Reader[B] {

View File

@@ -6,8 +6,8 @@ import (
"strings"
"testing"
F "github.com/ibm/fp-go/function"
T "github.com/ibm/fp-go/tuple"
F "github.com/IBM/fp-go/function"
T "github.com/IBM/fp-go/tuple"
"github.com/stretchr/testify/assert"
)

View File

@@ -1,8 +1,8 @@
package reader
import (
R "github.com/ibm/fp-go/reader/generic"
T "github.com/ibm/fp-go/tuple"
R "github.com/IBM/fp-go/reader/generic"
T "github.com/IBM/fp-go/tuple"
)
// SequenceT converts n inputs of higher kinded types into a higher kinded types of n strongly typed values, represented as a tuple

View File

@@ -4,7 +4,7 @@ package reader
import (
"context"
R "github.com/ibm/fp-go/reader"
R "github.com/IBM/fp-go/reader"
)
// Reader is a specialization of the Reader monad assuming a golang context as the context of the monad

View File

@@ -1,7 +1,7 @@
package readereither
import (
RE "github.com/ibm/fp-go/readereither/generic"
RE "github.com/IBM/fp-go/readereither/generic"
)
// TraverseArray transforms an array

View File

@@ -3,7 +3,7 @@ package readereither
import (
"context"
E "github.com/ibm/fp-go/either"
E "github.com/IBM/fp-go/either"
)
// withContext wraps an existing ReaderEither and performs a context check for cancellation before deletating

View File

@@ -3,7 +3,7 @@ package readereither
import (
"context"
RE "github.com/ibm/fp-go/readereither/generic"
RE "github.com/IBM/fp-go/readereither/generic"
)
// these functions curry a golang function with the context as the firsr parameter into a either reader with the context as the last parameter

View File

@@ -3,11 +3,11 @@ package exec
import (
"context"
RE "github.com/ibm/fp-go/context/readereither"
E "github.com/ibm/fp-go/either"
"github.com/ibm/fp-go/exec"
F "github.com/ibm/fp-go/function"
GE "github.com/ibm/fp-go/internal/exec"
RE "github.com/IBM/fp-go/context/readereither"
E "github.com/IBM/fp-go/either"
"github.com/IBM/fp-go/exec"
F "github.com/IBM/fp-go/function"
GE "github.com/IBM/fp-go/internal/exec"
)
var (

View File

@@ -3,7 +3,7 @@ package readereither
import (
"context"
RE "github.com/ibm/fp-go/readereither/generic"
RE "github.com/IBM/fp-go/readereither/generic"
)
// these functions curry a golang function with the context as the firsr parameter into a either reader with the context as the last parameter

View File

@@ -3,10 +3,10 @@ package readereither
import (
"context"
R "github.com/ibm/fp-go/context/reader"
ET "github.com/ibm/fp-go/either"
O "github.com/ibm/fp-go/option"
RE "github.com/ibm/fp-go/readereither/generic"
R "github.com/IBM/fp-go/context/reader"
ET "github.com/IBM/fp-go/either"
O "github.com/IBM/fp-go/option"
RE "github.com/IBM/fp-go/readereither/generic"
)
func MakeReaderEither[A any](f func(context.Context) ET.Either[error, A]) ReaderEither[A] {

View File

@@ -1,8 +1,8 @@
package readereither
import (
RE "github.com/ibm/fp-go/readereither/generic"
T "github.com/ibm/fp-go/tuple"
RE "github.com/IBM/fp-go/readereither/generic"
T "github.com/IBM/fp-go/tuple"
)
// SequenceT converts n inputs of higher kinded types into a higher kinded types of n strongly typed values, represented as a tuple

View File

@@ -4,7 +4,7 @@ package readereither
import (
"context"
RE "github.com/ibm/fp-go/readereither"
RE "github.com/IBM/fp-go/readereither"
)
// ReaderEither is a specialization of the Reader monad for the typical golang scenario

View File

@@ -1,8 +1,8 @@
package readerio
import (
IO "github.com/ibm/fp-go/io"
R "github.com/ibm/fp-go/readerio/generic"
IO "github.com/IBM/fp-go/io"
R "github.com/IBM/fp-go/readerio/generic"
)
// TraverseArray transforms an array

View File

@@ -3,8 +3,8 @@ package readerio
import (
"context"
IO "github.com/ibm/fp-go/io"
R "github.com/ibm/fp-go/readerio/generic"
IO "github.com/IBM/fp-go/io"
R "github.com/IBM/fp-go/readerio/generic"
)
// these functions curry a golang function with the context as the firsr parameter into a either reader with the context as the last parameter

View File

@@ -3,7 +3,7 @@ package readerio
import (
"context"
R "github.com/ibm/fp-go/readerio/generic"
R "github.com/IBM/fp-go/readerio/generic"
)
func MonadMap[A, B any](fa ReaderIO[A], f func(A) B) ReaderIO[B] {

View File

@@ -6,9 +6,9 @@ import (
"strings"
"testing"
F "github.com/ibm/fp-go/function"
IO "github.com/ibm/fp-go/io"
T "github.com/ibm/fp-go/tuple"
F "github.com/IBM/fp-go/function"
IO "github.com/IBM/fp-go/io"
T "github.com/IBM/fp-go/tuple"
"github.com/stretchr/testify/assert"
)

View File

@@ -1,8 +1,8 @@
package readerio
import (
R "github.com/ibm/fp-go/readerio/generic"
T "github.com/ibm/fp-go/tuple"
R "github.com/IBM/fp-go/readerio/generic"
T "github.com/IBM/fp-go/tuple"
)
// SequenceT converts n inputs of higher kinded types into a higher kinded types of n strongly typed values, represented as a tuple

View File

@@ -4,7 +4,7 @@ package readerio
import (
"context"
R "github.com/ibm/fp-go/readerio"
R "github.com/IBM/fp-go/readerio"
)
// ReaderIO is a specialization of the ReaderIO monad assuming a golang context as the context of the monad

View File

@@ -1,7 +1,7 @@
package readerioeither
import (
G "github.com/ibm/fp-go/context/readerioeither/generic"
G "github.com/IBM/fp-go/context/readerioeither/generic"
)
// WithContext wraps an existing ReaderIOEither and performs a context check for cancellation before delegating

View File

@@ -1,3 +1,4 @@
// Package readerioeither contains a version of [ReaderIOEither] that takes a golang [context.Context] as its context
package readerioeither
//go:generate go run ../.. contextreaderioeither --count 10 --filename gen.go

View File

@@ -3,9 +3,9 @@ package readerioeither
import (
"context"
G "github.com/ibm/fp-go/context/readerioeither/generic"
ET "github.com/ibm/fp-go/either"
EQ "github.com/ibm/fp-go/eq"
G "github.com/IBM/fp-go/context/readerioeither/generic"
ET "github.com/IBM/fp-go/either"
EQ "github.com/IBM/fp-go/eq"
)
// Eq implements the equals predicate for values contained in the IOEither monad

View File

@@ -3,11 +3,11 @@ package exec
import (
"context"
RIOE "github.com/ibm/fp-go/context/readerioeither"
"github.com/ibm/fp-go/exec"
F "github.com/ibm/fp-go/function"
GE "github.com/ibm/fp-go/internal/exec"
IOE "github.com/ibm/fp-go/ioeither"
RIOE "github.com/IBM/fp-go/context/readerioeither"
"github.com/IBM/fp-go/exec"
F "github.com/IBM/fp-go/function"
GE "github.com/IBM/fp-go/internal/exec"
IOE "github.com/IBM/fp-go/ioeither"
)
var (

View File

@@ -5,11 +5,11 @@ import (
"io"
"os"
RIOE "github.com/ibm/fp-go/context/readerioeither"
ET "github.com/ibm/fp-go/either"
F "github.com/ibm/fp-go/function"
"github.com/ibm/fp-go/internal/file"
IOE "github.com/ibm/fp-go/ioeither"
RIOE "github.com/IBM/fp-go/context/readerioeither"
ET "github.com/IBM/fp-go/either"
F "github.com/IBM/fp-go/function"
"github.com/IBM/fp-go/internal/file"
IOE "github.com/IBM/fp-go/ioeither"
)
var (

View File

@@ -1,13 +1,13 @@
// Code generated by go generate; DO NOT EDIT.
// This file was generated by robots at
// 2023-07-18 15:21:14.8906482 +0200 CEST m=+0.127356001
package readerioeither
// Code generated by go generate; DO NOT EDIT.
// This file was generated by robots at
// 2023-07-19 16:18:34.1521763 +0200 CEST m=+0.011558001
import (
"context"
G "github.com/ibm/fp-go/context/readerioeither/generic"
G "github.com/IBM/fp-go/context/readerioeither/generic"
)
// Eitherize0 converts a function with 0 parameters returning a tuple into a function with 0 parameters returning a [ReaderIOEither[R]]

View File

@@ -3,9 +3,9 @@ package generic
import (
"context"
CIOE "github.com/ibm/fp-go/context/ioeither/generic"
E "github.com/ibm/fp-go/either"
IOE "github.com/ibm/fp-go/ioeither/generic"
CIOE "github.com/IBM/fp-go/context/ioeither/generic"
E "github.com/IBM/fp-go/either"
IOE "github.com/IBM/fp-go/ioeither/generic"
)
// withContext wraps an existing ReaderIOEither and performs a context check for cancellation before delegating

View File

@@ -3,13 +3,12 @@ package generic
import (
"context"
E "github.com/ibm/fp-go/either"
ET "github.com/ibm/fp-go/either"
EQ "github.com/ibm/fp-go/eq"
G "github.com/ibm/fp-go/readerioeither/generic"
E "github.com/IBM/fp-go/either"
EQ "github.com/IBM/fp-go/eq"
G "github.com/IBM/fp-go/readerioeither/generic"
)
// Eq implements the equals predicate for values contained in the IOEither monad
func Eq[GRA ~func(context.Context) GIOA, GIOA ~func() E.Either[error, A], A any](eq EQ.Eq[ET.Either[error, A]]) func(context.Context) EQ.Eq[GRA] {
func Eq[GRA ~func(context.Context) GIOA, GIOA ~func() E.Either[error, A], A any](eq EQ.Eq[E.Either[error, A]]) func(context.Context) EQ.Eq[GRA] {
return G.Eq[GRA](eq)
}

View File

@@ -1,14 +1,14 @@
// Code generated by go generate; DO NOT EDIT.
// This file was generated by robots at
// 2023-07-18 15:21:14.8906482 +0200 CEST m=+0.127356001
package generic
// Code generated by go generate; DO NOT EDIT.
// This file was generated by robots at
// 2023-07-19 16:18:34.1526819 +0200 CEST m=+0.012063601
import (
"context"
E "github.com/ibm/fp-go/either"
RE "github.com/ibm/fp-go/readerioeither/generic"
E "github.com/IBM/fp-go/either"
RE "github.com/IBM/fp-go/readerioeither/generic"
)
// Eitherize0 converts a function with 0 parameters returning a tuple into a function with 0 parameters returning a [GRA]

View File

@@ -4,13 +4,13 @@ import (
"context"
"time"
E "github.com/ibm/fp-go/either"
ER "github.com/ibm/fp-go/errors"
F "github.com/ibm/fp-go/function"
IO "github.com/ibm/fp-go/io/generic"
IOE "github.com/ibm/fp-go/ioeither/generic"
O "github.com/ibm/fp-go/option"
RIE "github.com/ibm/fp-go/readerioeither/generic"
E "github.com/IBM/fp-go/either"
ER "github.com/IBM/fp-go/errors"
F "github.com/IBM/fp-go/function"
IO "github.com/IBM/fp-go/io/generic"
IOE "github.com/IBM/fp-go/ioeither/generic"
O "github.com/IBM/fp-go/option"
RIE "github.com/IBM/fp-go/readerioeither/generic"
)
func FromEither[

View File

@@ -3,9 +3,9 @@ package generic
import (
"context"
E "github.com/ibm/fp-go/either"
F "github.com/ibm/fp-go/function"
RIE "github.com/ibm/fp-go/readerioeither/generic"
E "github.com/IBM/fp-go/either"
F "github.com/IBM/fp-go/function"
RIE "github.com/IBM/fp-go/readerioeither/generic"
)
// WithResource constructs a function that creates a resource, then operates on it and then releases the resource

View File

@@ -3,9 +3,9 @@ package generic
import (
"context"
E "github.com/ibm/fp-go/either"
RE "github.com/ibm/fp-go/readerioeither/generic"
T "github.com/ibm/fp-go/tuple"
E "github.com/IBM/fp-go/either"
RE "github.com/IBM/fp-go/readerioeither/generic"
T "github.com/IBM/fp-go/tuple"
)
// SequenceT converts n inputs of higher kinded types into a higher kinded types of n strongly typed values, represented as a tuple

View File

@@ -3,8 +3,8 @@ package generic
import (
"context"
E "github.com/ibm/fp-go/either"
RE "github.com/ibm/fp-go/readerioeither/generic"
E "github.com/IBM/fp-go/either"
RE "github.com/IBM/fp-go/readerioeither/generic"
)
// TraverseArray transforms an array

View File

@@ -4,14 +4,14 @@ import (
"io"
"net/http"
B "github.com/ibm/fp-go/bytes"
RIOE "github.com/ibm/fp-go/context/readerioeither"
F "github.com/ibm/fp-go/function"
H "github.com/ibm/fp-go/http"
IOE "github.com/ibm/fp-go/ioeither"
IOEF "github.com/ibm/fp-go/ioeither/file"
J "github.com/ibm/fp-go/json"
T "github.com/ibm/fp-go/tuple"
B "github.com/IBM/fp-go/bytes"
RIOE "github.com/IBM/fp-go/context/readerioeither"
F "github.com/IBM/fp-go/function"
H "github.com/IBM/fp-go/http"
IOE "github.com/IBM/fp-go/ioeither"
IOEF "github.com/IBM/fp-go/ioeither/file"
J "github.com/IBM/fp-go/json"
T "github.com/IBM/fp-go/tuple"
)
type (

View File

@@ -4,13 +4,13 @@ import (
"context"
"time"
R "github.com/ibm/fp-go/context/reader"
RIO "github.com/ibm/fp-go/context/readerio"
G "github.com/ibm/fp-go/context/readerioeither/generic"
ET "github.com/ibm/fp-go/either"
IO "github.com/ibm/fp-go/io"
IOE "github.com/ibm/fp-go/ioeither"
O "github.com/ibm/fp-go/option"
R "github.com/IBM/fp-go/context/reader"
RIO "github.com/IBM/fp-go/context/readerio"
G "github.com/IBM/fp-go/context/readerioeither/generic"
ET "github.com/IBM/fp-go/either"
IO "github.com/IBM/fp-go/io"
IOE "github.com/IBM/fp-go/ioeither"
O "github.com/IBM/fp-go/option"
)
func FromEither[A any](e ET.Either[error, A]) ReaderIOEither[A] {

View File

@@ -6,9 +6,9 @@ import (
"testing"
"time"
E "github.com/ibm/fp-go/either"
F "github.com/ibm/fp-go/function"
"github.com/ibm/fp-go/internal/utils"
E "github.com/IBM/fp-go/either"
F "github.com/IBM/fp-go/function"
"github.com/IBM/fp-go/internal/utils"
"github.com/stretchr/testify/assert"
)

View File

@@ -1,7 +1,7 @@
package readerioeither
import (
G "github.com/ibm/fp-go/context/readerioeither/generic"
G "github.com/IBM/fp-go/context/readerioeither/generic"
)
// WithResource constructs a function that creates a resource, then operates on it and then releases the resource

View File

@@ -1,8 +1,8 @@
package readerioeither
import (
G "github.com/ibm/fp-go/context/readerioeither/generic"
T "github.com/ibm/fp-go/tuple"
G "github.com/IBM/fp-go/context/readerioeither/generic"
T "github.com/IBM/fp-go/tuple"
)
// SequenceT converts n inputs of higher kinded types into a higher kinded types of n strongly typed values, represented as a tuple

View File

@@ -1,7 +1,7 @@
package readerioeither
import (
G "github.com/ibm/fp-go/context/readerioeither/generic"
G "github.com/IBM/fp-go/context/readerioeither/generic"
)
// TraverseArray transforms an array

View File

@@ -4,7 +4,7 @@ package readerioeither
import (
"context"
RE "github.com/ibm/fp-go/readerioeither"
RE "github.com/IBM/fp-go/readerioeither"
)
// ReaderIOEither is a specialization of the Reader monad for the typical golang scenario

View File

@@ -1,8 +1,8 @@
package either
import (
M "github.com/ibm/fp-go/monoid"
S "github.com/ibm/fp-go/semigroup"
M "github.com/IBM/fp-go/monoid"
S "github.com/IBM/fp-go/semigroup"
)
func ApplySemigroup[E, A any](s S.Semigroup[A]) S.Semigroup[Either[E, A]] {

View File

@@ -3,8 +3,8 @@ package either
import (
"testing"
M "github.com/ibm/fp-go/monoid/testing"
N "github.com/ibm/fp-go/number"
M "github.com/IBM/fp-go/monoid/testing"
N "github.com/IBM/fp-go/number"
"github.com/stretchr/testify/assert"
)

View File

@@ -1,7 +1,7 @@
package either
import (
F "github.com/ibm/fp-go/function"
F "github.com/IBM/fp-go/function"
)
// these function curry a golang function that returns an error into its curried version that returns an either

View File

@@ -5,9 +5,9 @@
package either
import (
E "github.com/ibm/fp-go/errors"
F "github.com/ibm/fp-go/function"
O "github.com/ibm/fp-go/option"
E "github.com/IBM/fp-go/errors"
F "github.com/IBM/fp-go/function"
O "github.com/IBM/fp-go/option"
)
// Of is equivalent to [Right]

View File

@@ -4,10 +4,10 @@ import (
"errors"
"testing"
F "github.com/ibm/fp-go/function"
"github.com/ibm/fp-go/internal/utils"
O "github.com/ibm/fp-go/option"
S "github.com/ibm/fp-go/string"
F "github.com/IBM/fp-go/function"
"github.com/IBM/fp-go/internal/utils"
O "github.com/IBM/fp-go/option"
S "github.com/IBM/fp-go/string"
"github.com/stretchr/testify/assert"
)

View File

@@ -1,8 +1,8 @@
package either
import (
EQ "github.com/ibm/fp-go/eq"
F "github.com/ibm/fp-go/function"
EQ "github.com/IBM/fp-go/eq"
F "github.com/IBM/fp-go/function"
)
// Constructs an equal predicate for an `Either`

View File

@@ -3,10 +3,10 @@ package exec
import (
"context"
E "github.com/ibm/fp-go/either"
"github.com/ibm/fp-go/exec"
F "github.com/ibm/fp-go/function"
GE "github.com/ibm/fp-go/internal/exec"
E "github.com/IBM/fp-go/either"
"github.com/IBM/fp-go/exec"
F "github.com/IBM/fp-go/function"
GE "github.com/IBM/fp-go/internal/exec"
)
var (

View File

@@ -1,12 +1,12 @@
// Code generated by go generate; DO NOT EDIT.
// This file was generated by robots at
// 2023-07-18 15:21:17.0339772 +0200 CEST m=+0.084638001
// 2023-07-19 16:18:36.5482933 +0200 CEST m=+0.013837701
package either
import (
A "github.com/ibm/fp-go/internal/apply"
T "github.com/ibm/fp-go/tuple"
A "github.com/IBM/fp-go/internal/apply"
T "github.com/IBM/fp-go/tuple"
)
// Eitherize0 converts a function with 0 parameters returning a tuple into a function with 0 parameters returning an Either

View File

@@ -4,7 +4,7 @@ import (
"bytes"
"net/http"
E "github.com/ibm/fp-go/either"
E "github.com/IBM/fp-go/either"
)
var (

View File

@@ -3,8 +3,8 @@ package either
import (
"log"
F "github.com/ibm/fp-go/function"
L "github.com/ibm/fp-go/logging"
F "github.com/IBM/fp-go/function"
L "github.com/IBM/fp-go/logging"
)
func _log[E, A any](left func(string, ...any), right func(string, ...any), prefix string) func(Either[E, A]) Either[E, A] {

View File

@@ -3,7 +3,7 @@ package either
import (
"testing"
F "github.com/ibm/fp-go/function"
F "github.com/IBM/fp-go/function"
"github.com/stretchr/testify/assert"
)

View File

@@ -1,8 +1,8 @@
package either
import (
F "github.com/ibm/fp-go/function"
RR "github.com/ibm/fp-go/internal/record"
F "github.com/IBM/fp-go/function"
RR "github.com/IBM/fp-go/internal/record"
)
// TraverseRecord transforms a record of options into an option of a record

View File

@@ -1,7 +1,7 @@
package either
import (
F "github.com/ibm/fp-go/function"
F "github.com/IBM/fp-go/function"
)
// constructs a function that creates a resource, then operates on it and then releases the resource

View File

@@ -4,7 +4,7 @@ import (
"os"
"testing"
F "github.com/ibm/fp-go/function"
F "github.com/IBM/fp-go/function"
"github.com/stretchr/testify/assert"
)

View File

@@ -3,9 +3,9 @@ package testing
import (
"testing"
ET "github.com/ibm/fp-go/either"
EQ "github.com/ibm/fp-go/eq"
L "github.com/ibm/fp-go/internal/monad/testing"
ET "github.com/IBM/fp-go/either"
EQ "github.com/IBM/fp-go/eq"
L "github.com/IBM/fp-go/internal/monad/testing"
)
// AssertLaws asserts the apply monad laws for the `Either` monad

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"testing"
EQ "github.com/ibm/fp-go/eq"
EQ "github.com/IBM/fp-go/eq"
"github.com/stretchr/testify/assert"
)

View File

@@ -1,7 +1,7 @@
package either
import (
F "github.com/ibm/fp-go/function"
F "github.com/IBM/fp-go/function"
)
/*

View File

@@ -3,8 +3,8 @@ package either
import (
"testing"
F "github.com/ibm/fp-go/function"
O "github.com/ibm/fp-go/option"
F "github.com/IBM/fp-go/function"
O "github.com/IBM/fp-go/option"
"github.com/stretchr/testify/assert"
)

View File

@@ -1,7 +1,7 @@
package eq
import (
F "github.com/ibm/fp-go/function"
F "github.com/IBM/fp-go/function"
)
type Eq[T any] interface {

View File

@@ -1,8 +1,8 @@
package eq
import (
M "github.com/ibm/fp-go/monoid"
S "github.com/ibm/fp-go/semigroup"
M "github.com/IBM/fp-go/monoid"
S "github.com/IBM/fp-go/semigroup"
)
func Semigroup[A any]() S.Semigroup[Eq[A]] {

View File

@@ -1,7 +1,7 @@
package testing
import (
EQ "github.com/ibm/fp-go/eq"
EQ "github.com/IBM/fp-go/eq"
"github.com/stretchr/testify/assert"
)

View File

@@ -3,7 +3,7 @@ package errors
import (
"errors"
O "github.com/ibm/fp-go/option"
O "github.com/IBM/fp-go/option"
)
// As tries to extract the error of desired type from the given error

View File

@@ -4,8 +4,8 @@ import (
"fmt"
"testing"
F "github.com/ibm/fp-go/function"
O "github.com/ibm/fp-go/option"
F "github.com/IBM/fp-go/function"
O "github.com/IBM/fp-go/option"
"github.com/stretchr/testify/assert"
)

View File

@@ -1,7 +1,7 @@
package errors
import (
F "github.com/ibm/fp-go/function"
F "github.com/IBM/fp-go/function"
)
var IdentityError = F.Identity[error]

View File

@@ -3,7 +3,7 @@ package errors
import (
"fmt"
A "github.com/ibm/fp-go/array"
A "github.com/IBM/fp-go/array"
)
// OnNone generates a nullary function that produces a formatted error

View File

@@ -1,7 +1,7 @@
package exec
import (
T "github.com/ibm/fp-go/tuple"
T "github.com/IBM/fp-go/tuple"
)
type (

View File

@@ -1,6 +1,6 @@
// Code generated by go generate; DO NOT EDIT.
// This file was generated by robots at
// 2023-07-18 15:21:26.5345454 +0200 CEST m=+0.141115301
// 2023-07-19 16:18:40.5224382 +0200 CEST m=+0.122863501
package function
// Combinations for a total of 1 arguments

Some files were not shown because too many files have changed in this diff Show More