Nested Guards

Bas van Dijk basvandijk at home.nl
Sat Jul 1 04:34:07 EDT 2006


Hello,

I would like to propose a feature from the FP language Clean[1] called Nested 
Guards. Example from [2]:

example arg1 arg2
	| predicate11 arg1
		| predicate21 arg2 = calculate1 arg1 arg2
		| predicate22 arg2 = calculate2 arg1 arg2
		| otherwise             = calculate3 arg1 arg2 
	| predicate12 arg1         = calculate4 arg1 arg2 

I think the semantics are clear enough.

Nested Guards should also be interoperable with Pattern Guards[3]. When a 
match on a pattern guard succeeds the environment is updated with the new 
bindings. Then the potential nested guards are matched in order in this new 
environment.

What do you think?

Bas van Dijk.

[1] http://www.cs.ru.nl/~clean
[2] ftp://ftp.cs.kun.nl/pub/Clean/Clean20/doc/CleanRep2.0.pdf (See 3.3 Guards)
[3] http://hackage.haskell.org/trac/haskell-prime/wiki/PatternGuards


More information about the Haskell-prime mailing list