All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Compat compat now includes version 4
- StructEquality is pushed to version 2.0
neutral
can be used as genericneutral
value. With this every Semigroup is automatically a Monoid.neutral(type)
now defaults to returningneutral
instead of throwing a not-implemented-error.
pure(Writer, value)
now initializes the accumulator toTypeClasses.neutral
instead ofOption()
, making it strictly more general with regard toTypeClasses.combine
.
reduce_monoid
,foldl_monoid
andfoldr_monoid
can now only be called asreduce_monoid(iterable; [init])
. The older variantreduce_monoid(combine_function, iterable; [init])
was a left over from previous thrown-away iterations.
- extensive documentation is ready
- re-exporting DataTypesBasic (Option, Try, Either, ContextManager)
Writer
implementsneutral
andcombine
now, analog toPair
andTuple
Writer
implementspure
, falling back toOption()
as the generic neutral value. The user needs to wrap their accumulator into anOption
to make use of this default.- new method
getaccumulator
is exported to access the accumulator of anWriter
. Access its value withBase.get
. Dictionaries.AbstractDictionary
is supported, however only loaded if Dictionaries is available, so no extra dependency.AbstractVector
type-class instances now generalises the previousVector
instances.Base.run
is now defined forState
as an alias for just calling it- when running a
State
you now do not need to provide an initial state, in that case it defaults tonothing
. ↠
operator is added, defined asa ↠ b = flatmap(_ -> b, a)
, and semantically kind of the reverse oforelse
.↠
,orelse
(⊘
),combine
(⊕
) have now multi-argument versions (i.e. they can take more than 2 arguments).- added
flip_types
implementation forDict
- for convenience,
Base.map(f, a, b, c...)
is defined as an alias forTypeClasses.mapn(f, a, b, c...)
for the data typesOption
,Try
,Either
,ContextManager
,Callable
,Writer
, andState
. Base.Nothing
now implementsneutral
andcombine
, concretely,neutral(nothing) == nothing
andnothing ⊕ nothing == nothing
. This was added to supportcombine
onOption
in general.
ap
has a default implementation now, usingflatmap
andmap
. This is added because most user will be easily familiar withflatmap
andmap
, and can define those easily. Hence this fallback simplifies the usage massively. Also there is no method ambiguity threat, becauseap
dispatches on both the function and monad argument with the concrete type, so everything is safe.- changed
orelse
alias⊛
to⊘
for better visual separation, the latex name \oslash which fits semantically kind of, and because the original reasoning was an misunderstanding. Task
andFuture
now have anorelse
implementation which parallelizes runs and returns the first resultflatmap
forIdentity
is now defined asflatmap(f, a::Identity) = f(a.value)
, i.e. there is no call toconvert(Identity, ...)
any longer, which makes composing Monads even simpler (Furthermore this gets rid of the need of converting aConst
to anIdentity
which was more a hack beforehand).neutral
forIdentity
now always returnsConst(nothing)
.- updated TagBot
- updated CompatHelper
neutral
for Either now returnsConst
, which is accordance to the Monoid laws.
orelse
is no longer forwarded to inner elements, as this function is usually defined on a container level.
- CI/CD pipeline
- Minimal Docs using Documenter
- Codecovering
- TagBot & CompatHelper
- License
- parts from the README went to the docs
-
Trait functions have been removed.
I.e. there is no longer isMonad or isApplicative. The reason is that there is ongoing work on inferring such traits automatically from whether a function is defined or not. As soon as such a generic util exists, the traits would not be needed anylonger. In addition we experienced ambiguities with isSemigroup and isMonoid, because for some examples, the trait affiliation would be defined by the eltype, but eltype is an instable characteristic and hence not recommended to use. We circumvent this problem for now by just not providing the traits.
-
Removed dependency on WhereTraits.jl.
This makes the package for more independent and easier to maintain. We loose some flexibility in multiple dispatch, and instead assume stronger constraints on how the functions should be used.
-
Removed
absorbing
function. It was no where really used. To simplify maintenance we take it out for now. -
Removed
change_eltype
functionDuring the development of this package we initially used a further function, quite related to
eltype
, calledchange_eltype
. It took a container type likeVector
and tried to change its ElementType, e.g.change_eltype(Vector{Int}, String) == Vector{String}
. While this may seem intuitively reasonable for example to defineisAp
, namely to check whether for some ContainerContainer
the key functionap
is defined forap(::Container{Function}, ::Container)
, this is a version of dispatching oneltype
and hence should be avoided.The resolution is that we assume
ap
is always overloaded with the first argument being of the general Container-type, i.e. without any restrictions to the eltype.
- Writer no longer checks whether the accumulator defines the Semigroup interface. This is because we dropped the traits function isSemigroup.
- TypeClasses: Functor, Applicative, Monads, Semigroup, Monoid and flip_types (traversable sequence)
- new DataTypes: Iterable, Callable, Writer, State
- TypeInstances: Iterable, Callable, Writer, State, Future, Task, Tuple, Pair, String, Vector, Dict
- TypeInstances for all of DataTypesBasic.jl: Const, Identity, Either, ContextManager