:- module change_class_r_2.

:- interface.

:- import_module io.

:- type foo
	--->	a
	;	b(int).

:- pred init_foo(foo::out) is det.

:- typeclass io(T) where [
	pred output(T::in, io__state::di, io__state::uo) is det,
	pred input(T::out, io__state::di, io__state::uo) is det
].
	
:- instance io(foo).

:- implementation.

:- import_module require.

:- instance io(foo) where [
	pred(output/3) is io__write,
	(input(T) -->
		io__read(Result),
		{ Result = ok(T0) ->
			T = T0
		;
			error("io__read failed")
		}
	)
].

init_foo(a).

