Skip to content

futuristic can break whenJust #23

Description

@tylerwx51

I just found an issue with emptyEs, more specifically with futuristic and how it interacts with the never event. After some trials and profiling this was the simplest program to cause the issue. The broken function just does nothing, it just waits forever. The working function prints "test" after e1 has fired.

import Control.FRPNow

broken :: IO ()
broken = runNowMaster $ do
    (e1, trigger1) <- callback
    sync $ trigger1 ()

    e2 <- sample $ futuristic $ return never
    e3 <- sample $ whenJust $ return Nothing `switch` fmap (pure . Just) e1 `switch` fmap (pure . Just) e2

    plan $ (sync $ print "test") <$ e3
    return never

working :: IO ()
working = runNowMaster $ do
    (e1, trigger1) <- callback
    sync $ trigger1 ()

    e2 <- sample $ return $ never
    e3 <- sample $ whenJust $ return Nothing `switch` fmap (pure . Just) e1 `switch` fmap (pure . Just) e2

    plan $ (sync $ print "test") <$ e3
    return never

The only difference in this code is in how e2 is produced, the broken one uses futuristic. This could cause programs to hang when emptyEs is used, particular when used with Control.FRPNow.Lib.first.

I'm currently using
Compiler: GHC 7.10.2
OS : Mac OS X 10.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions