Laws for Monad and MonadPlus.

2001-03-13 Thread Theodore Norvell

Hi all.  I was revising a short article I've written about
Monads in Haskell and started wondering about the identities
associated with Monads.

I think it is generally agreed (and in the report) that the
following identities should be true of a Monad:

Left identity:  return a >>= k   =   k a
Right identity:   p >>= return   =   p
Associativity:  (p >>= j) >= k   =   p >>= (\x->(j x >>= k))
[provided x is not free in j or k]

What about MonadPlus?  By analogy with semirings, I came up with:

Zero:mzero >>= k   =  mzero  =  p >>= (\x -> mzero)
Identity: p `mplus` mzero  =  p  =  mzero `mplus` p
Commutativity: p `mplus` q  =  q `mplus` p
Right distributivity: (p `mplus` q) >>= k  =  (p >>= k) `mplus` (q >>= k)
Left distributivity:  p >>= (\x->j x `mplus` k x)  =  (p >>= j) `mplus` (p >== k)
[provided x is not free in j or k]

But commutativity does not hold for Maybe or [], left distributivity
does not hold for Maybe and right distributivity does not hold for [],
so these can't be right.

Are the other identities I've listed ok?

Are there other identities that I've missed?

Cheers,
Theodore Norvell


Dr. Theodore Norvell[EMAIL PROTECTED]
Electrical and Computer Engineering http://www.engr.mun.ca/~theo
Engineering and Applied SciencePhone: (709) 737-8962
Memorial University of Newfoundland  Fax: (709) 737-4042
St. John's, NF, Canada, A1B 3X5

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: Haskell and the NGWS Runtime

2000-08-10 Thread Theodore Norvell

Thanks to Nigel for answering my question

Tyson Dowd wrote:
> > Microsoft indicates that C# will not support "genericity", through
> > even anything as crude as C++'s templates, so it is unlikely that
> > they will seek to support functional programming languages in the
> > short term.  Perhaps this limitation is part of the impetus for the
> > Mondrian variant.

That they are not supporting templates ala C++ can only be a good thing.
It leaves the door open for something closer to Haskell's or ML's
styles of genericity. This is certainly something that the functional
language community can contribute to the world of mainstream imperative
programming languages, and thence to the bulk of software development.
Yes, I know it's been done; for example pizza; but pizza is not a widely
adopted standard. If C# adopts parametric polymorphism and either type
classes or ML style modules, and C# becomes more than a
proprietary language, then it could make a contribution to getting
some of the ideas developed by the functional community into the
mainstream.

With Haskell# or Mondrian: Can I use C# to create an instance of
a Haskell class? Can I use Haskell to extend a C# abstract class?
I suspect the answer to both these questions is currently no.
If future versions of .NET and Haskell variants change that, it will
be very interesting.

Cheers,
Theodore Norvell


Dr. Theodore Norvell[EMAIL PROTECTED]
Electrical and Computer Engineering http://www.engr.mun.ca/~theo
Engineering and Applied SciencePhone: (709) 737-8962
Memorial University of Newfoundland  Fax: (709) 737-4042
St. John's, NF, Canada, A1B 3X5




Re: Haskell and the NGWS Runtime

2000-08-09 Thread Theodore Norvell


I've been following this discussion, but there are so many new buzzwords
coming out of microsoft that it's a bit confusing for those not
in the know.  Is there a quick way to summarize the relationships
between
.NET
NGWS
C# (which I've discovered is intended to be pronounces C-sharp
rather than C-hash)
the .NET virtual machine
COM
Why does the world need C# when it already has Java and C++?
Why does the world need a .NET virtual machine when it has
dozens of Java Virtual Machines?  Don't COM and Corba already
provide interlanguage and network interoperability? Why is it
important for Haskell to fit into .NET?

I hope this isn't too far off topic.

Cheers,
Theodore Norvell

----
Dr. Theodore Norvell[EMAIL PROTECTED]
Electrical and Computer Engineering http://www.engr.mun.ca/~theo
Engineering and Applied SciencePhone: (709) 737-8962
Memorial University of Newfoundland  Fax: (709) 737-4042
St. John's, NF, Canada, A1B 3X5