Or in where statement. Ordered-graph

Hi, I’m trying to base a stategroup in an ordered graph on the previous entry, however this works except for the first entry. I want a day only to be able to be set to 'Done'?'Yes' when the previous day os 'Done'?'Yes', however this causes a problem as the 'First Day' does not comply to that statement. Since it is not possible to have an or-statement in the where-statement, is there a way to do this? Thanks in advance.

'Days': collection ['Day']
	'Order': ordered-graph .'First Day' ( ?'Yes' || ?'No'>'Previous Day' )
	@small
{
	'Day': text @default: auto-increment || "1"
	'First Day': stategroup (
		'Yes' { }
		'No' {
			'Previous Day': text -> ^ sibling in ( 'Order' )
		}
	)
	'Done': stategroup (
		'Yes' where 'Previous Done' -> .'First Day'?'No' >'Previous Day' .'Done'?'Yes' 
|| .'First Day'?'Yes' { } // <--
		'No' { }
	)
}

My suggestion would be to add a derived stategroup that first determines whether it is the first day or not and whether that day is Done or not:

'Previous day done': stategroup = switch .'First day' (
	|'Yes' as $'yes' => switch $'yes'.'Done' (
	   |'Yes' => 'Yes' ( )
	   |'No' => 'No' ( )
	|'No' as $'no' => switch $'no'.'Done' (
	   |'Yes' => 'Yes' ( )
	   |'No' => 'No' ( )
	)
 ) (
	'Yes' { }
	'No' { }
 ) @hidden

Of course, this code still needs the ordered-graph ‘handling’ added…
Your where rule can then reference this stategroup.

@twagemakers that is not possible, as mandatory where rules for base values may not depend on derived values.

Yes I just ran into that problem. Is there another way?

Hmm… bummer, good to know.

Maybe an interesting extension to the application language…?

As you noticed, you cannot use an or-operator for where rules. where rules always produce a single node of a single specific type.

The goal of where rules (or more generally: constraints) in Alan is to ensure that derived values can always be computed without relying on fallback/implementation defined values. In your example, the constraints do not contribute to that goal.

For your use case, I would suggest using the todo concept:

'Done': stategroup (
	'Yes' {
		has-todo: ^ .'First Day'?'No' >'Previous Day' .'Done'?'No'
			@description: "Previous day should be Done before marking this one as Done."
	}
	'No' { }
)