--  Access-to-subprogram types with contracts, and subprograms they designate.
package Ops is
   type Unary is access function (X : Integer) return Integer
     with Pre => X in -1000 .. 1000, Post => Unary'Result in -2000 .. 2000;
   type Action is access procedure (Total : in out Integer)
     with Pre => Total in 0 .. 1000, Post => Total in Total'Old .. Total'Old + 1;

   function Double (X : Integer) return Integer is (2 * X)
     with Pre => X in -1000 .. 1000, Post => Double'Result = 2 * X;
   function Negate (X : Integer) return Integer is (-X)
     with Pre => X in -1000 .. 1000;
   function Clamp (X : Integer) return Integer is (Integer'Max (-100, Integer'Min (100, X)));

   procedure Bump (Total : in out Integer)
     with Pre => Total in 0 .. 1000, Post => Total = Total'Old + 1;
   procedure Keep (Total : in out Integer) with Post => Total = Total'Old;

   type Values is array (1 .. 4) of Integer;
   type Unaries is array (1 .. 3) of Unary;

   --  F applied to each of the values, through the access value
   procedure Apply_All (F : not null Unary; V : in out Values)
     with Pre => (for all X of V => X in -1000 .. 1000);
end Ops;
