How to convert imperative side-effectful program to functional (in Ocaml)?
oessessnex @ oessessnex @programming.dev Posts 0Comments 47Joined 2 yr. ago
oessessnex @ oessessnex @programming.dev
Posts
0
Comments
47
Joined
2 yr. ago
Deleted
Permanently Deleted
The way you can think of it is that in OCaml everything is implicitly wrapped in an IO monad. In Haskell the IO monad is explicit, so if a function returns something in IO you know it can perform input and output, in OCaml there is no way to tell just from the types. That means that in Haskell the code naturally stratifies into a part that does input and output and a pure core. In OCaml you can do the same thing, however it needs to be a conscious design decision.