Skip to content

Commit 1a404a1

Browse files
getting rid of Compat
1 parent f3d74c6 commit 1a404a1

5 files changed

Lines changed: 26 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ 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+
9+
## [2.0.3] - 2023-07-01
810
### Changed
9-
- Compat compat now includes version 4
11+
- got rid of Compat dependency
12+
1013
## [2.0.2] - 2021-07-17
1114
### Changed
1215
- reverting `Base.catch_backtrace()` to `Base.catch_stack()` everywhere. Apparently this is really only an issue on julia nightly and should not be changed in julia 1.6. Hence reverting everything.
@@ -18,7 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1821
## [2.0.0] - 2021-07-15
1922
### Added
2023
- `Base.get` and `Base.getindex` are now both implemented for `Const` (like they are implemented already for `Identity`), to simplify working with `Const`.
21-
- Vector conversions (`convert`) are now more generic and support AbstractArray in general
24+
- Vector conversions (`convert`) are now more generic and support AbstractArray in general
2225

2326
### Fixed
2427
- `Option(3)` works now

Project.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ uuid = "83eed652-29e8-11e9-12da-a7c29d64ffc9"
33
authors = ["Sahm Stephan <stephan.sahm@gmx.de>"]
44
version = "2.0.2"
55

6-
[deps]
7-
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
8-
96
[compat]
10-
Compat = "2.1, 3, 4"
117
julia = "1.6"
128

139
[extras]

README.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,31 @@
88
This package defines julia implementations for the common types `Option` (aka `Maybe`), `Either` and `Try`, as well as one extra type `ContextManager` which mimics Python's `with`-ContextManager.
99

1010

11-
## Installation
11+
## Usage
12+
13+
Here an example using `Try` to handle errors programmatically. Similar to `Option`, a `Try` is either a `Const`, denoting an error, or an `Identity`
14+
value, which denotes success.
1215

13-
The package is soon going to be registered at General, until then you can use it by adding a custom registry.
1416
```julia
15-
using Pkg
16-
pkg"add DataTypesBasic"
17+
using DataTypesBasic # defines Try
18+
19+
@Try div(1, 0) # Const(Thrown(DivideError()))
20+
@Try div(8, 3) # Identity(2)
1721
```
1822

19-
Use it like
23+
Using another helper package [`Monadic`](https://github.com/JuliaFunctional/Monadic.jl/tree/main). We can combine these
24+
into nice syntax.
2025
```julia
21-
using DataTypesBasic
26+
using Monadic # defines @monadic
27+
28+
# flatmap is also defined in TypeClasses.jl
29+
flatmap(f, x) = Iterators.flatten(map(f, x))
30+
tryit = @monadic map flatmap begin
31+
a = @Try div(8, 3)
32+
b = @Try isodd(a) ? 100 + a : error("fail")
33+
@pure a, b
34+
end
35+
# Const(Thrown(ErrorException("fail")))
2236
```
2337

2438
For more details check out the [documentation](https://JuliaFunctional.github.io/DataTypesBasic.jl/dev/).

docs/src/manual.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ myeither = either("error", 2 > 3, 42)
152152
fe(myeither) # "fallback behaviour 'error'"
153153
```
154154

155-
You also have support for `Iterators.flatten` in order to work "withing" Either, and combine everything correctly.
155+
You also have support for `Iterators.flatten` in order to work "within" Either, and combine everything correctly.
156156
```julia
157157
check_threshold(a) = a < 15 ? Const((a, "threshold not reached")) : Identity("checked threshold successfully")
158158

src/DataTypesBasic.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ export Identity, isidentity, Const,
3939
Try, @Try, @TryCatch, istry, issuccess, isfailure, Thrown, MultipleExceptions,
4040
ContextManager, @ContextManager
4141

42-
using Compat
43-
4442
# type definitions
4543
include("Identity.jl")
4644
include("Const.jl")

0 commit comments

Comments
 (0)