;; -*-theme-*-

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

;; Expected results: translation error
;;  (type mismatch, sequence-length not implemented for
;;  (:uniform-list %element)).


(define-proper-program (tests test356)


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


  (define-generic-proc sequence-ref)
  (define-generic-proc sequence-length)
  (define-generic-proc sequence-map)


  (define-param-signature :sequence (%element) ()
    (sequence-ref (this <integer>) %element pure)
    (sequence-length (this) <integer> pure)
    (sequence-map ((:procedure (%element) %element pure) this) this pure))


  (define-param-method sequence-ref (%element)
		       (((l (:uniform-list %element)) (i <integer>))
			%element pure)
    (uniform-list-ref l i))


  (define-param-method sequence-map (%element)
		       (((proc (:procedure (%element) %element pure))
			 (l (:uniform-list %element)))
			(:uniform-list %element) pure)
    (map1 proc l))


  (define-param-proc display-sequence (%element)
		     (((seq (:sequence %element))) <none> nonpure)
    (let ((i-len <integer> (sequence-length seq)))
      (do ((i <integer> 0 (+ i 1))) ((>= i i-len))
        (console-display (sequence-ref seq i))
        (console-newline))))


  (define-simple-proc my-proc (((i <integer>)) <integer> pure)
    (+ i 1))


  (define-simple-proc main (() <none> nonpure)
    (let* ((seq (list 1 2 3 4 5))
	   (seq2 (sequence-map my-proc seq)))
      (display-sequence seq2)))
  
  )
