ciren / cilib

Typesafe, purely functional Computational Intelligence
https://cilib.net
Apache License 2.0
124 stars 101 forks source link

Limit sinks to Measurement[A] values #281

Closed gpampara closed 6 years ago

gpampara commented 6 years ago

A bug was found by @stefanvds with the use of a sink in the runner process pipeline. When setting up a pipeline (without using a measure function), compilation would cause the compiler to try create a derivation that never completed. I'm actually surprised that the compiler didn't crash, although I suspect letting the compiler continue, without intervention, would eventually result in a crash. The specific case highlighted by @stefanvds had the compiler running for over 20 minutes.

Limiting all sinks to instead only accept Measurement[A] values corrects the derivation problem. In retrospect, it makes sense to only allow Measurement[A] values to be serialized through the sinks.

Naturally, this does not prevent alternate usage, but to use the sinks defined in the io module, a measurement needs to be done to allow the compilation to succeed now, not doing so results in a compiler error (as it should be).