;; -*-theme-d-*-

;; Copyright (C) 2014 Tommi Höynälänmaa
;; Distributed under GNU General Public License version 3,
;; see file doc/GPL-3.

;; Expected results: translation and running OK


(define-proper-program (tests test126)


  (import (standard-library core)
	  (standard-library console-io))


  (add-method my-map
    (param-lambda (%arg-type %result-type)
		  (((proc (:procedure (%arg-type) %result-type pure))
		    (lst (:uniform-list %arg-type)))
		   (:uniform-list %result-type)
		   pure)
		  (raise 'abstract-method)))

  (add-method my-map
    (param-lambda (%arg-type %result-type)
		  (((proc (:procedure (%arg-type) %result-type pure))
		    (lst (:nonempty-uniform-list %arg-type)))
		   (:uniform-list %result-type)
		   pure)
		  (cons (proc (car lst)) (my-map proc (cdr lst)))))

  (add-method my-map
    (param-lambda (%arg-type %result-type)
		  (((proc (:procedure (%arg-type) %result-type pure))
		    (lst <null>))
		   (:uniform-list %result-type)
		   pure)
		  null))

  (define main
    (lambda (() <integer> nonpure)
      (let* ((lst (list 1 2 3 4 5))
	     (proc (lambda (((n <integer>)) <integer> pure) (+ n 2)))
	     (result (my-map proc lst)))
	(console-display result)
	(console-newline))
      0)))
