Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
cmester0 committed Apr 9, 2024
1 parent d2fbf65 commit 1227c58
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
31 changes: 13 additions & 18 deletions engine/backends/coq/coq/coq_backend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ open AST
module CoqLibrary : Library = struct
module Notation = struct
let int_repr (x : string) (i : string) : string =
"(Int"^x^".repr" ^ " " ^ i ^ ")"
"(Int" ^ x ^ ".repr" ^ " " ^ i ^ ")"

let type_str : string = "Type"
let bool_str : string = "bool"
Expand Down Expand Up @@ -168,8 +168,7 @@ struct
| TApp { ident = `TupleType n; args } when n >= 2 ->
C.AST.Product (args_ty span args)
| TApp { ident; args } ->
C.AST.AppTy
(C.AST.NameTy (pglobal_ident ident), args_ty span args)
C.AST.AppTy (C.AST.NameTy (pglobal_ident ident), args_ty span args)
| TArrow (inputs, output) ->
List.fold_right ~init:(pty span output)
~f:(fun x y -> C.AST.Arrow (x, y))
Expand Down Expand Up @@ -385,9 +384,7 @@ struct
| TyAlias { name; ty; _ } ->
[
C.AST.Notation
( "'" ^ pconcrete_ident name ^ "'",
C.AST.Type (pty span ty),
None );
("'" ^ pconcrete_ident name ^ "'", C.AST.Type (pty span ty), None);
]
(* record *)
| Type { name; generics; variants = [ v ]; is_struct = true } ->
Expand Down Expand Up @@ -449,8 +446,7 @@ struct
[],
C.AST.Var "id",
C.AST.Arrow
( C.AST.NameTy (o.type_name),
C.AST.NameTy (o.type_name) ) );
(C.AST.NameTy o.type_name, C.AST.NameTy o.type_name) );
]
| "bytes" ->
let open Hacspeclib_macro_parser in
Expand All @@ -470,8 +466,8 @@ struct
[],
C.AST.Var "id",
C.AST.Arrow
( C.AST.NameTy (o.bytes_name),
C.AST.NameTy (o.bytes_name) ) );
(C.AST.NameTy o.bytes_name, C.AST.NameTy o.bytes_name)
);
]
| "unsigned_public_integer" ->
let open Hacspeclib_macro_parser in
Expand All @@ -491,8 +487,8 @@ struct
[],
C.AST.Var "id",
C.AST.Arrow
( C.AST.NameTy (o.integer_name),
C.AST.NameTy (o.integer_name) ) );
( C.AST.NameTy o.integer_name,
C.AST.NameTy o.integer_name ) );
]
| "public_bytes" ->
let open Hacspeclib_macro_parser in
Expand All @@ -505,15 +501,14 @@ struct
(* int_of_string *) o.size )
in
[
C.AST.Notation
("'" ^ o.bytes_name ^ "'", C.AST.Type typ, None);
C.AST.Notation ("'" ^ o.bytes_name ^ "'", C.AST.Type typ, None);
C.AST.Definition
( o.bytes_name,
[],
C.AST.Var "id",
C.AST.Arrow
( C.AST.NameTy (o.bytes_name),
C.AST.NameTy (o.bytes_name) ) );
(C.AST.NameTy o.bytes_name, C.AST.NameTy o.bytes_name)
);
]
| "array" ->
let open Hacspeclib_macro_parser in
Expand Down Expand Up @@ -547,8 +542,8 @@ struct
[],
C.AST.Var "id",
C.AST.Arrow
( C.AST.NameTy (o.array_name),
C.AST.NameTy (o.array_name) ) );
(C.AST.NameTy o.array_name, C.AST.NameTy o.array_name)
);
]
| _ -> unsupported ())
| _ -> unsupported ())
Expand Down
10 changes: 8 additions & 2 deletions engine/backends/coq/coq_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,14 @@ functor
let rec term_to_string (x : AST.term) depth : string * bool =
match x with
| AST.UnitTerm -> ("tt", false)
| AST.Let { pattern = AST.AscriptionPat (pat, _) | pat; value = bind; value_typ = typ; body = term; _ }
->
| AST.Let
{
pattern = AST.AscriptionPat (pat, _) | pat;
value = bind;
value_typ = typ;
body = term;
_;
} ->
(* TODO: propegate type definition *)
let var_str = pat_to_string pat true depth in
let expr_str = term_to_string_without_paren bind (depth + 1) in
Expand Down

0 comments on commit 1227c58

Please sign in to comment.