-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sebastian Hanowski wrote:
>> It's sort of funny-looking, though: to write a factorial function,
>> for instance, you have to give "inf" an int, which doesn't get used
>> for anything.
> 
> To see how to write the factorial with the partial monad have a look at:
> 
>         http://sneezy.cs.nott.ac.uk/fplunch/weblog/?p=3

We don't really want factorial to be partial...

Anyway, neat seeing that, it makes it obvious how to write what I was
thinking of that two partial things can be combined such that you could
get either one... It's MonadPlus!

instance MonadPlus D where
 mzero = never
 mplus (Now a) _ = Now a
 mplus _ (Now a) = Now a
 mplus (Later d1) (Later d2) = mplus d1 d2

Although, this can pick an arbitrary answer based on the number of
cycles of recursion for each. What I was initially thinking was just for
functions like (&&).  In Haskell they're asymmetric, strict in the first
argument, where if it's False the whole function is false.  What would
be nice is a combinator that says that if partial argument A is foo, OR
partial argument B is bar, the whole function's answer is quux, no
matter if the other partial argument was _|_.

e.g.
(&&): False or False --> False
(||): True or True --> True
(\a b -> a && not b):
      False or True --> False

hmm... are there any instances of that pattern besides boolean logic,
(if we don't also want to enter the nondeterminism arena?)

Isaac


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGEiz1HgcxvIWYTTURAuI+AKC9zlafbQOWJpF9pcON/dO1vyxeHwCgqSLH
NjXpupvdGs3LD0mm4dqf4uc=
=08rZ
-----END PGP SIGNATURE-----

Reply via email to