type Stream[T] = concept s, type S # interface s.head() is T s.tail is S proc display[T](stream: Stream[T]) = stdout.write stream.head stream.tail.display func consumes(a: Stream[char]) = discard type StreamImpl[T] = seq[T] # list func head[T](stream: StreamImpl[T]): T = stream[0] func tail[T](stream: StreamImpl[T]): StreamImpl[T] = stream[1..^1] & stream[0] # dumb let a: StreamImpl[char] = @['h', 'e', 'l', 'l', 'o'] consumes(a) # works just fine