purescript-signal
purescript-signal copied to clipboard
About reference transparency being broken and whether or not to modify this package.
First, every
function.
tmp = every 1000.0
main :: Effect Unit
main = launchAff_ do
Aff.delay $ Milliseconds 500.0
let
pulse = tmp
liftEffect $ runSignal $ pulse ~> logShow
outputs
75.52480700612068
1076.4696190059185
2078.1452220082283
3079.518830999732
4080.8751610070467
5081.603973001242
...
main :: Effect Unit
main = launchAff_ do
Aff.delay $ Milliseconds 500.0
let
pulse = every 1000.0
liftEffect $ runSignal $ pulse ~> logShow
outputs
578.351668998599
1580.3739890009165
2580.902148991823
3582.3207959979773
4583.194288998842
...
These behaviors are different, but what we have done is replace the bindings.
Next, merge
function
main :: Effect Unit
main = do
channel1 <- channel true
channel2 <- channel true
let
mergedSignal = merge (subscribe channel1) (subscribe channel2)
send channel2 false
logShow =<< get mergedSignal
output false
main :: Effect Unit
main = do
channel1 <- channel true
channel2 <- channel true
send channel2 false
let
mergedSignal = merge (subscribe channel1) (subscribe channel2)
logShow =<< get mergedSignal
outputs true
For the same reason, filters are not referentially transparent either.
I would like to modify these APIs, but in fact, this package references Elm's APIs, so it may not be a good idea to make direct changes. In other words, there are two options
- Modify the this Signal package
- Create a new, modified package
Do you have any suggestions on the pros and cons of modifying this package, or any other suggestions?