Skip to content

Weird casuality loop detection #516

@bglgwyng

Description

@bglgwyng

Here I made a reproducible.
https://github.com/bglgwyng/reflex-casuality-loop-report

The network description reads as follows.
You don't need to understand the following code. This is the result of the removal of domain-specific code from my project.

app = do
  eTick <- tickLossyFromPostBuildTime 0.1

  -- `mergeMapIncremental` cause the casuality loop
  e1 <- mergeMapIncremental <$> holdIncremental @_ @_ @(PatchMap Int (Event t ())) mempty never
  d1 <- holdDyn mempty e1

  dGate <- toggle False (eTick $> True)

  e2 <- mergeMapIncremental <$> holdIncremental @_ @_ @(PatchMap Int (Event t ())) mempty (eTick $> mempty)
  d2 <- holdDyn mempty e2

  let d3 = do
        d1
        gate <- dGate
        when gate (d2 $> ()) -- d2 is optionally evaluated by dGate
  performEvent_ $ updated d3 $> pure () -- subscribe `updated d3`
  pure never

I don't think there is any causality loop. The usage of mergeMapIncremental and toggling of evaluation of d2 in Dynamic monad is crucial to reproduce the causality loop.

Does anyone have an idea why this code is reported to include a loop?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions