News for hackers. Stuff that matters.
Re:Löb and möb: strange loops in Haskell by moomin on Monday January 30, 2023 @09:38AM (#34580098)
I've been very excited about this myself before, but unfortunately, it's something of a stupid trick. The big problem is circular dependencies: they produce infinite loops and there's no particularly good way of detecting them. Regular old catamorphisms with `Either CycleDetected a` are probably a better idea in practice.
Re:Löb and möb: strange loops in Haskell by hacker_junky on Monday January 30, 2023 @09:59AM (#34580381)
Can you elaborate on what kind of circular dependencies are you referring to and how would catamorphisms with `Either CycleDetected a` help to reduce those dependencies?
Re:Löb and möb: strange loops in Haskell by moomin on Monday January 30, 2023 @10:08AM (#34580535)
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.

Re:Löb and möb: strange loops in Haskell by Y_Y on Monday January 30, 2023 @02:01PM (#34584736)
Can you detect cycles in general though? At first blush it feels like a halting problem.
Re:Löb and möb: strange loops in Haskell by chowells on Monday January 30, 2023 @02:32PM (#34585161)
You 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.
Re:Löb and möb: strange loops in Haskell by gowld on Wednesday February 01, 2023 @05:54PM (#34619239)
Can 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 ;-)
Re:Löb and möb: strange loops in Haskell by moomin on Thursday February 02, 2023 @05:02PM (#34633825)
You gain all the fun of Fix, though.