;; -*-theme-d-*-

;; Copyright (C) 2016 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 test462)


  (import (standard-library core)
	  (standard-library string-utilities)
	  (standard-library stream)
	  (standard-library console-io)
	  (standard-library object-string-conversion))


  (define-simple-proc main (() <none> nonpure)
    (let* ((l1 '(1 2 3 4 5))
	   (stm (list->stream l1))
	   (stm2 (stream-map
		  (lambda (((i <integer>)) <integer> pure) (+ i 1))
		  stm))
	   (l2 (stream->list stm2))
	   (stm3 (stream-map
		  (lambda (((i <integer>)) <real> pure) (+ i 0.5))
		  stm))
	   (l3 (stream->list stm3))
	   (stm4 (:nonpure-stream <string>)
		 (stream-map-nonpure
		  (lambda (((i <integer>)) <string> nonpure)
		    (console-display-line "*")
		    (object->string i))
		  stm))
	   (l4 (nonpure-stream->list stm4)))
      (console-display-line l2)
      (console-display-line l3)
      (console-display-line l4)
      (stream-for-each (lambda (((r <real>)) <none> nonpure)
			 (console-display r)
			 (console-display ", "))
		       stm3)
      (console-newline)
      (console-display-line
       (nonpure-stream->list
	(nonpure-stream-map (lambda (((str <string>)) <string> nonpure)
			      (console-display-line str)
			      (string-append str "*"))
			    stm4)))
      (nonpure-stream-for-each (lambda (((str <string>)) <none> nonpure)
				 (console-display str)
				 (console-display ", "))
			       stm4)
      (console-newline))
    0))
