I am having a little trouble following the two discussions on pattern
guards and monads, due to some (probably minor) confusing pieces of
syntax.  Would anyone like to clarify these for me?  It would help me
to understand the underlying issues.  Thanks.

----
On pattern guards, Simon PJ writes:
>  f (x:xs) | x<0 = e1
>           | x>0 = e2
>           | otherwise = e3

then
>   g a | (x:xs) <- h a, x<0 = e1
>       | (x:xs) <- h a, x>0 = e1
>       | otherwise = e3

Am i right in thinking that f [] is bottom, whilst g [] is e3?

Later, another definition of g (intended to be equivalent?) is given in
which g [] appears to be bottom:
>  g a | (x:xs) <- h a
>         | x<0 = e1
>         | x>0 = e2
>         | otherwise = e3

To match the semantics of the earlier definition of g, shouldn't this
read as follows?
   g a | (x:xs) <- h a
          | x<0 = e1
          | x>0 = e2
       | otherwise = e3

----
Now, for monads, Phil Wadler writes a law:
>       m >>= \x -> k x ++ h x  =  m >>= k ++ n >>= k

in which 'h' appears on the lhs but not the rhs, and 'n' on the rhs but
not the lhs.  Are h and n the same?  Or perhaps the equation should read
as follows?
        m >>= \x -> k x ++ h x  =  m >>= k ++ m >>= h

----
Regards,
    Malcolm

[EMAIL PROTECTED]



Reply via email to