
;; Copyright (C) 2017 Tommi Höynälänmaa

;; Expected results: translation and running OK

(define-proper-program (tests test589)

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

  (define-param-proc assoc-set0 (%key %value)
		     (((al (:alist %key %value))
		       (x-key %key)
		       (x-value %value))
		      (:pair (:alist %key %value) <boolean>)
		      pure)
    (match-type al
      ((<null>) (cons null #f))
      ((al1 (:nonempty-alist %key %value))
       (let ((p-binding (car al1)))
	 (if (equal? (car p-binding) x-key)
	     (cons
	      (cons
	       (cons x-key x-value)
	       (car (assoc-set0 (cdr al1) x-key x-value)))
	      #t)
	     (let ((x (assoc-set0 (cdr al1) x-key x-value)))
	       (cons
		(cons (car al1)
		      (car x))
		(cdr x))))))))

  (define-simple-proc main (() <none> nonpure)
    (let ((al '((abc . 1) (def . 2) (ghi . 3))))
      (console-display-line (assoc-set0 al 'jkl 5))
      (console-display-line (assoc-set0 al 'def 6)))))
