Giter Club home page Giter Club logo

cefal's Issues

Constraints vs static_assert

(This is not necessarily an issue).

The way that the various type classes are implemented all look basically like this:

template <typename T1, typename T2>
static std::optional<M> append(T1&& left, T2&& right) {
    static_assert(std::is_same_v<std::remove_cvref_t<T1>, std::optional<M>>, "Argument type should be the same as monoid");
    static_assert(std::is_same_v<std::remove_cvref_t<T2>, std::optional<M>>, "Argument type should be the same as monoid");

Is there a reason you chose unconstrained arguments with a static_assert, as opposed to an implementation strategy like:

template <DecaysTo<std::optional<M>> T1, DecaysTo<std::optional<M>> T2>
static std::optional<M> append(T1&& left, T2&& right) {
    // no static_asserts
}

The former might give you better diagnostics for direct invocations, the latter lets you "bubble up" the constraint to catch it earlier in the call stack.

Functor Definition

Hello,

this project is a very nice idea. Thank you for sharing.

I have read the readme file and was left wondering about your definition of functor. What is unit and which laws does it obey. Furthermore, I am asking myself how a type can satisfy functor+monoid. You mentioned this in the from optional conversion. I am asking, because the kind of functor is * -> * and that of monoid is *.

Kind regards

Konstantin

Ps, since you like functional programming. Try coroutines. You can implement some monadic bindings with it. However, a general monad seems to be not possible. At least I found no way to clone the state of a coroutine. This would be required to invoke the continuation more than one time as for the list monad for example.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.