www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Maybe type in Fortress

reply bearophile <bearophileHUGS lycos.com> writes:
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
parent reply Tim Matthews <tim.matthews7 gmail.com> writes:
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,
 bearophile
Haskell 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
next sibling parent bearophile <bearophileHUGS lycos.com> writes:
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
prev sibling parent reply "Steven E. Harris" <seh panix.com> writes:
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
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Steven E. Harris wrote:
 Tim Matthews <tim.matthews7 gmail.com> writes:
 
 Haskell 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
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. Andrei
Jan 19 2010