Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I wouldn't say that that's that surprising, when you remember that 'do' in Haskell is sort of analogous to defining and calling a function inline. If you keep that in mind, 'return ()' makes perfect sense.

Return does influence the control flow in the sense that it signals the end of the monad - it's just that Haskell allows you to define and call a monad ('function') inline, which is not idiomatic in most procedural languages.

It's not too far removed from the following Python code:

> (lambda x: 5)(5)

Which, naturally, returns '5'. Lisp, of course, treats lambdas similarly; however, writing a series of statements in Lisp (like progn) is not considered idiomatic/'good' Lisp, whereas writing monads in Haskell is absolutely necessary.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: