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

Not the best place to mention this, but I never understood why, at least when talking with the functional oriented people, the union types are not explained as providing first level support for the Option, Either and the Try monads.


Well, I guess it depends on what you mean by "first level" support.

For example, the T|Null thing doesn't give you code composability of the type monad transformers do -- at least as far as I understand it[1]. (I'm sure there are other things, but that's the first thing that popped into my head.)

FTR, I am a typed-FP weenie, but I still find Ceylon quite interesting, though I haven't done anything non-trivial in it yet.

[1] I still haven't fully understood the (experimental) HKT support, so maybe that can accomodate this?


There are some places where monad composability would improve your code but in general, at least the way I see it, you can replace a scala for comprehension with a set of IF statements, each IF eliminating a wrong value (null, exception, etc). Not to mention that you can have as many options as you like (A|B|C|D|E), whereas the mentioned monads must be composed in order to capture the same thing.

But it's true I never built a big ceylon project, so I can't say I know how that works out in practice.


Yes, it's one good way to think about how they fit into the whole ecosystem of the language. Thanks.




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

Search: