digitalmars.D - Maybe type in Fortress
- bearophile (4/4) Jan 18 2010 Just found this blog page. Fortress is a language quite different from D...
- Tim Matthews (16/27) Jan 18 2010 Haskell has the 'maybe' monad so not really innovative. Quite simply
- bearophile (5/12) Jan 18 2010 Cyclone is safer and it has some cute ideas, but I think it burdens the ...
- Steven E. Harris (7/8) Jan 19 2010 Yes, and in Scala, "maybe" is called Option=C2=B9, which is modeled to
- Andrei Alexandrescu (5/15) Jan 19 2010 BTW what prevents D from defining a NonNull type is disabling the
Just found this blog page. Fortress is a language quite different from D because it tries to be innovative (while D tries to be mostly a collection of well known good solutions) but it author Guy Steele is a good language designer, so some of the ideas of Fortress are nice. This post is about the Maybe type in Fortress and its consequences (you can guess it...? in Fortress things are notnull by default): http://projectfortress.sun.com/Projects/Community/blog/MaybeType Bye, bearophile
Jan 18 2010
On Mon, 18 Jan 2010 12:04:15 -0500 bearophile <bearophileHUGS lycos.com> wrote:Just found this blog page. Fortress is a language quite different from D because it tries to be innovative (while D tries to be mostly a collection of well known good solutions) but it author Guy Steele is a good language designer, so some of the ideas of Fortress are nice. This post is about the Maybe type in Fortress and its consequences (you can guess it...? in Fortress things are notnull by default): http://projectfortress.sun.com/Projects/Community/blog/MaybeType Bye, bearophileHaskell has the 'maybe' monad so not really innovative. Quite simply to those who don't know what this means: in haskell you don't have null. You have a 'maybe' monad that has 2 constructors 'just A' or 'nothing'. You then chain monad computations and the 'maybe' monad will stop on the first 'maybe' that is 'nothing'. 'nothing' is not a type but a constructor and haskell can match up types based on how they were constructed. The article points out "going beyond haskell" with maybe as a generator. I don't get this bit because in haskell all lists are monads and a single element list is just like the 'maybe' so this can be done already and empty lists can be pattern matched on if the extra assurance is desired. As the article points cyclone is good example of safer c. Maybe this could influence D or at least safed if it hasn't already.
Jan 18 2010
Tim Matthews:The article points out "going beyond haskell" with maybe as a generator. I don't get this bit because in haskell all lists are monads and a single element list is just like the 'maybe' so this can be done already and empty lists can be pattern matched on if the extra assurance is desired.I am not used to the idea of nullable values seen as collections of 0 or 1 items (Scala is doing the same, I think).As the article points cyclone is good example of safer c. Maybe this could influence D or at least safed if it hasn't already.Cyclone is safer and it has some cute ideas, but I think it burdens the programmers too much. Bye, bearophile
Jan 18 2010
Tim Matthews <tim.matthews7 gmail.com> writes:Haskell has the 'maybe' monad so not really innovative.Yes, and in Scala, "maybe" is called Option=C2=B9, which is modeled to participate in the expected monadic contracts. Footnotes:=20 =C2=B9 http://www.scala-lang.org/docu/files/api/scala/Option.html --=20 Steven E. Harris
Jan 19 2010
Steven E. Harris wrote:Tim Matthews <tim.matthews7 gmail.com> writes:BTW what prevents D from defining a NonNull type is disabling the default constructor. With the advent of disable, doing that becomes feasible, but it doesn't become trivial. AndreiHaskell has the 'maybe' monad so not really innovative.Yes, and in Scala, "maybe" is called Option¹, which is modeled to participate in the expected monadic contracts. Footnotes: ¹ http://www.scala-lang.org/docu/files/api/scala/Option.html
Jan 19 2010