Re:Functional Programming in OCaml
by fiddlerwoaroof on Saturday March 02, 2019 @09:01PM
(#19292290)
I believe OCaml isn’t as strict about side-effects as Haskell, so if you don’t want the side-effect ceremony Haskell sort of forces on you, OCaml might be a good choice. Also, OCaml is strict by default and had a fairly good compiler.
[ Parent
| on HN ]
> I believe OCaml isn’t as strict about side-effects as Haskell, so if you don’t want the side-effect ceremony Haskell sort of forces on you, OCaml might be a good choice. Also, OCaml is strict by default and had a fairly good compiler.
Probably anyone who's interested here knows, but it may be appropriate to point out that you are using the word 'strict' in two different senses, first in the informal sense of being restrictive, and second in the formal sense of strict evaluation (which is why it makes sense to say that OCaml is less strict, and yet strict by default).
Re:Functional Programming in OCaml
by fiddlerwoaroof on Sunday March 03, 2019 @12:09PM
(#19295474)
Yeah, I didn't even think about that when I wrote the comment, but it occurred to me later that that might be confusing.
Is there any convention for denoting which functions in OCaml have side effects?
Not really, but the documentation will usually tell you. Also, at least in Jane Street’a libraries, exceptionful functions always end in _exn. So for example there is List.find and List.find_exn
Some people append `_exn` to names of functions which can raise exceptions; that's about it.
Re:Functional Programming in OCaml
by craigsmansion on Sunday March 03, 2019 @04:46AM
(#19293644)
I don't think it's a strict convention, but it's common to see (a block of) imperative statements with side effects enclosed in:
begin ... end
It's ugly and stands out in its awkwardness, almost as if by design, with the compiler saying: "I will let you do this, but do think about it some more and try and come up with something more elegant."
Re:Functional Programming in OCaml
by fiddlerwoaroof on Saturday March 02, 2019 @10:33PM
(#19292541)
I don't know, I don't write it very much.