function u=construct(s,sizes_in)
	u=mkunit(s);
	state=s.s0; fn=s.fn;
	u.sizes_out = guess_sizes(fn,state);
	u.get_state = @get_state;
	u.set_state = @set_state;
	u.process   = @proc;

	function out=proc, [out,state]=fn(state); end
	function s=get_state, s=state; end
	function set_state(s), state=s; end
end

function sz_out=guess_sizes(fn,st)
	[out,s1] = fn(st);
	sz_out = {size(out)};
end

