simonpj's proposal on guards:

> > I would really welcome feedback on this proposal.  Have you encountered
> > situations in which pattern guards would be useful?  Can you think of ways
> > in which they might be harmful, or in which their semantics is non-obvious?
> > Are there ways in which the proposal could be improved?  And so on.

M. Chakravarty:

> ... The proposed syntax may look a bit strange in the beginning,
> but I find the upward compatibility and the simple changes to the
> grammar very attractive.

after some thought, the syntax looks just right for me. after all,
the proposal could be read as transforming

        fun x | Just b <- ..., more guards = expression

into

        fun x = do { Just b <- ..., more guards, return expression }

which makes sense since this is really happening in the
underlying (identity) monad. 

in fact it's not the identity but it
also has a zero (pattern doesn't match) 
and a (++) (if left arg. fails, try right arg.)
as in 

        fun x | guardx = ...; fun y | guardy = ...

which "really" is
        
        fun =      (\ x -> do { guardx, return ...} ) 
                ++ (\ y -> do { guardy, return ...} ) 
        

-- 
Johannes Waldmann   Institut für Informatik   FSU   D-07740  Jena  Germany
http://www5.informatik.uni-jena.de/~joe/ mailto:[EMAIL PROTECTED]




Reply via email to