public static function AlphaOperator($op, $nArgs, DataType $alpha) { $aVal = $alpha->value(); switch ($nArgs) { case 1: grokit_assert(array_key_exists($op, self::$unaryOperators), 'Attempted to generate invalid unary operator ' . $op . ' with alpha type ' . $alpha); $form = self::$unaryOperators[$op]; switch ($form) { case 'ata': $args = [$alpha->value()]; $call = function () use($alpha) { return array('kind' => InfoKind::T_OP, 'input' => [$alpha], 'result' => $alpha); }; break; } break; case 2: // Binary operator grokit_assert(array_key_exists($op, self::$binaryOperators), 'Attempted to generate invalid binary operator ' . $op . ' with alpha type ' . $alpha); $form = self::$binaryOperators[$op]; switch ($form) { case 'aata': $args = [$aVal, $aVal]; $call = function () use($alpha) { return array('kind' => InfoKind::T_OP, 'input' => [$alpha, $alpha], 'result' => $alpha); }; break; case 'aatb': $args = [$aVal, $aVal]; $call = function () use($alpha) { return array('kind' => InfoKind::T_OP, 'input' => [$alpha, $alpha], 'result' => lookupType('base::bool')); }; break; } } declareOperator($op, $args, $call); }