aboutsummaryrefslogtreecommitdiff
path: root/main/Version.icl
blob: d53aba2db0f6bb6a543a6bb4acc49f07cda870b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
	module owner: Ronny Wichers Schreur
*/
implementation module Version

import StdInt, StdClass

:: VersionInfo =
	{	versionCurrent
			:: Int
	,	versionOldestDefinition
			:: Int
	,	versionOldestImplementation
			:: Int
	}

:: VersionsCompatability
	=	VersionsAreCompatible
	|	VersionObservedIsTooOld
	|	VersionObservedIsTooNew

versionCompare :: VersionInfo VersionInfo -> VersionsCompatability
versionCompare expected observed
	| expected.versionCurrent < observed.versionCurrent
		| expected.versionCurrent >= observed.versionOldestDefinition
			=	VersionsAreCompatible
		// otherwise
			=	VersionObservedIsTooNew
	| expected.versionCurrent == observed.versionCurrent
		=	VersionsAreCompatible
	// expected.versionCurrent > observed.versionCurrent
		| expected.versionOldestImplementation <= observed.versionCurrent
			=	VersionsAreCompatible
		// otherwise
			=	VersionObservedIsTooOld