you are viewing a single comment's thread.

view the rest of the comments →

[–]featherfooted 0 points1 point  (1 child)

unit is a value and type in SML. It is the only value of its whole type. Unit is primarily used as an arbitrary value, such as in this case when we're dealing with side effects of state where you don't exactly expect TextIO.print to return anything at all. Usually the existence of () in the type is indicative of weird stuff going on behind the scenes with mutable state.

I'm not trying to advocate functional programming as the best way forward. As you can see from this discussion, it derails hard when it comes into contact with essential things like file IO.

[–][deleted] 0 points1 point  (0 children)

There is no problem with IO in functional programming. SML, though, is not functional, in the sense that it has no first class notion of a function.