% vim: ft=mercury ts=4 sw=4 et

:- module y2.
:- interface.

:- type s
    --->    a
    ;       b
    ;       c.

:- type sa =< s
    --->    a.

:- type t
    --->    f(s, int)
    ;       g(s, int, int)
    ;       h(s, int).

:- type ta =< t
    --->    f(sa, int)
    ;       g(sa, int, int)
    ;       h(sa, int).

:- pred extract_second(t::in, int::out) is det.

:- implementation.

extract_second(T, Second) :-
    ( T = f(_, Second)
    ; T = g(_, Second, _)
    ; T = h(_, Second)
    ).
