result = $result; $this->fetch(); }} public function next() { $»t = ($this->nextValue); switch($»t->index) { case 0: { throw new HException("Iterator exhausted"); }break; case 1: $v = $»t->params[0]; { $this->fetch(); return $v; }break; } } public function hasNext() { return $this->nextValue != Maybe::$Nothing; } public function fetch() { $next = db_fetch($this->result); $this->nextValue = (($next) ? Maybe::Just($next) : Maybe::$Nothing); } public $nextValue; public $result; public function __call($m, $a) { if(isset($this->$m) && is_callable($this->$m)) return call_user_func_array($this->$m, $a); else if(isset($this->»dynamics[$m]) && is_callable($this->»dynamics[$m])) return call_user_func_array($this->»dynamics[$m], $a); else if('toString' == $m) return $this->__toString(); else throw new HException('Unable to call «'.$m.'»'); } function __toString() { return 'QueryIterator'; } }