;; -*-theme-*-

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

(define-interface (examples assoc-list-impl)


  (import (standard-library core)
	  (standard-library singleton))

  (define-param-class :assoc-list
    (parameters %key %value)
    (constructor-access module)
    (construct
     ((l-contents1 (:uniform-list (:pair %key (:singleton %value))))
      (eq-pred1? (:procedure (%key %key) <boolean> pure))))
    (fields
     (l-contents (:uniform-list (:pair %key (:singleton %value)))
		 module module l-contents1)
     (eq-pred? (:procedure (%key %key) <boolean> pure) module module
	       eq-pred1?)))
     
  (declare-method make-assoc-list
		  (:param-proc (%key %value)
			       ((:procedure (%key %key) <boolean> pure)
				%value)
				(:assoc-list %key %value) pure))

  (declare-static-virtual-method gen-assoc
			 (:param-proc (%key %value)
				      ((:assoc-list %key %value) %key)
				      (:maybe %value)
				      pure))

  (declare-static-virtual-method gen-assoc-set!
			 (:param-proc (%key %value)
				      ((:assoc-list %key %value) %key %value)
				      <none>
				      nonpure)))

