34
loading...
This website collects cookies to deliver better user experience
Ubiquitous: present, appearing, or found everywhere.
functions
. the function is simple it's just a small kind of box that accepts input and produces output. input -> output.// Signature -> multiplay2 :: Number -> Number
// Which Means that the multiplay2 function takes and
// expect to pass parameter(input) from type Number and
// produce(output a value from type Number.
const multiplay2 = x => x * 2;
// Signature -> sum:: (Number, Number) -> Number
// Which Means that the sum function takes and expect to
// pass 2 parameter(input) from type Number
// and produce(output) a value from type Number.
const sum = (x, y) => x + y;
it’s just a given label or name for some values that could be used as input or output for function.
an algebraic data type is a kind of composite type, i.e., a type formed by combining other types.
type FruitSalad = {
apple: AppleKinds,
banana: BananaKinds,
orange: OrangeKinds
}
type FruitSnack = Apple | Banana | Orange
type Amount = number | string;
type Currency = 'USD' | 'EUR';
type CardType = 'Visa' | 'MasterCard';
type CardNumber = number;
type CreditCardInfo = {
CardType: CardType,
CardNumber: CardNumber
}
type Payment = {
Amount: Amount,
Currency: Currency,
CreditCardInfo: CreditCardInfo
}