@@ -3698,6 +3698,34 @@ type module_item =
3698
3698
| Functor of Names.ModPath .t * Names.ModPath .t list
3699
3699
| FunctorType of Names.ModPath .t * Names.ModPath .t list
3700
3700
3701
+ [%% if coq = " 8.20" || coq = " 9.0" ]
3702
+ type 'a generic_module_body = 'a Declarations .generic_module_body
3703
+ let module_view m = (m.Declarations. mod_mp, m.Declarations. mod_type)
3704
+ let mod_type m = m.Declarations. mod_type
3705
+ let mod_mp m = m.Declarations. mod_mp
3706
+
3707
+ let rec functor_params x =
3708
+ let open Declarations in
3709
+ match x with
3710
+ | MoreFunctor (_ ,{ mod_type_alg = Some (MENoFunctor (MEident mod_mp )) } ,rest ) -> mod_mp :: functor_params rest
3711
+ | _ -> [] (* XXX non trivial functors, eg P : X with type a = nat, are badly described (no params) *)
3712
+ [%% else ]
3713
+ type 'a generic_module_body = 'a Mod_declarations .generic_module_body
3714
+ let module_view m = (Mod_declarations. mod_mp m, Mod_declarations. mod_type m)
3715
+ let mod_type = Mod_declarations. mod_type
3716
+ let mod_mp = Mod_declarations. mod_mp
3717
+
3718
+ let rec functor_params x =
3719
+ let open Declarations in
3720
+ match x with
3721
+ | MoreFunctor (_ , mtb , rest ) ->
3722
+ begin match Mod_declarations. mod_type_alg mtb with
3723
+ | Some (MENoFunctor (MEident mod_mp )) -> mod_mp :: functor_params rest
3724
+ | _ -> [] (* XXX *)
3725
+ end
3726
+ | _ -> [] (* XXX non trivial functors, eg P : X with type a = nat, are badly described (no params) *)
3727
+ [%% endif]
3728
+
3701
3729
let rec in_elpi_module_item ~depth path state (name , item ) =
3702
3730
let open Declarations in
3703
3731
match item with
@@ -3706,31 +3734,24 @@ let rec in_elpi_module_item ~depth path state (name, item) =
3706
3734
| SFBmind { mind_packets } ->
3707
3735
CList. init (Array. length mind_packets) (fun i -> Gref (GlobRef. IndRef (MutInd. make2 path name,i)))
3708
3736
| SFBrules _ -> nYI " rewrite rules"
3709
- | SFBmodule ( { mod_mp; mod_type = NoFunctor _ } as b ) -> [ Module (mod_mp,in_elpi_module ~depth state b) ]
3710
- | SFBmodule { mod_mp; mod_type = MoreFunctor _ as l } -> [ Functor (mod_mp,functor_params l)]
3711
- | SFBmodtype { mod_mp; mod_type = NoFunctor _ } -> [ModuleType mod_mp]
3712
- | SFBmodtype { mod_mp; mod_type = MoreFunctor _ as l } -> [FunctorType (mod_mp,functor_params l)]
3713
-
3714
- and functor_params x =
3715
- let open Declarations in
3716
- match x with
3717
- | MoreFunctor ( _ , { mod_type_alg = Some (MENoFunctor (MEident mod_mp )) } , rest ) -> mod_mp :: functor_params rest
3718
- | _ -> [] (* XXX non trivial functors, eg P : X with type a = nat, are badly described (no params) *)
3737
+ | SFBmodule b ->
3738
+ begin match module_view b with
3739
+ | mod_mp , NoFunctor _ -> [Module ( mod_mp,in_elpi_module ~depth state b) ]
3740
+ | mod_mp , ( MoreFunctor _ as l ) -> [Functor (mod_mp,functor_params l)]
3741
+ end
3742
+ | SFBmodtype m ->
3743
+ begin match module_view m with
3744
+ | mod_mp , NoFunctor _ -> [ ModuleType mod_mp]
3745
+ | mod_mp , (MoreFunctor _ as l ) -> [ FunctorType (mod_mp, functor_params l)]
3746
+ end
3719
3747
3720
- and in_elpi_module : 'a. depth:int -> API.Data.state -> 'a Declarations.generic_module_body -> module_item list =
3721
- fun ~depth state { Declarations.
3722
- mod_mp; (* Names. module_path *)
3723
- mod_expr; (* Declarations. module_implementation *)
3724
- mod_type; (* Declarations. module_signature *)
3725
- mod_type_alg; (* Declarations. module_expression option *)
3726
- mod_delta; (* Mod_subst. delta_resolver *)
3727
- mod_retroknowledge; (* Retroknowledge. action list *)
3728
- } ->
3729
- match mod_type with
3748
+ and in_elpi_module : 'a. depth:int -> API.Data.state -> 'a generic_module_body -> module_item list =
3749
+ fun ~depth state mb ->
3750
+ match mod_type mb with
3730
3751
| Declarations. MoreFunctor _ -> nYI " functors"
3731
3752
| Declarations. NoFunctor contents ->
3732
3753
let l =
3733
- CList. map (in_elpi_module_item ~depth mod_mp state) contents in
3754
+ CList. map (in_elpi_module_item ~depth ( mod_mp mb) state) contents in
3734
3755
CList. flatten l
3735
3756
3736
3757
let rec in_elpi_modty_item (name , item ) = match item with
@@ -3742,16 +3763,16 @@ let rec in_elpi_modty_item (name, item) = match item with
3742
3763
| Declarations. SFBmodule mb -> in_elpi_modty mb
3743
3764
| Declarations. SFBmodtype _ -> []
3744
3765
3745
- and in_elpi_modty : 'a.'a Declarations. generic_module_body -> string list =
3746
- fun { Declarations. mod_type; (* Declarations. modty_signature *) } ->
3747
- match mod_type with
3766
+ and in_elpi_modty : 'a.'a generic_module_body -> string list =
3767
+ fun mb ->
3768
+ match mod_type mb with
3748
3769
| Declarations. MoreFunctor _ -> nYI " functors"
3749
3770
| Declarations. NoFunctor contents ->
3750
3771
CList. flatten (CList. map in_elpi_modty_item contents)
3751
3772
3752
- let in_elpi_module ~depth s ( x : Declarations.module_body ) = in_elpi_module ~depth s x
3773
+ let in_elpi_module ~depth s x = in_elpi_module ~depth s x
3753
3774
3754
- let in_elpi_module_type ( x : Declarations.module_type_body ) = in_elpi_modty x
3775
+ let in_elpi_module_type x = in_elpi_modty x
3755
3776
3756
3777
(* ********************************* }}} ********************************** *)
3757
3778
0 commit comments