Hacker News new | past | comments | ask | show | jobs | submit login

There are a lot of things wrong with this, I'll just pick one.

Can you please explain more about what you think the relationship is between ADTs and monadic control of IO effects? The two are really not much related and there are languages like OCaml and F# which have ADTs but very limited use of monads - not for controlling access to IO. A monad need not be an ADT either. It really sounds like you know very little about Haskell and if you are going to criticize Scala for not getting the Haskell bits right then you really should understand it first.




I am not saying one is absolutely necessary for the other. I'm just saying that Haskell uses its types for very strict type safety as well as for the control of side effects. I am no Haskell expert, but I believe side effects in Haskell are expressed in a function's return type. So the relative complexity of the Haskell type system is hopefully offset by its advantages of having fewer "type" bugs as well as fewer side-effect bugs, as well as better, more "pure", testing. There are other ways to control side effects through effect systems, but Haskell uses its ADTs for that.


But it actually does not do so. The IO data type has a single value constructor: IO. Other monadic types do use ADTs - for example Either has both a Right and Left constructor - but ADTs are used extensively outside of any monadic type as well because the basic idea of composite types is actually very useful. So I cannot imagine how it is a bad thing that Scala has this useful feature, just because it does not also require an IO Monad? Does that mean ML is mistaken in its use of ADTs as well, even though it precedes Haskell?


ADTs are algebraic data types. They are quite simple, and have nothing to do with the IO type which haskell uses to constrain side effects. An ADT is just a type made up of ORs and ANDs:

    data Bool = False | True
    data Tree a = Leaf a | Branch (Tree a) (Tree a)




Consider applying for YC's W25 batch! Applications are open till Nov 12.

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

Search: