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
neutralcan be used as genericneutralvalue. With this every Semigroup is automatically a Monoid.neutral(type)now defaults to returningneutralinstead of throwing a not-implemented-error.
pure(Writer, value)now initializes the accumulator toTypeClasses.neutralinstead ofOption(), making it strictly more general with regard toTypeClasses.combine.
reduce_monoid,foldl_monoidandfoldr_monoidcan 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)
Writerimplementsneutralandcombinenow, analog toPairandTupleWriterimplementspure, falling back toOption()as the generic neutral value. The user needs to wrap their accumulator into anOptionto make use of this default.- new method
getaccumulatoris exported to access the accumulator of anWriter. Access its value withBase.get. Dictionaries.AbstractDictionaryis supported, however only loaded if Dictionaries is available, so no extra dependency.AbstractVectortype-class instances now generalises the previousVectorinstances.Base.runis now defined forStateas an alias for just calling it- when running a
Stateyou 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_typesimplementation 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.Nothingnow implementsneutralandcombine, concretely,neutral(nothing) == nothingandnothing ⊕ nothing == nothing. This was added to supportcombineonOptionin general.
aphas a default implementation now, usingflatmapandmap. This is added because most user will be easily familiar withflatmapandmap, and can define those easily. Hence this fallback simplifies the usage massively. Also there is no method ambiguity threat, becauseapdispatches on both the function and monad argument with the concrete type, so everything is safe.- changed
orelsealias⊛to⊘for better visual separation, the latex name \oslash which fits semantically kind of, and because the original reasoning was an misunderstanding. TaskandFuturenow have anorelseimplementation which parallelizes runs and returns the first resultflatmapforIdentityis 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 aConstto anIdentitywhich was more a hack beforehand).neutralforIdentitynow always returnsConst(nothing).- updated TagBot
- updated CompatHelper
neutralfor Either now returnsConst, which is accordance to the Monoid laws.
orelseis 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
absorbingfunction. It was no where really used. To simplify maintenance we take it out for now. -
Removed
change_eltypefunctionDuring the development of this package we initially used a further function, quite related to
eltype, calledchange_eltype. It took a container type likeVectorand 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 ContainerContainerthe key functionapis defined forap(::Container{Function}, ::Container), this is a version of dispatching oneltypeand hence should be avoided.The resolution is that we assume
apis 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