StdOverloaded.dcl 3.32 KB
Newer Older
1 2
definition module StdOverloaded

Camil Staps's avatar
Camil Staps committed
3 4 5 6
/**
 * A number of common overloaded functions.
 */

7 8 9 10 11
// ****************************************************************************************
//	Concurrent Clean Standard Library Module Version 2.0
//	Copyright 1998 University of Nijmegen
// ****************************************************************************************

Camil Staps's avatar
Camil Staps committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
//* Add `arg1` to `arg2`.
class  (+)  infixl 6	a	:: !a	!a	->	a

//* Subtract `arg2` from `arg1`.
class  (-)  infixl 6	a	:: !a	!a	->	a

//* Zero (unit element for addition).
class  zero 			a	:: a


//* Multiply `arg1` with `arg2`.
class  (*)  infixl 7	a	:: !a	!a	->	a

//* Divide `arg1` by `arg2`.
class  (/)  infixl 7	a	:: !a	!a	->	a

//* One (unit element for multiplication).
class  one 			a	:: a


//* True if `arg1` is equal to `arg2`.
class  (==) infix  4	a	:: !a	!a	->	Bool

//* True if `arg1` is less than `arg2`.
class  (<)  infix  4	a	:: !a	!a	->	Bool

//* True if `arg1` is an even number.
class  isEven a :: !a -> Bool;

//* True if `arg1` is an odd  number.
class  isOdd  a :: !a -> Bool;


/**
 * Number of elements in `arg`.
 * Used for list-like structures. It should have O(n) complexity.
 */
class  length m	:: !(m a) -> Int

//* Slice a part from `arg1`.
class  (%)  infixl 9	a	:: !a !(!Int,!Int)	-> a


//* Append the arguments.
class  (+++) infixr 5	a 	:: !a	!a	-> a


//* `arg1` to the power of `arg2`.
class  (^)  infixr 8	a	:: !a	!a 	->	a

//* Absolute value.
class  abs  			a	:: !a		->	a

/**
 * The sign of a thing.
 * @result `1` for a positive value; `-1` for a negative value; `0` for zero
 */
class  sign 			a	:: !a 		->	Int

//* Negate a thing.
class  ~				a	:: !a 		->	a

74

Camil Staps's avatar
Camil Staps committed
75 76
//* `arg1` modulo `arg2`.
class  (mod) infix 7 a :: !a !a -> a
77

Camil Staps's avatar
Camil Staps committed
78 79
//* The remainder after division of `arg1 / arg2`.
class  (rem)	infix 7	a :: !a !a -> a
80

Camil Staps's avatar
Camil Staps committed
81 82
//* Greatest common divisor.
class  gcd a :: !a !a -> a
83

Camil Staps's avatar
Camil Staps committed
84 85
//* Least common multiple.
class  lcm a :: !a !a -> a
86 87


Camil Staps's avatar
Camil Staps committed
88 89
//* Convert into {{`Int`}}.
class  toInt			a	:: !a		->	Int
90

Camil Staps's avatar
Camil Staps committed
91 92
//* Convert into {{`Char`}}.
class  toChar		a	:: !a		->	Char
93

Camil Staps's avatar
Camil Staps committed
94 95
//* Convert into {{`Bool`}}.
class  toBool		a	:: !a		->	Bool
96

Camil Staps's avatar
Camil Staps committed
97 98
//* Convert into {{`Real`}}.
class  toReal		a	:: !a		->	Real
99

Camil Staps's avatar
Camil Staps committed
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
//* Convert into {{`String`}}.
class  toString		a	:: !a		->	{#Char}


//* Convert from {{`Int`}}.
class  fromInt		a	:: !Int			-> a

//* Convert from {{`Char`}}.
class  fromChar		a	:: !Char		-> a

//* Convert from {{`Bool`}}.
class  fromBool		a	:: !Bool		-> a

//* Convert from {{`Real`}}.
class  fromReal		a	:: !Real		-> a

//* Convert from {{`String`}}.
class  fromString	a	:: !{#Char}		-> a


//* Logarithm base e.
class  ln			a	:: !a 		->	a

//* Logarithm base 10.
class  log10			a	:: !a 		->	a

//* e to to the power of `arg`.
class  exp			a	:: !a 		->	a

//* Square root.
class  sqrt			a	:: !a 		->	a
131 132 133 134


//	Trigonometrical Functions:

Camil Staps's avatar
Camil Staps committed
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
//* Sine.
class  sin			a	:: !a		->	a

//* Cosine.
class  cos			a	:: !a		->	a

//* Tangent.
class  tan			a	:: !a		->	a

//* Arc Sine.
class  asin			a	:: !a		->	a

//* Arc Cosine.
class  acos			a	:: !a		->	a

//* Arc Tangent.
class  atan			a	:: !a		->	a

//* Hyperbolic Sine.
class  sinh			a	:: !a		->	a

//* Hyperbolic Cosine.
class  cosh			a	:: !a		->	a

//* Hyperbolic Tangent.
class  tanh			a	:: !a		->	a

//* Arc Hyperbolic Sine.
class  asinh			a	:: !a		->	a

//* Arc Hyperbolic Cosine.
class  acosh			a	:: !a		->	a

//* Arc Hyperbolic Tangent.
class  atanh			a	:: !a		->	a