Yes, of course you can do it. Well, sort of.
But like most things Ada-esque, it requires a modicum of thought and planning.
Here's one way (the only way?)
The corresponding declarations are,
package GrandParent is
type Item is private;
private
type Item is
record
Value : Boolean;
end record;
end GrandParent;
package GrandParent.Parent is
function Get
(The_Item : in Item)
return Boolean;
end GrandParent.Parent;
private package GrandParent.Child1 is
procedure Set
(The_Item : in out Item;
Value : in Boolean);
end GrandParent.Child1;
The package bodies are,
package body GrandParent.Child1 is
procedure Set
(The_Item : in out Item;
Value : in Boolean)
is
begin
The_Item.Value := Value;
end Set;
end GrandParent.Child1;
private with GrandParent.Child;
package body GrandParent.Parent is
function Get
(The_Item : in Item)
return Boolean
is
(The_Item.Value);
procedure Set
(The_Item : in out Item;
Value : in Boolean)
is
begin
GrandParent.Child.Set
(The_Item => The_Item,
Value => Value);
end Set;
end GrandParent.Parent;
If you then try to have,
(private) with GrandParent.Child;
package GrandParent.Parent.Child is
end GrandParent.Parent.Child;
This raises a compile time error that the current unit must also be a direct descendant of GrandParent thus effectively making the GrandParent.Child1 package private to GrandParent.Parent.
Clients of GrandParent also won't have visibility to GrandParent.Child1. However, other children of GrandParent will have the same visibility as GrandParent.Parent
That's how one could hide the Set subprogram. What if you want to hide the private type from the package children?
Firstly, that's probably questionable, since children of a package with a private type are designed to fully interact with that type, since as others have described, children are about extending the capabilities of their respective parent package.
If you want to do that, then your best bet is to hide away the type Item and both the Get and Set routines into GrandParent.Child so that only GrandParent.Parent can see them (in it's private body) and expose whatever functionality you want to allow the GrandParent.Parent's children to have in the GrandParent.Parent package.
However, I'm not sure that's particularly useful. A question - if Parent's children should not have access to the inner workings of Item, why are they Parent's childern?