[MLton] funny error message

Henry Cejtin henry.cejtin@sbcglobal.net
Fri, 23 Sep 2005 23:29:58 -0500


Sorry about that.  Here is the code this time.

signature STREAM =  
  sig
    type 'a stream

    val flatmap : ('a -> 'b stream) -> 'a stream -> 'b stream
    val flatten : 'a stream stream -> 'a stream
  end;


functor ListStream () : STREAM =
    struct
	type 'a stream = 'a list

	fun accumulate f initial str =
	    case str of
	      [] => initial
	    | head::tail =>
		 f (head, accumulate f initial tail)

	val flatten = accumulate (op @) []
	    
	fun flatmap f str = flatten (map f str)
    end