Some implements Option private $v; public function getOrElse($alter) return $this->v; class None implements Option public function getOrElse($alter) return $alter; echo $hash->get("key")->getOrElse(0);
$v; public function getOrElse($alter) return $this->v; public function =>($func, $args) return $this->v->$func(*$args); class Nothing implements Maybe public function getOrElse($alter) return $alter; public function =>($func, $args) return Nothing;
$v; public function getOrElse($alter) return $this->v; public function =>($func, $args) return $this->v->$func(*$args); class Nothing implements Maybe public function getOrElse($alter) return $alter; public function =>($func, $args) return Nothing;
new Just($hash)=>get("key") == $hash->get ("key") 2. m >>= return == m new Just($hash)=>(Just::__constructor) == new Just($hash) 3. (m >>= f) >>= g == m >>= (\x -> f x >>= g) new Just($hash)=>get("key1")=>get("key2") == new Just($hash)=>(function ($m) { return $m- >get("key1")=>get("key2"); })
new List($x)=>split == split($x) 2. m >>= return == m new List($x)=>(List::__constructor) == new List($x) 3. (m >>= f) >>= g == m >>= (\x -> f x >>= g) new List($x)=>split=>filter == new List($x)=>(function ($x) { return $x- >split=>filter; })