News for hackers. Stuff that matters.
Re:Fantasy World OCaml (2013) by Peaker on Sunday August 03, 2014 @03:28PM (#8128865)
Original code:

  if some_error_condition then
        None
      else (
        // everything else in the function is nested
      )
Why not use a Maybe/Either monad like:

  x <- some_maybe_value
  // everything else in the function isn't nested, and "x" is available (if some_maybe_value was Just)
Kind of like exceptions, but a bit more explicit.
Re:Fantasy World OCaml (2013) by rwmj on Sunday August 03, 2014 @04:47PM (#8129134)
I don't understand your example. I don't want to run the "// everything else" bit if the error condition was true.
Re:Fantasy World OCaml (2013) by Peaker on Monday August 04, 2014 @01:38AM (#8130503)
The error condition is represented by Nothing ("None" in OCaml?) and the rest of the code only runs if it was Just ("Some" in OCaml?).