| TermDeclaration of term_former_decl
| TermDefinition of term_former_def
| LetRec of obj_kind list
- (* inductive and records missing *)
+ | Algebraic of (string * typ_context * (string * typ list) list) list
type obj = NUri.uri * obj_kind
| `Term _ -> assert false (* IMPOSSIBLE *)
;;
+let obj_of_inductive status ~metasenv uri ind leftno il =
+ let tyl =
+ HExtlib.filter_map
+ (fun _,name,arity,cl ->
+ match classify_not_term status true [] arity with
+ | `Proposition
+ | `KindOrType
+ | `Type -> assert false (* IMPOSSIBLE *)
+ | `PropKind -> None
+ | `Kind ->
+ let arity = kind_of status ~metasenv [] arity in
+ let ctx,_ as res = split_kind_prods [] arity in
+ Some (name,ctx,[])
+ ) il
+ in
+ match tyl with
+ [] -> status,None
+ | _ -> status, Some (uri, Algebraic tyl)
+;;
+
let obj_of status (uri,height,metasenv,subst,obj_kind) =
let obj_kind = apply_subst subst obj_kind in
try
fs (status,[])
in
status, Some (uri,LetRec objs)
- | NCic.Inductive _ -> status,None (*CSC: TO BE IMPLEMENTED*)
+ | NCic.Inductive (ind,leftno,il,_) ->
+ obj_of_inductive status ~metasenv uri ind leftno il
with
NotInFOmega ->
prerr_endline "-- NOT IN F_omega";
| TermDefinition ((ctx,ty),bo) ->
let name = name_of_uri `FunctionName uri in
let namectx = namectx_of_ctx ctx in
+ (*CSC: BUG here *)
name ^ " :: " ^ pp_typ status ["a";"b";"c"] (glue_ctx_typ ctx ty) ^ "\n" ^
name ^ " = " ^ pp_term status namectx bo
| LetRec l ->
(*CSC: BUG always uses the name of the URI *)
String.concat "\n" (List.map (fun obj -> pp_obj status (uri,obj)) l)
+ | Algebraic il ->
+ String.concat "\n"
+ (List.map
+ (fun _name,ctx,cl ->
+ (*CSC: BUG always uses the name of the URI *)
+ "data " ^ name_of_uri `TypeName uri ^ " " ^ pp_ctx ctx ^ " = " ^
+ String.concat " | " (List.map
+ (fun name,tys ->
+ capitalize `Constructor name ^
+ String.concat " " (List.map (pp_typ status []) tys)
+ ) cl
+ )) il)
(* inductive and records missing *)
let haskell_of_obj status obj =
match n with
[ O ⇒ nat
| S m ⇒ mktyp m ].*)
+
+inductive mynat : Type[0] ≝ myzero: mynat | mysucc: mynat → mynat.
+
+(*FEATURE: print kind signatures*)
+inductive T1 : (Type[0] → Type[0]) → ∀B:Type[0]. mynat → Type[0] → Type[0] ≝ .
+
+(*Not in F_omega *)
+inductive T2 : (Type[0] → Type[0]) → ∀B:Type[0]. B → Type[0] → Type[0] ≝ .
+
+(* no content *)
+inductive T3 : (Type[0] → Type[0]) → CProp[2] ≝ .
+
+(*BUG: elimination principles not extracted *)
+inductive myvect (A: Type[0]) (b:nat) : nat → Type[0] ≝
+ myemptyv : myvect A b 0
+ | mycons: ∀n. n < b → A → myvect A b n → myvect A b (S n).
\ No newline at end of file