-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Base-like APIs to TryExperimental (#13)
- Loading branch information
Showing
15 changed files
with
140 additions
and
49 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
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Takafumi Arakaki <[email protected]> and contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,10 @@ | ||
name = "TryExperimental" | ||
uuid = "ae3b139e-64da-4858-8f55-5617df0d650e" | ||
authors = ["Takafumi Arakaki <[email protected]> and contributors"] | ||
version = "0.1.0-DEV" | ||
|
||
[deps] | ||
Try = "bf1d0ff0-c4a9-496b-85f0-2b0d71c4f32a" | ||
|
||
[compat] | ||
julia = "1.6" |
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 @@ | ||
# TryExperimental |
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,52 @@ | ||
baremodule TryExperimental | ||
|
||
import Try | ||
|
||
module InternalPrelude | ||
include("prelude.jl") | ||
end # module InternalPrelude | ||
InternalPrelude.@reexport_try | ||
|
||
Try.@function convert | ||
# Try.@function promote | ||
|
||
# Collection interface | ||
Try.@function length | ||
Try.@function eltype | ||
|
||
Try.@function getindex | ||
Try.@function setindex! | ||
|
||
Try.@function first | ||
Try.@function last | ||
|
||
Try.@function push! | ||
Try.@function pushfirst! | ||
Try.@function pop! | ||
Try.@function popfirst! | ||
|
||
Try.@function put! | ||
Try.@function take! | ||
|
||
Try.@function push_nowait! | ||
Try.@function pushfirst_nowait! | ||
Try.@function pop_nowait! | ||
Try.@function popfirst_nowait! | ||
|
||
Try.@function put_nowait! | ||
Try.@function take_nowait! | ||
|
||
module Internal | ||
|
||
import ..TryExperimental | ||
const Try = TryExperimental | ||
using .Try | ||
using .Try: Causes | ||
|
||
using Base: IteratorEltype, HasEltype, IteratorSize, HasLength, HasShape | ||
|
||
include("base.jl") | ||
|
||
end # module Internal | ||
|
||
end # baremodule TryExperimental |
File renamed without changes.
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,21 @@ | ||
using Try | ||
|
||
macro reexport_try() | ||
exprs = [] | ||
|
||
mapfoldl(append!, names(Try; all = true); init = exprs) do name | ||
value = try | ||
getproperty(Try, name) | ||
catch err | ||
@error "Cannot access `Try.$name`" exception = (err, catch_backtrace()) | ||
return [] | ||
end | ||
(value isa Module && value !== Try.Causes) && return [] | ||
return [:(const $name = $Try.$name)] | ||
end | ||
|
||
public_names = filter(!=(:Try), names(Try)) | ||
export_expr = :(export $(public_names...)) | ||
|
||
return esc(Expr(:block, __source__, exprs..., export_expr)) | ||
end |
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,3 @@ | ||
[deps] | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
TestFunctionRunner = "792026f5-ac9a-4a19-adcb-47b0ce2deb5d" |
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,2 @@ | ||
using TestFunctionRunner | ||
TestFunctionRunner.@run |
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
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
using TestFunctionRunner | ||
TestFunctionRunner.@run | ||
TestFunctionRunner.@run(paths = ["../lib/TryExperimental"]) |