Nested Guards

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


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 

What do you think?

Bas van Dijk.

[2] (See 3.3 Guards)

More information about the Haskell-prime mailing list