Skip to content

Commit 25ac5a4

Browse files
committed
Initial commit
0 parents  commit 25ac5a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+16531
-0
lines changed

.github/workflows/test.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: CI
2+
3+
# Controls when the action will run. Triggers the workflow on push or pull request
4+
# events but only for the master branch
5+
on: [push, pull_request]
6+
7+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
8+
jobs:
9+
test:
10+
# The type of runner that the job will run on
11+
runs-on: ubuntu-latest
12+
13+
# Steps represent a sequence of tasks that will be executed as part of the job
14+
steps:
15+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
16+
- uses: actions/checkout@v3
17+
18+
- name: Setup Node.js environment
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: lts/*
22+
23+
# Re-use node_modules between runs until package-lock.json changes.
24+
- name: Cache node_modules
25+
id: internal-cache-node_modules
26+
uses: actions/cache@v3
27+
with:
28+
path: node_modules
29+
key: internal-node_modules-ubuntu-latest.x-${{ hashFiles('package-lock.json') }}
30+
31+
# Re-use ~/.elm between runs until elm.json, elm-tooling.json or
32+
# review/elm.json changes. The Elm compiler saves downloaded Elm packages
33+
# to ~/.elm, and elm-tooling saves downloaded tool executables there.
34+
- name: Cache ~/.elm
35+
uses: actions/cache@v3
36+
with:
37+
path: ~/.elm
38+
key: elm-${{ hashFiles('elm.json', 'review/elm.json') }}
39+
40+
- name: Install npm dependencies
41+
if: steps.cache-node_modules.outputs.cache-hit != 'true'
42+
43+
run: npm ci
44+
45+
- name: Run tests
46+
run: npm test
47+
48+
publish:
49+
if: github.ref == 'refs/heads/master' # run only on master
50+
needs: [test] # make sure all your other jobs succeed before trying to publish
51+
52+
# The type of runner that the job will run on
53+
runs-on: ubuntu-latest
54+
55+
# Steps represent a sequence of tasks that will be executed as part of the job
56+
steps:
57+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
58+
- uses: actions/checkout@v3
59+
60+
- name: Setup Node.js environment
61+
uses: actions/setup-node@v3
62+
with:
63+
node-version: lts/*
64+
65+
# Re-use node_modules between runs until package-lock.json changes.
66+
- name: Cache node_modules
67+
id: internal-cache-node_modules
68+
uses: actions/cache@v3
69+
with:
70+
path: node_modules
71+
key: internal-node_modules-ubuntu-latest.x-${{ hashFiles('package-lock.json') }}
72+
73+
# Re-use ~/.elm between runs until elm.json or
74+
# review/elm.json changes. The Elm compiler saves downloaded Elm packages
75+
# to ~/.elm, and elm-tooling saves downloaded tool executables there.
76+
- name: Cache ~/.elm
77+
uses: actions/cache@v3
78+
with:
79+
path: ~/.elm
80+
key: elm-${{ hashFiles('elm.json', 'review/elm.json') }}
81+
82+
- name: Install npm dependencies
83+
if: steps.cache-node_modules.outputs.cache-hit != 'true'
84+
env:
85+
# If you have a `"postinstall": "elm-tooling install"` script in your
86+
# package.json, this turns it into a no-op. We’ll run it in the next
87+
# step because of the caching. If elm-tooling.json changes but
88+
# package-lock.json does not, the postinstall script needs running
89+
# but this step won’t.
90+
NO_ELM_TOOLING_INSTALL: 1
91+
run: npm ci
92+
93+
94+
95+
# Runs a single command using the runners shell
96+
- name: Elm Publish
97+
uses: dillonkearns/elm-publish-action@v1
98+
with:
99+
# Token provided by GitHub
100+
github-token: ${{ secrets.GITHUB_TOKEN }}
101+
path-to-elm: ./node_modules/.bin/elm

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
elm-stuff/
2+
node_modules
3+
tests/VerifyExamples
4+
.DS_Store

LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2023, Jakub Hampl
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
- Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
- Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
- Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# core-extra
2+
3+
This is a large collection of utility-style functions pertaining to the Elm standard library (core).

benchmarks/chromium.pdf

179 KB
Binary file not shown.

benchmarks/elm.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"type": "application",
3+
"source-directories": [
4+
"src",
5+
"../src"
6+
],
7+
"elm-version": "0.19.1",
8+
"dependencies": {
9+
"direct": {
10+
"elm/browser": "1.0.2",
11+
"elm/core": "1.0.5",
12+
"elm/html": "1.0.0",
13+
"elm-explorations/benchmark": "1.0.2",
14+
"lue-bird/elm-alternative-benchmark-runner": "1.0.0"
15+
},
16+
"indirect": {
17+
"BrianHicks/elm-trend": "2.1.3",
18+
"avh4/elm-color": "1.0.0",
19+
"elm/json": "1.1.3",
20+
"elm/regex": "1.0.0",
21+
"elm/time": "1.0.0",
22+
"elm/url": "1.0.0",
23+
"elm/virtual-dom": "1.0.3",
24+
"mdgriffith/elm-ui": "1.1.8",
25+
"mdgriffith/style-elements": "5.0.2",
26+
"miniBill/elm-ui-with-context": "1.1.0",
27+
"robinheghan/murmur3": "1.0.0"
28+
}
29+
},
30+
"test-dependencies": {
31+
"direct": {
32+
"elm-explorations/test": "1.2.2"
33+
},
34+
"indirect": {
35+
"elm/random": "1.0.0"
36+
}
37+
}
38+
}

benchmarks/firefox.pdf

78.1 KB
Binary file not shown.

benchmarks/src/Application/NegAbs.elm

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module Application.NegAbs exposing (composeR, declarationArgumentPipeline, lambdaPipeComposeR, lambdaPipeline)
2+
3+
4+
declarationArgumentPipeline : number -> number
5+
declarationArgumentPipeline n =
6+
n |> abs |> negate
7+
8+
9+
lambdaPipeComposeR : number -> number
10+
lambdaPipeComposeR =
11+
\n -> n |> abs >> negate
12+
13+
14+
lambdaPipeline : number -> number
15+
lambdaPipeline =
16+
\n -> n |> abs |> negate
17+
18+
19+
composeR : number -> number
20+
composeR =
21+
abs >> negate

benchmarks/src/Application/Sum.elm

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module Application.Sum exposing (lambdaFullyAppliedCurried, lambdaNestedFullyAppliedCurried, nameOnlyCurried, partiallyCurried, pipe)
2+
3+
import Array exposing (Array)
4+
5+
6+
nameOnlyCurried : Array number -> number
7+
nameOnlyCurried =
8+
\array ->
9+
array |> Array.foldl (+) 0
10+
11+
12+
partiallyCurried : Array number -> number
13+
partiallyCurried =
14+
\array ->
15+
array |> Array.foldl (\element -> (+) element) 0
16+
17+
18+
pipe : Array number -> number
19+
pipe =
20+
\array ->
21+
array |> Array.foldl (\element soFar -> soFar |> (+) element) 0
22+
23+
24+
lambdaFullyAppliedCurried : Array number -> number
25+
lambdaFullyAppliedCurried =
26+
\array ->
27+
array |> Array.foldl (\element soFar -> soFar + element) 0
28+
29+
30+
lambdaNestedFullyAppliedCurried : Array number -> number
31+
lambdaNestedFullyAppliedCurried =
32+
\array ->
33+
array |> Array.foldl (\element -> \soFar -> soFar + element) 0

benchmarks/src/Array/Extra/All.elm

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
module Array.Extra.All exposing (recursiveGet, recursiveLast, withFold, withListAll)
2+
3+
import Array exposing (Array)
4+
import Array.Extra
5+
6+
7+
recursiveLast : (a -> Bool) -> Array a -> Bool
8+
recursiveLast isOkay =
9+
\array ->
10+
case array |> Array.get ((array |> Array.length) - 1) of
11+
Nothing ->
12+
True
13+
14+
Just last ->
15+
if isOkay last then
16+
recursiveLast isOkay (Array.Extra.pop array)
17+
18+
else
19+
False
20+
21+
22+
withListAll : (a -> Bool) -> Array a -> Bool
23+
withListAll isOkay =
24+
\array ->
25+
array
26+
|> Array.toList
27+
|> List.all isOkay
28+
29+
30+
withFold : (a -> Bool) -> Array a -> Bool
31+
withFold isOkay =
32+
\array ->
33+
array
34+
|> Array.foldl
35+
(\element soFar -> soFar && (element |> isOkay))
36+
True
37+
38+
39+
recursiveGet : (a -> Bool) -> Array a -> Bool
40+
recursiveGet isOkay array =
41+
recursiveGetFromIndex 0 isOkay array
42+
43+
44+
recursiveGetFromIndex : Int -> (a -> Bool) -> Array a -> Bool
45+
recursiveGetFromIndex index isOkay array =
46+
case Array.get index array |> Maybe.map isOkay of
47+
Just False ->
48+
False
49+
50+
Just True ->
51+
recursiveGetFromIndex (index + 1) isOkay array
52+
53+
Nothing ->
54+
True

0 commit comments

Comments
 (0)