Ticket #15 (new defect)

Opened 6 years ago

Events don't hold monad laws

Reported by: camio Owned by:
Priority: major Milestone:
Version: Keywords:
Cc:

Description

m :: EventG X String
m = listToEvent [future 1 "m0"]

f,g :: String -> EventG X String
f = const $ listToEvent [ future 0 "f0"
                        , future 0 "f1"
                        ]
g = const $ listToEvent [ future 0 "g0"
                        , future 1 "g1"
                        ]

a = (m >>= f) >>= g
-- ((1,m0) >>= f) >>= g
-- [(1,f0), (1,f1)] >>= g
-- [(1,g0), (1,g1), (1,g0), (1,g1)]

b = m >>= (\x -> f x >>= g)
-- m >>= (\x -> f x >>= g)
-- m >>= ([(0,f0), (0,f1)] >>= g)
-- m >>= [(0,g0), (0,g0), (1,g1), (1,g1)]
-- [(1,g0), (1,g0), (1,g1), (1,g1)]

Beneath a and b is a calculation of the result in the semantic domain. This serves as a counter example of the assertion that joinE as defined in section 2.2.3 of the paper forms a monad with the rest of the things (list equality, fmap, etc.).

Note: See TracTickets for help on using tickets.