StdBool.dcl 1.39 KB
Newer Older
1 2
system module StdBool

Camil Staps's avatar
Camil Staps committed
3 4 5 6
/**
 * Class instances and basic functions for the Bool type.
 */

7
// ****************************************************************************************
8 9
//	Concurrent Clean Standard Library Module Version 3.0
//	Copyright 2019 University of Nijmegen
10 11 12 13
// ****************************************************************************************

import	StdOverloaded

14
instance ==				Bool	:: !Bool !Bool -> Bool				:== code { eqB }
15

16
instance toBool			Bool	:: !Bool -> Bool					:== code { no_op }
17

18 19
instance fromBool		Bool	:: !Bool -> Bool					:== code { no_op }
instance fromBool		{#Char}	:: !Bool -> {#Char}					:== code { .d 0 1 b ; jsr BtoAC ; .o 1 0 }
20 21 22

//	Additional Logical Operators:

Camil Staps's avatar
Camil Staps committed
23 24 25 26 27 28
/**
 * Logical negation.
 *
 * @param The boolean to negate
 * @result True if the parameter was False; False if True
 */
29
not					:: !Bool		->	Bool						:== code { notB }
Camil Staps's avatar
Camil Staps committed
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

/**
 * Logical disjunction. The second parameter is not strict and will not be
 * evaluated if the first parameter is True.
 *
 * @param First boolean
 * @param Second boolean
 * @result True iff at least one of the parameters is True
 */
(||)	infixr 2	:: !Bool Bool	->	Bool

/**
 * Logical conjunction. The second parameter is not strict and will not be
 * evaluated if the first parameter is False.
 *
 * @param First boolean
 * @param Second boolean
 * @result True iff both parameters are True
 */
(&&)	infixr 3	:: !Bool Bool	->	Bool