Skip to content

Is ParAff Actually Alternative? #183

@eric-corumdigital

Description

@eric-corumdigital

Distributivity: (f <|> g) <*> x = (f <*> x) <|> (g <*> x)

Let r ∷ Ref Int, f = delay 1.0, g = delay 2.0, x = modify (_ + 1) r

Then

  (delay 1.0 <|> delay 2.0) <*> modify (_ + 1) r
= (delay 1.0 <*> modify (_ + 1) r) <|> (delay 2.0 <*> modify (_ + 1) r)

But, by duplicating the Ref.modify (_ + 1) r effect and running both in parallel, r is incremented by 2 rather than 1.

(Yes, I fudged some types here for brevity).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions