Hi,
I do not understand how derivation works.
In the following, the only line that poses trouble is the body of the “Appointment” function.
I read:
je-appointments.adb:19:13: error: expected private type “Ada.Containers.Indefinite_Holders.Holder” from instance at je-appointments.ads:29
je-appointments.ads:29:1: error: expected private type “Ada.Containers.Indefinite_Holders.Holder” from instance at je-appointments.ads:29
je-appointments.ads:31:1: error: found type “SHolder” defined at je-appointments.ads:31
with Ada.Calendar, Ada.Streams.Stream_IO, Ada.Containers.Indefinite_Holders;
use Ada.Calendar, JE.Times, Ada.Streams.Stream_IO;
procedure Test is
package JE.Appointments is
type Appointment_Type is private;
function Details (Appt : Appointment_Type) return String;
function Appointment (Date : Time_Type;
Details : String) return Appointment_Type;
private
package SH is new Ada.Containers.Indefinite_Holders (String);
type SHolder is new SH.Holder with null record with
Input => HINput, Output => HOuput;
function HINput (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return SHolder;
procedure HOuput (Stream : not null access Ada.Streams.Root_Stream_Type'Class; T : SHolder);
type Appointment_Type is
record
Time : Time_Type;
Details : SH.Holder;
end record;
end JE.Appointments;
package body Appointments is
function Details (Appt : Appointment_Type) return String is
(Appt.Details.Element);
function Appointment (Date : Time_Type; Details : String) return Appointment_Type is
(Date, To_Holder (Details));
function HINput (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return SHolder is
(To_Holder (String'Input (Stream)));
procedure HOuput (Stream : not null access Ada.Streams.Root_Stream_Type'Class; T : SHolder) is
begin
String'Output (Stream, T.Element);
end HOuput;
end JE.Appointments;
begin
null;
end Test;