Version.icl 849 Bytes
Newer Older
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
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