Re: [Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-22 Thread Keean Schupke
Ashley Yakeley wrote:
In article [EMAIL PROTECTED],
S. Alexander Jacobson [EMAIL PROTECTED] wrote:
 

I assume there is a standard name for this 
class/function:

  instance Foo [] where
foo [] = mzero
foo (x:_) = return x
  instance Foo (Maybe x) where
foo Nothing = mzero
foo Just x = return x
   

Surely they are incomplete monad definitions (has a return but no bind)...
I don't believe so. I had to write my own classes to do this sort of 
thing.

This is also a good opporunity to point out an ambiguity in the standard 
MonadPlus class. All instances satisfy these:

 mplus mzero a = a
 mplus a mzero = a
But only some instances (such as []) satisfy this:
 (mplus a b) = c = mplus (a = c) (b = c)
Other instances (IO, Maybe) satisfy this:
 mplus (return a) b = return a
I think mplus should be separated into two functions. This code shows 
the difference a bit more clearly:

 do
   b - mplus (return True) (return False)
   if b then mzero else return ()
For the first kind this is the same as return (), for the second kind 
it's the same as mzero.
 

But isnt the point of Monad plus, that to have a 'zero' implies failure 
(a normal
monad cannot fail) - and failure implies choice (a `mplus` b) is a if a 
succeeds or
b if a fails and b succeeds,or mzero if both fail. if you look at your 
first identity:

   mplus mzero a = a
   mplus a mzero = a
This fits the above description, but I don't see how the following can 
be true:

   (mplus a b) = c = mplus (a = c) (b = c)
The LHS says (if a fails run b)  then run c.
The RHS says if (a then c) fails  run (b then c)
Finally,
mplus (return a) b = return a
Is obvious because return a is not  mzero, so it is true for all 
Monads that can fail. 

Or have I missed the point?
   Keean.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-22 Thread Ashley Yakeley
In article [EMAIL PROTECTED],
 Keean Schupke [EMAIL PROTECTED] wrote:

 This fits the above description, but I don't see how the following can 
 be true:
 
 (mplus a b) = c = mplus (a = c) (b = c)

Try it (and my test code) with [], which is an instance of MonadPlus. 
mplus is defined as (++) for [].

-- 
Ashley Yakeley, Seattle WA

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Hugs for Zaurus

2005-01-22 Thread Rainer Volz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Wow, hugs on my Z. Many thanks for that!

- -- 
Rainer Volz
Virtuelle Projekte -- www.vrtprj.de
Virtual Projects   -- www.vrtprj.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 http://mailcrypt.sourceforge.net/

iD8DBQFB8mOgenjtlV2FwvQRAotuAJ0bY/RkqPiiW9N8pTz70J26yjXblACguSQ7
Kx5ExTM25TaGB1h7qi74JoM=
=qsCT
-END PGP SIGNATURE-

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-22 Thread Keean Schupke
Ashley Yakeley wrote:
In article [EMAIL PROTECTED],
Keean Schupke [EMAIL PROTECTED] wrote:
 

This fits the above description, but I don't see how the following can 
be true:

   (mplus a b) = c = mplus (a = c) (b = c)
   

Try it (and my test code) with [], which is an instance of MonadPlus. 
mplus is defined as (++) for [].

 

but what if (a = c) causes c to fail, and (b = c) lets c succeed. In 
this
case the LHS will fail, whereas the RHS will succeed I think?

   Keean.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-22 Thread Daniel Fischer
Am Samstag, 22. Januar 2005 21:20 schrieb Keean Schupke:
 Ashley Yakeley wrote:
 In article [EMAIL PROTECTED],
 
  Keean Schupke [EMAIL PROTECTED] wrote:
 This fits the above description, but I don't see how the following can
 be true:
 
 (mplus a b) = c = mplus (a = c) (b = c)
 
 Try it (and my test code) with [], which is an instance of MonadPlus.
 mplus is defined as (++) for [].

 but what if (a = c) causes c to fail, and (b = c) lets c succeed. In
 this
 case the LHS will fail, whereas the RHS will succeed I think?

 Keean.

That's probably a misunderstanding due to the notation, in the [] monad, it's 
just

concat (map c (a ++ b)) = concat (map c a) ++ concat (Map c b),

which is easily seen to be true (if applying c to an element of a causes an 
error, neither side will go past that).

Daniel
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hugs for Zaurus

2005-01-22 Thread Fritz Ruehr
Hi John,
I'm curious if you know what the requirements (memory, model, etc.) for 
running Hugs on a Zaurus might be: I am not normally a PDA sort of 
person, but a quick search indicates that Zauruses (Zauri?) are 
available (used) for around US $30-50 (e.g., 2MB ZR 5800 through 64 MB 
SL-5500). I'm guessing the 2MB model wouldn't work, but even at the 
higher prices the temptation would be great.

Anyway, thank you for your efforts, on behalf of current and future 
Zaurus users.

  --  Fritz
PS: I realize that you might not know what the exact requirements are: 
I imagine you don't have a large range of test systems available :) .

On Jan 21, 2005, at 12:15 PM, John Goerzen wrote:
Hello,
I have built a fixed Hugs for the Zaurus PDA running the OpenZaurus
distribution.  Download here:
http://quux.org/devel/zaurus/hugs_hugs98-Nov2003-r1_arm.ipk
Every module except Posix signals appears to be working.
-- John
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-22 Thread Keean Schupke
Daniel Fischer wrote:
That's probably a misunderstanding due to the notation, in the [] 
monad, it's

just
concat (map c (a ++ b)) = concat (map c a) ++ concat (Map c b),
which is easily seen to be true (if applying c to an element of a causes an 
error, neither side will go past that).

Daniel
 

So do we consider [] to be fail?, Monad.hs defines:
instance MonadPlus [] where
  mzero = []
  mplus = (++)
What would happen if this was the definition?
instance MonadPlus [] where
  mzero = []
  mplus a b
  | a == [] = b
  | otherwise = a
   Keean.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-22 Thread Jorge Adriano Aires
 But only some instances (such as []) satisfy this:

   (mplus a b) = c = mplus (a = c) (b = c)

 Other instances (IO, Maybe) satisfy this:

   mplus (return a) b = return a

 I think mplus should be separated into two functions. 

How would we implement the first kind in the Maybe instance of MonadPlus?

J.A.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-22 Thread Jorge Adriano Aires
snip
 Only the monoid Maybe a is not very nice (nor is the monoid IO a),since the 
 second argument of the composition is in  general ignored. 

snip

 So I think, rather than separating mplus, one should think about whether it
 is sensible to make Maybe and IO instances of MonadPlus in the first place.
 I don't know nearly enough of the innards of Haskell to form a valuable
 opinion of that, but perhaps somebody could enlighten me?

My humble opinion follows. 

It's still a Monoid, being boring should be no reason not to include it [*]. 
By taking advantage of typeclasses, we can easily alternate between more 
elaborate approaches and dull ones (if we have the dull ones available too). 

One common example is using MonadPlus for some backtracking algorithm, then 
instantiatiating it to Maybe or List instance depending on wether you just 
want one solution or all of them. 

[*] For instance, I've missed Maybe being an instance of MonadError. 

Greetings,
J.A.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hugs for Zaurus

2005-01-22 Thread John Goerzen
On Sat, Jan 22, 2005 at 01:52:58PM -0800, Fritz Ruehr wrote:
 I'm curious if you know what the requirements (memory, model, etc.) for 
 running Hugs on a Zaurus might be: I am not normally a PDA sort of 
 person, but a quick search indicates that Zauruses (Zauri?) are 
 available (used) for around US $30-50 (e.g., 2MB ZR 5800 through 64 MB 
 SL-5500). I'm guessing the 2MB model wouldn't work, but even at the 
 higher prices the temptation would be great.

I can give you some idea, at least.  When started from scratch, hugs
consumes about 4MB RAM on my system.

for those of you not familiar with the Zaurus, it is a PDA from Sharp
that runs a version of the Linux kernel and the Qt-derived Qtopia
environment from the factory.  There arealso numerous projects that have
developed alternative Zaurus ROMs, such as OpenZaurus.  

In addition to the Zaurus models you mentioned, there is also the
640x480 cxx0 series (c760, c860, c700, c750/ etc).  These models were
only sold in Japan, but are widely available in the rest of the world
through ebay and sites like dynamism.com and conics.net..  I have a c760
and it has 128MB RAM IIRC.

Most Zaurii can take SD and CF cards.  Debian has been ported to the
Zaurus also, and can run from a memory card.  nhc98 works in such a
setting.  Of course, hugs already works that way.  My effort simply
makes it work outside a debian chroot.  My understanding is that ghc is
currently broken on arm, but if/when that is fixed, you could actually
run ghc itself on the zaurus in Debian.  Thouhg it sometimes uses
almost 1GB of RAM -- that won't do :-)

The OpenEmbedded folks have a cross-compilation system built up, and
packages of about 1200 well-known unix programs that build in that
environment .  This is how OpenZaurus itself gets bilt.A  They do have a
hugs package, but it was broken due to some incompatibilities with
cross-compiling.

Hope this helps.  Feel free to ask if you have any other questions.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] File path programme

2005-01-22 Thread Isaac Jones
You might be interested in the new FilePath module that's in the
works.  There's been a lot of work to make these functions portable.

http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/libraries/base/System/FilePath.hs


peace,

  isaac
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe