Git Product home page Git Product logo

Comments (8)

vlopezj avatar vlopezj commented on August 28, 2024
empty <|> a  == a <|> empty == a
(a <|> b) <|> c == a <|> (b <|> c)
empty <*> a == empty

Are there any other laws that every Alternative instance should follow?

from free.

ekmett avatar ekmett commented on August 28, 2024

Basically we need to choose between the equivalent of the left distribution and left catch laws from the old MonadPlus reform proposal

I'd say the distribution law is the one that matters, hence the use of [] above.

from free.

ekmett avatar ekmett commented on August 28, 2024

So we'd want

(a <|> b) <*> c = (a <*> c) <|> (b <*> c)

I think you can get the catch law from the abuse of lists there if you target an Alternative for runAlt that satisfies that law as well, but I haven't made that rigorous.

from free.

vlopezj avatar vlopezj commented on August 28, 2024

I just pushed a working prototype to a new branch. It's not very clean, with lots of currying, but I ran some tests and it seems to work fine.

Left catch might hold, but runAlt would not be an homomorphism anymore. There's an example using a ZipList alternative functor in the test file.

from free.

ekmett avatar ekmett commented on August 28, 2024

Hrmm, I wonder if we can accomplish this and still retain Twan's f a -> Alt f (a -> b) -> Alt f b backend somehow.

from free.

ekmett avatar ekmett commented on August 28, 2024

Merged 12a9c00. Thanks @vklj!

from free.

vlopezj avatar vlopezj commented on August 28, 2024

My pleasure :) . I'll close the issue then.

from free.

ekmett avatar ekmett commented on August 28, 2024

Shipped in free 4.6.

from free.

Related Issues (20)

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.