3 ms·
Okay, imagine you've got a list of securities and their underlyers. You've got a flat file that represents this information. You try to represent it as Securit
by moomin 4y ago
Okay, imagine you've got a list of securities and their underlyers. You've got a flat file that represents this information. You try to represent it as
Security
Underlying Security (Security)
Where that's the Security object, not the Security ID.
This works great for moeb, until the day that someone accidentally introduces a cycle. Instead you want a representation that looks like:
Security
Either CycleDetected a
You can call traverse to make that `Either CycleDetected Security a`.
Is that making any sense at all?
You rapidly realize that X knows Y and Y knows X.
- Y_Y 4y agoCan you detect cycles in general though? At first blush it feels like a halting problem.
- chowells 4y agoYou can't detect all possible cycles statically, but you can definitely detect them when they happen at runtime. When calculating a value, track its dynamic dependencies. If it ends up depending on itself, you have a cycle.
- gowld 4y agoCan you do that without losing all the fun of the magic one-liner with Haskell's inbuilt graph reduction? Otherwise, you may as well use Python ;-)
- moomin 4y agoYou gain all the fun of Fix, though.