Skip to content

Commit 20a3cbe

Browse files
state in progress
1 parent 2fed970 commit 20a3cbe

7 files changed

Lines changed: 769 additions & 28 deletions

File tree

.github/workflows/CompatHelper.yml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,43 @@ on:
33
schedule:
44
- cron: 0 0 * * *
55
workflow_dispatch:
6+
permissions:
7+
contents: write
8+
pull-requests: write
69
jobs:
710
CompatHelper:
811
runs-on: ubuntu-latest
912
steps:
10-
- name: Pkg.add("CompatHelper")
11-
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
12-
- name: CompatHelper.main()
13+
- name: Check if Julia is already available in the PATH
14+
id: julia_in_path
15+
run: which julia
16+
continue-on-error: true
17+
- name: Install Julia, but only if it is not already available in the PATH
18+
uses: julia-actions/setup-julia@v1
19+
with:
20+
version: '1'
21+
# arch: ${{ runner.arch }}
22+
if: steps.julia_in_path.outcome != 'success'
23+
- name: "Add the General registry via Git"
24+
run: |
25+
import Pkg
26+
ENV["JULIA_PKG_SERVER"] = ""
27+
Pkg.Registry.add("General")
28+
shell: julia --color=yes {0}
29+
- name: "Install CompatHelper"
30+
run: |
31+
import Pkg
32+
name = "CompatHelper"
33+
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
34+
version = "3"
35+
Pkg.add(; name, uuid, version)
36+
shell: julia --color=yes {0}
37+
- name: "Run CompatHelper"
38+
run: |
39+
import CompatHelper
40+
CompatHelper.main()
41+
shell: julia --color=yes {0}
1342
env:
1443
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1544
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
16-
run: julia -e 'using CompatHelper; CompatHelper.main()'
45+
# COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Changed
9+
- Compat compat now includes version 4
810

911
## [1.1.1] - 2021-07-27
1012
### Added

Project.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@ Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
1010
ExprParsers = "c5caad1f-83bd-4ce8-ac8e-4b29921e994e"
1111
Monadic = "4a6f0533-cc52-4fcf-a409-c6c05775ac80"
1212
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
13+
SimpleMatch = "a3ae8450-d22f-11e9-3fe0-77240e25996f"
1314
TypeClasses = "addcc920-e0cf-11e8-30b7-0fb08706b574"
1415

1516
[compat]
16-
Compat = "2.1, 3"
17+
Compat = "2.1, 3, 4"
1718
DataTypesBasic = "1.0, 2"
1819
ExprParsers = "1"
19-
julia = "1.6"
2020
Monadic = "1"
21-
Reexport = "1"
21+
Reexport = "0.2, 1"
2222
TypeClasses = "1.1"
23+
julia = "1.6"
2324

2425
[extras]
2526
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

src/core.jl

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ is handled independently on its own
2222
struct Eff{Effectful, Fs}
2323
effectful::Effectful
2424
cont::Continuation{Fs}
25+
end
26+
27+
function Eff(effectful::E, cont::Continuation{Tuple{}}) where E<:NoEffect
28+
# also run this if isempty(cont) to stop infinite recursion
29+
# (which happens otherwise because empty cont results returns noeffect for convenience)
30+
Eff{E, Tuple{}}(effectful, cont)
31+
end
2532

26-
function Eff(effectful::T, cont::Continuation{Fs}) where {T, Fs}
27-
if !isempty(cont) && effectful isa NoEffect
28-
# Evaluate NoEffect directly to make sure, we don't have a chain of NoEffect function accumulating
29-
# e.g. with ContextManager this could lead to things not being evaluated, while the syntax suggest
30-
# everything is evaluated, and hence the ContextManager may finalize resource despite they are still used.
31-
cont(effectful.value)
32-
33-
else
34-
# also run this if isempty(cont) to stop infinite recursion
35-
# (which happens otherwise because empty cont results returns noeffect for convenience)
36-
new{T, Fs}(effectful, cont)
37-
end
38-
end
33+
function Eff(effectful::NoEffect, cont::Continuation{Fs}) where Fs
34+
# Evaluate NoEffect directly to make sure, we don't have a chain of NoEffect function accumulating
35+
# e.g. with ContextManager this could lead to things not being evaluated, while the syntax suggest
36+
# everything is evaluated, and hence the ContextManager may finalize resource despite they are still used.
37+
cont(effectful.value)
3938
end
39+
4040
Eff(effectful) = Eff(effectful, Continuation())
4141

4242
function Base.show(io::IO, eff::Eff)
@@ -60,16 +60,17 @@ effect(eff::Eff) = eff # if we find a Eff effect, we just directly use it
6060
# Functionalities for Continuation
6161
# --------------------------------
6262

63+
function (c::Continuation{Tuple{}})(value)
64+
# mapping empty continuation is the same as wrapping into noeffect
65+
noeffect(value)
66+
end
6367
function (c::Continuation)(value)
64-
if isempty(c)
65-
noeffect(value)
66-
else
67-
first_func = c.functions[1]
68-
rest = c.functions[2:end]
69-
eff = first_func(value)
70-
Eff(eff.effectful, Continuation(eff.cont.functions..., rest...))
71-
end
68+
first_func = Base.first(c.functions)
69+
rest = Base.tail(c.functions)
70+
eff = first_func(value)
71+
Eff(eff.effectful, Continuation(eff.cont.functions..., rest...))
7272
end
73+
7374
Base.isempty(c::Continuation) = Base.isempty(c.functions)
7475
Base.map(f, c::Continuation) = Continuation(c.functions..., noeffect f)
7576

test/Project.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[deps]
2+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
3+
DataTypesBasic = "83eed652-29e8-11e9-12da-a7c29d64ffc9"
4+
ExtensibleEffects = "67377c25-f533-4d0b-9328-1721380cc1f1"
5+
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
6+
TypeClasses = "addcc920-e0cf-11e8-30b7-0fb08706b574"
7+
TypeClasses2 = "addcc920-e0cf-11e8-30b7-0fb08706b575"

0 commit comments

Comments
 (0)