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

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

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

