News for hackers. Stuff that matters.
Re:8 months of OCaml after 8 years of Haskell in production ... by Tainnor on Wednesday December 04, 2024 @07:41AM (#42316873)
Other languages can't help you track that a function that transitively calls 100 other functions is side-effect free, Haskell can.

> UUID::fromWords(getRandom(), getRandom(), getRandom(), getRandom())

This ignores that getRandom() is a side-effecting function (it has to be because it returns something different every time). And that's not just a "local variable". UUID.fromWords val1 val2 val3 val4 works in Haskell too, the "extra syntax" is to be able to all that in IO (i.e. with side effects). If you want it in a form that is more recognisable, you could write it as

  getUuid :: IO UUID
  getUuid = do
    val1 <- getRandom
    val2 <- getRandom
    val3 <- getRandom
    val4 <- getRandom
    return UUID.fromWords val1 val2 val3 val4
but that's unnecessarily verbose if you know the idiom.

Your cache example is similarly side effecting.

There are no comments on this comment yet.