-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
102 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Build Artifacts | ||
|
||
on: pull_request | ||
|
||
env: | ||
JAVA_OPTS: -Xms512m -Xmx1024m | ||
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.configureondemand=true -Dorg.gradle.jvmargs=-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8" | ||
|
||
jobs: | ||
build_artifacts: | ||
|
||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-java@v2 | ||
with: | ||
distribution: 'adopt' | ||
java-version: '11' | ||
|
||
- name: Build and test with Gradle | ||
run: ./gradlew build | ||
|
||
- name: Bundle build report | ||
if: failure() | ||
run: find . -type d -name 'reports' | zip -@ -r build-reports.zip | ||
|
||
- name: Upload build report | ||
if: failure() | ||
uses: actions/upload-artifact@master | ||
with: | ||
name: error-report | ||
path: build-reports.zip | ||
|
||
- name: Bundle analysis report | ||
run: mkdir sarif && find . -name '*.sarif' | xargs -I{} cp "{}" ./sarif/ | ||
|
||
- name: Upload analysis report | ||
uses: github/codeql-action/upload-sarif@v1 | ||
with: | ||
# Path to SARIF file relative to the root of the repository | ||
sarif_file: sarif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
@file:Suppress("unused") | ||
package io.arrow.example | ||
|
||
import arrow.optics.Every | ||
|
||
// WRONG | ||
// fun Order.containsSingleProductWrong() = | ||
// entries.all { entry -> entry.id == entries[0].id } | ||
|
||
// RIGHT | ||
fun Order.containsSingleProductRight() = | ||
if (entries.isEmpty()) false | ||
else entries.all { entry -> entry.id == entries[0].id } | ||
|
||
fun Order.addOneFreeNoOptics(): Order = | ||
Order(entries.map { it.copy(amount = it.amount + 1) }) | ||
|
||
fun Order.addOneFreeOptics(): Order { | ||
// an optic focuses on a set of elements | ||
// in this case we focus: | ||
// 1. on the 'entries' field | ||
// 2. on each element on the list | ||
// 3. on the 'amount' field | ||
// RESULT: we focus on each 'amount' field in each 'Entry' | ||
val optic = Order.entries compose Every.list() compose Entry.amount | ||
// now we can perform a single modification step | ||
return optic.modify(this) { it + 1 } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters