Pattern guards

Ross Paterson ross at soi.city.ac.uk
Thu Sep 28 12:25:45 EDT 2006


On Thu, Sep 28, 2006 at 04:40:30PM +0300, Yitzchak Gale wrote:
> Now given any function binding using pattern guards:
> 
> funlhs
> | qual11, qual12, ..., qual1n = exp1
> | qual21, qual22, ..., qual2n = exp2
> ...
> 
> we translate the function binding into Haskell 98 as:
> 
> funlhs = runExit $ do
>  maybeExit $ do {qual11'; qual12'; ...; qual1n'; return (exp1)}
>  maybeExit $ do {qual21'; qual22'; ...; qual2n'; return (exp2)}
>  ...

Or even

funlhs = fromJust $
 do {qual11'; qual12'; ...; qual1n'; return (exp1)}
 `mplus`
 do {qual21'; qual22'; ...; qual2n'; return (exp2)}



More information about the Haskell-prime mailing list