public function provideFunctorTestData() { return ['Right' => ['$f' => function ($x) { return $x + 1; }, '$g' => function ($x) { return $x + 5; }, '$x' => Right::of(1)], 'Left' => ['$f' => function ($x) { return $x + 1; }, '$g' => function ($x) { return $x + 5; }, '$x' => Left::of(1)]]; }
/** * left :: a -> Left a * * @param mixed $value * * @return Left */ function left($value) { return Left::of($value); }
function read($file) { return is_file($file) ? Either\Right::of(file_get_contents($file)) : Either\Left::of(sprintf('File "%s" does not exists', $file)); }
function validateNameLength(array $request) { return strlen($request['name']) > 30 ? E\Left::of('Request name is to long') : E\Right::of($request); }