diff --git a/Makefile b/Makefile index a1d88ed0..07a641c7 100644 --- a/Makefile +++ b/Makefile @@ -181,14 +181,20 @@ bench_js: run_french_law_library_benchmark_js FRENCH_LAW_OCAML_LIB_DIR=french_law/ocaml FRENCH_LAW_JS_LIB_DIR=french_law/js +FRENCH_LAW_PYTHON_LIB_DIR=french_law/python + +$(FRENCH_LAW_PYTHON_LIB_DIR)/allocations_familiales.py: .FORCE + CATALA_OPTS="-O" $(MAKE) -C $(ALLOCATIONS_FAMILIALES_DIR) allocations_familiales.py + cp -f $(ALLOCATIONS_FAMILIALES_DIR)/allocations_familiales.py \ + $(FRENCH_LAW_PYTHON_LIB_DIR)/ $(FRENCH_LAW_OCAML_LIB_DIR)/law_source/allocations_familiales.ml: .FORCE - CATALA_OPTS="-O -t" $(MAKE) -C $(ALLOCATIONS_FAMILIALES_DIR) allocations_familiales.ml + CATALA_OPTS="-O" $(MAKE) -C $(ALLOCATIONS_FAMILIALES_DIR) allocations_familiales.ml cp -f $(ALLOCATIONS_FAMILIALES_DIR)/allocations_familiales.ml \ $(FRENCH_LAW_OCAML_LIB_DIR)/law_source $(FRENCH_LAW_OCAML_LIB_DIR)/law_source/unit_tests/tests_allocations_familiales.ml: .FORCE - CATALA_OPTS="-O -t" $(MAKE) -s -C $(ALLOCATIONS_FAMILIALES_DIR) tests/tests_allocations_familiales.ml + CATALA_OPTS="-O" $(MAKE) -s -C $(ALLOCATIONS_FAMILIALES_DIR) tests/tests_allocations_familiales.ml cp -f $(ALLOCATIONS_FAMILIALES_DIR)/tests/tests_allocations_familiales.ml \ $(FRENCH_LAW_OCAML_LIB_DIR)/law_source/unit_tests/ @@ -216,6 +222,11 @@ build_french_law_library_js: generate_french_law_library_ocaml format dune build --profile release $(FRENCH_LAW_OCAML_LIB_DIR)/api_web.bc.js cp -f $(ROOT_DIR)/_build/default/$(FRENCH_LAW_OCAML_LIB_DIR)/api_web.bc.js $(FRENCH_LAW_JS_LIB_DIR)/french_law.js +#> generate_french_law_library_python : Generates the French law library Python sources from Catala +generate_french_law_library_ocaml:\ + $(FRENCH_LAW_PYTHON_LIB_DIR)/allocations_familiales.py + + ########################################## # Website assets ########################################## diff --git a/compiler/driver.ml b/compiler/driver.ml index e264e783..579341cd 100644 --- a/compiler/driver.ml +++ b/compiler/driver.ml @@ -257,24 +257,29 @@ let driver (source_file : Pos.input_file) (debug : bool) (unstyled : bool) | Contents _ -> Errors.raise_error "This backend does not work if the input is not a file" in - let output_file = + let output_file (extension : string) : string = match output_file with | Some f -> f - | None -> Filename.remove_extension source_file ^ ".ml" + | None -> Filename.remove_extension source_file ^ extension in - Cli.debug_print (Printf.sprintf "Writing to %s..." output_file); - let oc = open_out output_file in - let fmt = Format.formatter_of_out_channel oc in - (match backend with | Cli.OCaml -> + let output_file = output_file ".ml" in + Cli.debug_print (Printf.sprintf "Writing to %s..." output_file); + let oc = open_out output_file in + let fmt = Format.formatter_of_out_channel oc in Cli.debug_print "Compiling program into OCaml..."; - Lcalc.To_ocaml.format_program fmt prgm type_ordering + Lcalc.To_ocaml.format_program fmt prgm type_ordering; + close_out oc | Cli.Python -> + let output_file = output_file ".py" in Cli.debug_print "Compiling program into Python..."; - Lcalc.To_python.format_program fmt prgm type_ordering + Cli.debug_print (Printf.sprintf "Writing to %s..." output_file); + let oc = open_out output_file in + let fmt = Format.formatter_of_out_channel oc in + Lcalc.To_python.format_program fmt prgm type_ordering; + close_out oc | _ -> assert false (* should not happen *)); - close_out oc; 0 | _ -> assert false (* should not happen *)) diff --git a/compiler/lcalc/backends.ml b/compiler/lcalc/backends.ml index 3a56f4d9..bb424363 100644 --- a/compiler/lcalc/backends.ml +++ b/compiler/lcalc/backends.ml @@ -52,3 +52,22 @@ let to_lowercase (s : string) : string = is_first := false) s; !out + +let to_uppercase (s : string) : string = + let last_was_underscore = ref false in + let is_first = ref true in + let out = ref "" in + CamomileLibraryDefault.Camomile.UTF8.iter + (fun c -> + let is_underscore = c = CamomileLibraryDefault.Camomile.UChar.of_char '_' in + let c_string = String.make 1 (CamomileLibraryDefault.Camomile.UChar.char_of c) in + out := + !out + ^ + if is_underscore then "" + else if !last_was_underscore || !is_first then String.uppercase_ascii c_string + else c_string; + last_was_underscore := is_underscore; + is_first := false) + s; + !out diff --git a/compiler/lcalc/backends.mli b/compiler/lcalc/backends.mli index 90759da4..c0a80f11 100644 --- a/compiler/lcalc/backends.mli +++ b/compiler/lcalc/backends.mli @@ -18,3 +18,6 @@ val to_ascii : string -> string val to_lowercase : string -> string (** Converts CamlCase into snake_case *) + +val to_uppercase : string -> string +(** Convertes snake_case into CamlCase *) diff --git a/compiler/lcalc/to_python.ml b/compiler/lcalc/to_python.ml index b02d87ea..5e64ab79 100644 --- a/compiler/lcalc/to_python.ml +++ b/compiler/lcalc/to_python.ml @@ -20,26 +20,22 @@ module D = Dcalc.Ast let format_lit (fmt : Format.formatter) (l : lit Pos.marked) : unit = match Pos.unmark l with | LBool b -> Dcalc.Print.format_lit fmt (Pos.same_pos_as (Dcalc.Ast.LBool b) l) - | LInt i -> Format.fprintf fmt "integer_of_string@ \"%s\"" (Runtime.integer_to_string i) - | LUnit -> Dcalc.Print.format_lit fmt (Pos.same_pos_as Dcalc.Ast.LUnit l) + | LInt i -> Format.fprintf fmt "integer_of_string(\"%s\")" (Runtime.integer_to_string i) + | LUnit -> Format.fprintf fmt "Unit()" | LRat i -> - Format.fprintf fmt "decimal_of_string \"%a\"" Dcalc.Print.format_lit + Format.fprintf fmt "decimal_of_string(\"%a\")" Dcalc.Print.format_lit (Pos.same_pos_as (Dcalc.Ast.LRat i) l) | LMoney e -> - Format.fprintf fmt "money_of_cents_string@ \"%s\"" + Format.fprintf fmt "money_of_cents_string(\"%s\")" (Runtime.integer_to_string (Runtime.money_to_cents e)) | LDate d -> - Format.fprintf fmt "date_of_numbers %d %d %d" + Format.fprintf fmt "date_of_numbers(%d,%d,%d)" (Runtime.integer_to_int (Runtime.year_of_date d)) (Runtime.integer_to_int (Runtime.month_number_of_date d)) (Runtime.integer_to_int (Runtime.day_of_month_of_date d)) | LDuration d -> let years, months, days = Runtime.duration_to_years_months_days d in - Format.fprintf fmt "duration_of_numbers %d %d %d" years months days - -let format_op_kind (fmt : Format.formatter) (k : Dcalc.Ast.op_kind) = - Format.fprintf fmt "%s" - (match k with KInt -> "!" | KRat -> "&" | KMoney -> "$" | KDate -> "@" | KDuration -> "^") + Format.fprintf fmt "duration_of_numbers(%d,%d,%d)" years months days let format_log_entry (fmt : Format.formatter) (entry : Dcalc.Ast.log_entry) : unit = match entry with @@ -50,18 +46,19 @@ let format_log_entry (fmt : Format.formatter) (entry : Dcalc.Ast.log_entry) : un let format_binop (fmt : Format.formatter) (op : Dcalc.Ast.binop Pos.marked) : unit = match Pos.unmark op with - | Add k -> Format.fprintf fmt "+%a" format_op_kind k - | Sub k -> Format.fprintf fmt "-%a" format_op_kind k - | Mult k -> Format.fprintf fmt "*%a" format_op_kind k - | Div k -> Format.fprintf fmt "/%a" format_op_kind k - | And -> Format.fprintf fmt "%s" "&&" - | Or -> Format.fprintf fmt "%s" "||" - | Eq -> Format.fprintf fmt "%s" "=" - | Neq | Xor -> Format.fprintf fmt "%s" "<>" - | Lt k -> Format.fprintf fmt "%s%a" "<" format_op_kind k - | Lte k -> Format.fprintf fmt "%s%a" "<=" format_op_kind k - | Gt k -> Format.fprintf fmt "%s%a" ">" format_op_kind k - | Gte k -> Format.fprintf fmt "%s%a" ">=" format_op_kind k + | Add _ -> Format.fprintf fmt "+" + | Sub _ -> Format.fprintf fmt "-" + | Mult _ -> Format.fprintf fmt "*" + | Div D.KInt -> Format.fprintf fmt "//" + | Div _ -> Format.fprintf fmt "/" + | And -> Format.fprintf fmt "and" + | Or -> Format.fprintf fmt "or" + | Eq -> Format.fprintf fmt "==" + | Neq | Xor -> Format.fprintf fmt "!=" + | Lt _ -> Format.fprintf fmt "<" + | Lte _ -> Format.fprintf fmt "<=" + | Gt _ -> Format.fprintf fmt ">" + | Gte _ -> Format.fprintf fmt ">=" | Map -> Format.fprintf fmt "Array.map" | Filter -> Format.fprintf fmt "array_filter" @@ -84,8 +81,8 @@ let format_string_list (fmt : Format.formatter) (uids : string list) : unit = let format_unop (fmt : Format.formatter) (op : Dcalc.Ast.unop Pos.marked) : unit = match Pos.unmark op with - | Minus k -> Format.fprintf fmt "~-%a" format_op_kind k - | Not -> Format.fprintf fmt "%s" "not" + | Minus _ -> Format.fprintf fmt "-" + | Not -> Format.fprintf fmt "not" | Log (entry, infos) -> Format.fprintf fmt "@[log_entry@ \"%a|%a\"@]" format_log_entry entry format_uid_list infos @@ -98,13 +95,11 @@ let format_unop (fmt : Format.formatter) (op : Dcalc.Ast.unop Pos.marked) : unit let avoid_keywords (s : string) : string = if match s with - (* list taken from http://caml.inria.fr/pub/docs/manual-ocaml/lex.html#sss:keywords *) - | "and" | "as" | "assert" | "asr" | "begin" | "class" | "constraint" | "do" | "done" | "downto" - | "else" | "end" | "exception" | "external" | "false" | "for" | "fun" | "function" | "functor" - | "if" | "in" | "include" | "inherit" | "initializer" | "land" | "lazy" | "let" | "lor" | "lsl" - | "lsr" | "lxor" | "match" | "method" | "mod" | "module" | "mutable" | "new" | "nonrec" - | "object" | "of" | "open" | "or" | "private" | "rec" | "sig" | "struct" | "then" | "to" - | "true" | "try" | "type" | "val" | "virtual" | "when" | "while" | "with" -> + (* list taken from https://www.programiz.com/python-programming/keyword-list *) + | "False" | "None" | "True" | "and" | "as" | "assert" | "async" | "await" | "break" | "class" + | "continue" | "def" | "del" | "elif" | "else" | "except" | "finally" | "for" | "from" + | "global" | "if" | "import" | "in" | "is" | "lambda" | "nonlocal" | "not" | "or" | "pass" + | "raise" | "return" | "try" | "while" | "with" | "yield" -> true | _ -> false then s ^ "_" @@ -113,7 +108,7 @@ let avoid_keywords (s : string) : string = let format_struct_name (fmt : Format.formatter) (v : Dcalc.Ast.StructName.t) : unit = Format.fprintf fmt "%s" (avoid_keywords - (to_lowercase (to_ascii (Format.asprintf "%a" Dcalc.Ast.StructName.format_t v)))) + (to_uppercase (to_ascii (Format.asprintf "%a" Dcalc.Ast.StructName.format_t v)))) let format_struct_field_name (fmt : Format.formatter) (v : Dcalc.Ast.StructFieldName.t) : unit = Format.fprintf fmt "%s" @@ -121,7 +116,7 @@ let format_struct_field_name (fmt : Format.formatter) (v : Dcalc.Ast.StructField let format_enum_name (fmt : Format.formatter) (v : Dcalc.Ast.EnumName.t) : unit = Format.fprintf fmt "%s" - (avoid_keywords (to_lowercase (to_ascii (Format.asprintf "%a" Dcalc.Ast.EnumName.format_t v)))) + (avoid_keywords (to_uppercase (to_ascii (Format.asprintf "%a" Dcalc.Ast.EnumName.format_t v)))) let format_enum_cons_name (fmt : Format.formatter) (v : Dcalc.Ast.EnumConstructor.t) : unit = Format.fprintf fmt "%s" @@ -151,18 +146,24 @@ let rec format_typ (fmt : Format.formatter) (typ : Dcalc.Ast.typ Pos.marked) : u else Format.fprintf fmt "%a" format_typ t in match Pos.unmark typ with - | TLit l -> Format.fprintf fmt "%a" Dcalc.Print.format_tlit l + | TLit TUnit -> Format.fprintf fmt "Unit" + | TLit TMoney -> Format.fprintf fmt "Money" + | TLit TInt -> Format.fprintf fmt "Integer" + | TLit TRat -> Format.fprintf fmt "Decimal" + | TLit TDate -> Format.fprintf fmt "Date" + | TLit TDuration -> Format.fprintf fmt "Duration" + | TLit TBool -> Format.fprintf fmt "bool" | TTuple (ts, None) -> - Format.fprintf fmt "@[(%a)@]" + Format.fprintf fmt "Tuple[%a]" (Format.pp_print_list - ~pp_sep:(fun fmt () -> Format.fprintf fmt "@ *@ ") + ~pp_sep:(fun fmt () -> Format.fprintf fmt ", ") (fun fmt t -> Format.fprintf fmt "%a" format_typ_with_parens t)) ts | TTuple (_, Some s) -> Format.fprintf fmt "%a" format_struct_name s | TEnum (_, e) -> Format.fprintf fmt "%a" format_enum_name e | TArrow (t1, t2) -> - Format.fprintf fmt "@[%a ->@ %a@]" format_typ_with_parens t1 format_typ_with_parens t2 - | TArray t1 -> Format.fprintf fmt "@[%a@ array@]" format_typ_with_parens t1 + Format.fprintf fmt "Callable[[%a], %a]" format_typ_with_parens t1 format_typ_with_parens t2 + | TArray t1 -> Format.fprintf fmt "List[%a]" format_typ_with_parens t1 | TAny -> Format.fprintf fmt "_" let format_var (fmt : Format.formatter) (v : Var.t) : unit = @@ -189,8 +190,8 @@ let format_exception (fmt : Format.formatter) (exc : except Pos.marked) : unit = | NoValueProvided -> let pos = Pos.get_position exc in Format.fprintf fmt - "(NoValueProvided@ @[{filename = \"%s\";@ start_line=%d;@ start_column=%d;@ \ - end_line=%d; end_column=%d;@ law_headings=%a}@])" + "NoValueProvided(SourcePosition(filename = \"%s\",@ start_line=%d,@ start_column=%d,@ \ + end_line=%d,@ end_column=%d,@ law_headings=%a))" (Pos.get_file pos) (Pos.get_start_line pos) (Pos.get_start_column pos) (Pos.get_end_line pos) (Pos.get_end_column pos) format_string_list (Pos.get_law_info pos) @@ -268,18 +269,15 @@ let rec format_expr (ctx : Dcalc.Ast.decl_ctx) (fmt : Format.formatter) (e : exp Format.fprintf fmt "%a%a" (Format.pp_print_list ~pp_sep:(fun fmt () -> Format.fprintf fmt "") - (fun fmt (x, tau, arg) -> - Format.fprintf fmt "@[let@ %a@ :@ %a@ =@ %a@]@ in@\n" format_var x format_typ - tau format_with_parens arg)) + (fun fmt (x, _, arg) -> Format.fprintf fmt "%a = %a@\n" format_var x format_expr arg)) xs_tau_arg format_with_parens body | EAbs ((binder, _), taus) -> let xs, body = Bindlib.unmbind binder in let xs_tau = List.map2 (fun x tau -> (x, tau)) (Array.to_list xs) taus in - Format.fprintf fmt "@[fun@ %a ->@ %a@]" + Format.fprintf fmt "@[lambda %a:@ %a@]" (Format.pp_print_list - ~pp_sep:(fun fmt () -> Format.fprintf fmt "@ ") - (fun fmt (x, tau) -> - Format.fprintf fmt "@[(%a:@ %a)@]" format_var x format_typ tau)) + ~pp_sep:(fun fmt () -> Format.fprintf fmt ", ") + (fun fmt (x, _) -> Format.fprintf fmt "%a" format_var x)) xs_tau format_expr body | EApp ((EOp (Binop ((Dcalc.Ast.Map | Dcalc.Ast.Filter) as op)), _), [ arg1; arg2 ]) -> Format.fprintf fmt "@[%a@ %a@ %a@]" format_binop (op, Pos.no_pos) format_with_parens @@ -307,88 +305,60 @@ let rec format_expr (ctx : Dcalc.Ast.decl_ctx) (fmt : Format.formatter) (e : exp | EApp ((EOp (Unop op), _), [ arg1 ]) -> Format.fprintf fmt "@[%a@ %a@]" format_unop (op, Pos.no_pos) format_with_parens arg1 | EApp (f, args) -> - Format.fprintf fmt "@[%a@ %a@]" format_with_parens f - (Format.pp_print_list ~pp_sep:(fun fmt () -> Format.fprintf fmt "@ ") format_with_parens) + Format.fprintf fmt "@[%a(%a)@]" format_with_parens f + (Format.pp_print_list ~pp_sep:(fun fmt () -> Format.fprintf fmt ",@ ") format_expr) args | EIfThenElse (e1, e2, e3) -> - Format.fprintf fmt "@[ if@ @[%a@]@ then@ @[%a@]@ else@ @[%a@]@]" - format_with_parens e1 format_with_parens e2 format_with_parens e3 + Format.fprintf fmt "@[%a@ if@ %a@ else@ %a@]" format_with_parens e2 format_with_parens + e1 format_with_parens e3 | EOp (Ternop op) -> Format.fprintf fmt "%a" format_ternop (op, Pos.no_pos) | EOp (Binop op) -> Format.fprintf fmt "%a" format_binop (op, Pos.no_pos) | EOp (Unop op) -> Format.fprintf fmt "%a" format_unop (op, Pos.no_pos) | EAssert e' -> Format.fprintf fmt "@[if @ %a@ then@ ()@ else@ raise AssertionFailed@]" format_with_parens e' - | ERaise exc -> Format.fprintf fmt "raise@ %a" format_exception (exc, Pos.get_position e) + | ERaise exc -> Format.fprintf fmt "raise_(%a)" format_exception (exc, Pos.get_position e) | ECatch (e1, exc, e2) -> - Format.fprintf fmt "@[try@ %a@ with@ %a@ ->@ %a@]" format_with_parens e1 + Format.fprintf fmt "@[TryCatch(%a).rescue(%a,@ lambda _: %a)@]" format_expr e1 format_exception (exc, Pos.get_position e) format_with_parens e2 -let format_struct_embedding (fmt : Format.formatter) - ((struct_name, struct_fields) : D.StructName.t * (D.StructFieldName.t * D.typ Pos.marked) list) - = - if List.length struct_fields = 0 then - Format.fprintf fmt "let embed_%a (_: %a) : runtime_value = Unit@\n@\n" format_struct_name - struct_name format_struct_name struct_name - else - Format.fprintf fmt - "@[let embed_%a (x: %a) : runtime_value =@ Struct([\"%a\"],@ @[[%a]@])@]@\n@\n" - format_struct_name struct_name format_struct_name struct_name D.StructName.format_t - struct_name - (Format.pp_print_list - ~pp_sep:(fun fmt () -> Format.fprintf fmt ";@\n") - (fun _fmt (struct_field, struct_field_type) -> - Format.fprintf fmt "(\"%a\",@ %a@ x.%a)" D.StructFieldName.format_t struct_field - typ_embedding_name struct_field_type format_struct_field_name struct_field)) - struct_fields - -let format_enum_embedding (fmt : Format.formatter) - ((enum_name, enum_cases) : D.EnumName.t * (D.EnumConstructor.t * D.typ Pos.marked) list) = - if List.length enum_cases = 0 then - Format.fprintf fmt "let embed_%a (_: %a) : runtime_value = Unit@\n@\n" format_enum_name - enum_name format_enum_name enum_name - else - Format.fprintf fmt - "@[let embed_%a (x: %a) : runtime_value =@ Enum([\"%a\"],@ @[match x with@ \ - %a@])@]@\n\ - @\n" - format_enum_name enum_name format_enum_name enum_name D.EnumName.format_t enum_name - (Format.pp_print_list - ~pp_sep:(fun fmt () -> Format.fprintf fmt "@\n") - (fun _fmt (enum_cons, enum_cons_type) -> - Format.fprintf fmt "@[| %a x ->@ (\"%a\", %a x)@]" format_enum_cons_name enum_cons - D.EnumConstructor.format_t enum_cons typ_embedding_name enum_cons_type)) - enum_cases - let format_ctx (type_ordering : Scopelang.Dependency.TVertex.t list) (fmt : Format.formatter) (ctx : D.decl_ctx) : unit = let format_struct_decl fmt (struct_name, struct_fields) = if List.length struct_fields = 0 then - Format.fprintf fmt "type %a = unit@\n@\n" format_struct_name struct_name + Format.fprintf fmt "class %a(Unit):@\n\tpass@\n@\n" format_struct_name struct_name else - Format.fprintf fmt "type %a = {@\n@[ %a@]@\n}@\n@\n" format_struct_name struct_name + Format.fprintf fmt "class %a:@\n\tdef __init__(self, %a) -> None:@\n%a@\n@\n" + format_struct_name struct_name + (Format.pp_print_list + ~pp_sep:(fun fmt () -> Format.fprintf fmt ", ") + (fun _fmt (struct_field, struct_field_type) -> + Format.fprintf fmt "%a: %a" format_struct_field_name struct_field format_typ + struct_field_type)) + struct_fields (Format.pp_print_list ~pp_sep:(fun fmt () -> Format.fprintf fmt "@\n") - (fun _fmt (struct_field, struct_field_type) -> - Format.fprintf fmt "%a:@ %a;" format_struct_field_name struct_field format_typ - struct_field_type)) - struct_fields; - if !Cli.trace_flag then format_struct_embedding fmt (struct_name, struct_fields) + (fun _fmt (struct_field, _) -> + Format.fprintf fmt "\t\tself.%a = %a" format_struct_field_name struct_field + format_struct_field_name struct_field)) + struct_fields in let format_enum_decl fmt (enum_name, enum_cons) = if List.length enum_cons = 0 then - Format.fprintf fmt "type %a = unit@\n@\n" format_enum_name enum_name + Format.fprintf fmt "class %a(Unit):@\n\tpass@\n@\n" format_enum_name enum_name else - Format.fprintf fmt "type %a =@\n@[ %a@]@\n@\n" format_enum_name enum_name + Format.fprintf fmt "class %a:@\n\tpass@\n@\n%a" format_enum_name enum_name (Format.pp_print_list - ~pp_sep:(fun fmt () -> Format.fprintf fmt "@\n") + ~pp_sep:(fun fmt () -> Format.fprintf fmt "@\n@\n") (fun _fmt (enum_cons, enum_cons_type) -> - Format.fprintf fmt "| %a@ of@ %a" format_enum_cons_name enum_cons format_typ - enum_cons_type)) - enum_cons; - if !Cli.trace_flag then format_enum_embedding fmt (enum_name, enum_cons) + Format.fprintf fmt + "class %a_%a(%a):@\n\ + \tdef __init__(self, value: %a) -> None:@\n\ + \t\tself.value = value" format_enum_name enum_name format_enum_cons_name enum_cons + format_enum_name enum_name format_typ enum_cons_type)) + enum_cons in let is_in_type_ordering s = List.exists @@ -421,7 +391,7 @@ let format_program (fmt : Format.formatter) (p : Ast.program) Format.fprintf fmt "# This file has been generated by the Catala compiler, do not edit!\n\ @\n\ - from catala_runtime import *@\n\ + from .catala_runtime import *@\n\ @\n\ %a@\n\ @\n\ @@ -430,5 +400,15 @@ let format_program (fmt : Format.formatter) (p : Ast.program) (Format.pp_print_list ~pp_sep:(fun fmt () -> Format.fprintf fmt "@\n@\n") (fun fmt (name, e) -> - Format.fprintf fmt "@[let@ %a@ =@ %a@]" format_var name (format_expr p.decl_ctx) e)) + match Pos.unmark e with + | EAbs ((binder, _), typs) -> + let vars, body = Bindlib.unmbind binder in + let vars_and_typs = List.map2 (fun var typ -> (var, typ)) (Array.to_list vars) typs in + Format.fprintf fmt "@[def %a(%a):@\n%a@]" format_var name + (Format.pp_print_list + ~pp_sep:(fun fmt () -> Format.fprintf fmt ", ") + (fun fmt (var, typ) -> Format.fprintf fmt "%a: %a" format_var var format_typ typ)) + vars_and_typs (format_expr p.decl_ctx) body + | _ -> assert false + (* should not happen*))) p.scopes diff --git a/examples/Makefile.common.mk b/examples/Makefile.common.mk index 57aeb3fd..24a77b7e 100644 --- a/examples/Makefile.common.mk +++ b/examples/Makefile.common.mk @@ -29,6 +29,13 @@ help : ../Makefile.common.mk OCaml \ $< +#> .py : Compiles the file to Python +%.py: %.catala_$(CATALA_LANG) + @$(CATALA) Makefile $< + $(CATALA) \ + Python \ + $< + #> .tex : Weaves the file to LaTeX %.tex: %.catala_$(CATALA_LANG) @$(CATALA) Makefile $< diff --git a/examples/allocations_familiales/.gitignore b/examples/allocations_familiales/.gitignore index 71eb6307..453bebd0 100644 --- a/examples/allocations_familiales/.gitignore +++ b/examples/allocations_familiales/.gitignore @@ -13,4 +13,5 @@ _minted* *.pyg *.d *.new -*.ml \ No newline at end of file +*.ml +*.py diff --git a/french_law/ocaml/law_source/allocations_familiales.ml b/french_law/ocaml/law_source/allocations_familiales.ml index ee026bb4..10f30996 100644 --- a/french_law/ocaml/law_source/allocations_familiales.ml +++ b/french_law/ocaml/law_source/allocations_familiales.ml @@ -11,28 +11,8 @@ type prise_en_charge = | ServicesSociauxAllocationVerseeALaFamille of unit | ServicesSociauxAllocationVerseeAuxServicesSociaux of unit -let embed_prise_en_charge (x : prise_en_charge) : runtime_value = - Enum - ( [ "PriseEnCharge" ], - match x with - | GardeAlterneePartageAllocations x -> ("GardeAlternéePartageAllocations", embed_unit x) - | GardeAlterneeAllocataireUnique x -> ("GardeAlternéeAllocataireUnique", embed_unit x) - | EffectiveEtPermanente x -> ("EffectiveEtPermanente", embed_unit x) - | ServicesSociauxAllocationVerseeALaFamille x -> - ("ServicesSociauxAllocationVerséeÀLaFamille", embed_unit x) - | ServicesSociauxAllocationVerseeAuxServicesSociaux x -> - ("ServicesSociauxAllocationVerséeAuxServicesSociaux", embed_unit x) ) - type situation_obligation_scolaire = Avant of unit | Pendant of unit | Apres of unit -let embed_situation_obligation_scolaire (x : situation_obligation_scolaire) : runtime_value = - Enum - ( [ "SituationObligationScolaire" ], - match x with - | Avant x -> ("Avant", embed_unit x) - | Pendant x -> ("Pendant", embed_unit x) - | Apres x -> ("Après", embed_unit x) ) - type collectivite = | Guadeloupe of unit | Guyane of unit @@ -44,40 +24,10 @@ type collectivite = | SaintPierreEtMiquelon of unit | Mayotte of unit -let embed_collectivite (x : collectivite) : runtime_value = - Enum - ( [ "Collectivité" ], - match x with - | Guadeloupe x -> ("Guadeloupe", embed_unit x) - | Guyane x -> ("Guyane", embed_unit x) - | Martinique x -> ("Martinique", embed_unit x) - | LaReunion x -> ("LaRéunion", embed_unit x) - | SaintBarthelemy x -> ("SaintBarthélemy", embed_unit x) - | SaintMartin x -> ("SaintMartin", embed_unit x) - | Metropole x -> ("Métropole", embed_unit x) - | SaintPierreEtMiquelon x -> ("SaintPierreEtMiquelon", embed_unit x) - | Mayotte x -> ("Mayotte", embed_unit x) ) - type prise_en_compte = Complete of unit | Partagee of unit | Zero of unit -let embed_prise_en_compte (x : prise_en_compte) : runtime_value = - Enum - ( [ "PriseEnCompte" ], - match x with - | Complete x -> ("Complète", embed_unit x) - | Partagee x -> ("Partagée", embed_unit x) - | Zero x -> ("Zéro", embed_unit x) ) - type versement_allocations = Normal of unit | AllocationVerseeAuxServicesSociaux of unit -let embed_versement_allocations (x : versement_allocations) : runtime_value = - Enum - ( [ "VersementAllocations" ], - match x with - | Normal x -> ("Normal", embed_unit x) - | AllocationVerseeAuxServicesSociaux x -> ("AllocationVerséeAuxServicesSociaux", embed_unit x) - ) - type element_prestations_familiales = | PrestationAccueilJeuneEnfant of unit | AllocationsFamiliales of unit @@ -88,21 +38,6 @@ type element_prestations_familiales = | AllocationRentreeScolaire of unit | AllocationJournalierePresenceParentale of unit -let embed_element_prestations_familiales (x : element_prestations_familiales) : runtime_value = - Enum - ( [ "ÉlémentPrestationsFamiliales" ], - match x with - | PrestationAccueilJeuneEnfant x -> ("PrestationAccueilJeuneEnfant", embed_unit x) - | AllocationsFamiliales x -> ("AllocationsFamiliales", embed_unit x) - | ComplementFamilial x -> ("ComplémentFamilial", embed_unit x) - | AllocationLogement x -> ("AllocationLogement", embed_unit x) - | AllocationEducationEnfantHandicape x -> - ("AllocationÉducationEnfantHandicapé", embed_unit x) - | AllocationSoutienFamilial x -> ("AllocationSoutienFamilial", embed_unit x) - | AllocationRentreeScolaire x -> ("AllocationRentréeScolaire", embed_unit x) - | AllocationJournalierePresenceParentale x -> - ("AllocationJournalièrePresenceParentale", embed_unit x) ) - type enfant_entree = { d_identifiant : integer; d_remuneration_mensuelle : money; @@ -111,18 +46,6 @@ type enfant_entree = { d_a_deja_ouvert_droit_aux_allocations_familiales : bool; } -let embed_enfant_entree (x : enfant_entree) : runtime_value = - Struct - ( [ "EnfantEntrée" ], - [ - ("d_identifiant", embed_integer x.d_identifiant); - ("d_rémuneration_mensuelle", embed_money x.d_remuneration_mensuelle); - ("d_date_de_naissance", embed_date x.d_date_de_naissance); - ("d_prise_en_charge", embed_prise_en_charge x.d_prise_en_charge); - ( "d_a_déjà_ouvert_droit_aux_allocations_familiales", - embed_bool x.d_a_deja_ouvert_droit_aux_allocations_familiales ); - ] ) - type enfant = { identifiant : integer; obligation_scolaire : situation_obligation_scolaire; @@ -133,46 +56,14 @@ type enfant = { a_deja_ouvert_droit_aux_allocations_familiales : bool; } -let embed_enfant (x : enfant) : runtime_value = - Struct - ( [ "Enfant" ], - [ - ("identifiant", embed_integer x.identifiant); - ("obligation_scolaire", embed_situation_obligation_scolaire x.obligation_scolaire); - ("rémuneration_mensuelle", embed_money x.remuneration_mensuelle); - ("date_de_naissance", embed_date x.date_de_naissance); - ("âge", embed_integer x.age); - ("prise_en_charge", embed_prise_en_charge x.prise_en_charge); - ( "a_déjà_ouvert_droit_aux_allocations_familiales", - embed_bool x.a_deja_ouvert_droit_aux_allocations_familiales ); - ] ) - type smic_out = { date_courante_out : date; residence_out : collectivite; brut_horaire_out : money } -let embed_smic_out (x : smic_out) : runtime_value = - Struct - ( [ "Smic_out" ], - [ - ("date_courante_out", embed_date x.date_courante_out); - ("résidence_out", embed_collectivite x.residence_out); - ("brut_horaire_out", embed_money x.brut_horaire_out); - ] ) - type smic_in = { date_courante_in : unit -> date; residence_in : unit -> collectivite; brut_horaire_in : unit -> money; } -let embed_smic_in (x : smic_in) : runtime_value = - Struct - ( [ "Smic_in" ], - [ - ("date_courante_in", unembeddable x.date_courante_in); - ("résidence_in", unembeddable x.residence_in); - ("brut_horaire_in", unembeddable x.brut_horaire_in); - ] ) - type prestations_familiales_out = { droit_ouvert_out : enfant -> bool; conditions_hors_age_out : enfant -> bool; @@ -185,21 +76,6 @@ type prestations_familiales_out = { base_mensuelle_out : money; } -let embed_prestations_familiales_out (x : prestations_familiales_out) : runtime_value = - Struct - ( [ "PrestationsFamiliales_out" ], - [ - ("droit_ouvert_out", unembeddable x.droit_ouvert_out); - ("conditions_hors_âge_out", unembeddable x.conditions_hors_age_out); - ("plafond_l512_3_2_out", embed_money x.plafond_l512_3_2_out); - ("âge_l512_3_2_out", embed_integer x.age_l512_3_2_out); - ("régime_outre_mer_l751_1_out", embed_bool x.regime_outre_mer_l751_1_out); - ("date_courante_out", embed_date x.date_courante_out); - ("prestation_courante_out", embed_element_prestations_familiales x.prestation_courante_out); - ("résidence_out", embed_collectivite x.residence_out); - ("base_mensuelle_out", embed_money x.base_mensuelle_out); - ] ) - type prestations_familiales_in = { droit_ouvert_in : unit -> enfant -> bool; conditions_hors_age_in : unit -> enfant -> bool; @@ -212,57 +88,14 @@ type prestations_familiales_in = { base_mensuelle_in : unit -> money; } -let embed_prestations_familiales_in (x : prestations_familiales_in) : runtime_value = - Struct - ( [ "PrestationsFamiliales_in" ], - [ - ("droit_ouvert_in", unembeddable x.droit_ouvert_in); - ("conditions_hors_âge_in", unembeddable x.conditions_hors_age_in); - ("plafond_l512_3_2_in", unembeddable x.plafond_l512_3_2_in); - ("âge_l512_3_2_in", unembeddable x.age_l512_3_2_in); - ("régime_outre_mer_l751_1_in", unembeddable x.regime_outre_mer_l751_1_in); - ("date_courante_in", unembeddable x.date_courante_in); - ("prestation_courante_in", unembeddable x.prestation_courante_in); - ("résidence_in", unembeddable x.residence_in); - ("base_mensuelle_in", unembeddable x.base_mensuelle_in); - ] ) - type allocation_familiales_avril2008_out = { age_minimum_alinea_1_l521_3_out : integer } -let embed_allocation_familiales_avril2008_out (x : allocation_familiales_avril2008_out) : - runtime_value = - Struct - ( [ "AllocationFamilialesAvril2008_out" ], - [ ("âge_minimum_alinéa_1_l521_3_out", embed_integer x.age_minimum_alinea_1_l521_3_out) ] ) - type allocation_familiales_avril2008_in = { age_minimum_alinea_1_l521_3_in : unit -> integer } -let embed_allocation_familiales_avril2008_in (x : allocation_familiales_avril2008_in) : - runtime_value = - Struct - ( [ "AllocationFamilialesAvril2008_in" ], - [ ("âge_minimum_alinéa_1_l521_3_in", unembeddable x.age_minimum_alinea_1_l521_3_in) ] ) - type enfant_le_plus_age_out = { enfants_out : enfant array; le_plus_age_out : enfant } -let embed_enfant_le_plus_age_out (x : enfant_le_plus_age_out) : runtime_value = - Struct - ( [ "EnfantLePlusÂgé_out" ], - [ - ("enfants_out", embed_array embed_enfant x.enfants_out); - ("le_plus_âgé_out", embed_enfant x.le_plus_age_out); - ] ) - type enfant_le_plus_age_in = { enfants_in : unit -> enfant array; le_plus_age_in : unit -> enfant } -let embed_enfant_le_plus_age_in (x : enfant_le_plus_age_in) : runtime_value = - Struct - ( [ "EnfantLePlusÂgé_in" ], - [ - ("enfants_in", unembeddable x.enfants_in); - ("le_plus_âgé_in", unembeddable x.le_plus_age_in); - ] ) - type allocations_familiales_out = { personne_charge_effective_permanente_est_parent_out : bool; personne_charge_effective_permanente_remplit_titre_I_out : bool; @@ -305,63 +138,6 @@ type allocations_familiales_out = { plafond_II_d521_3_out : money; } -let embed_allocations_familiales_out (x : allocations_familiales_out) : runtime_value = - Struct - ( [ "AllocationsFamiliales_out" ], - [ - ( "personne_charge_effective_permanente_est_parent_out", - embed_bool x.personne_charge_effective_permanente_est_parent_out ); - ( "personne_charge_effective_permanente_remplit_titre_I_out", - embed_bool x.personne_charge_effective_permanente_remplit_titre_I_out ); - ("ressources_ménage_out", embed_money x.ressources_menage_out); - ("résidence_out", embed_collectivite x.residence_out); - ("date_courante_out", embed_date x.date_courante_out); - ("enfants_à_charge_out", embed_array embed_enfant x.enfants_a_charge_out); - ( "enfants_à_charge_droit_ouvert_prestation_familiale_out", - embed_array embed_enfant x.enfants_a_charge_droit_ouvert_prestation_familiale_out ); - ("prise_en_compte_out", unembeddable x.prise_en_compte_out); - ("versement_out", unembeddable x.versement_out); - ("montant_versé_out", embed_money x.montant_verse_out); - ("droit_ouvert_base_out", embed_bool x.droit_ouvert_base_out); - ("montant_initial_base_out", embed_money x.montant_initial_base_out); - ( "montant_initial_base_premier_enfant_out", - embed_money x.montant_initial_base_premier_enfant_out ); - ( "montant_initial_base_deuxième_enfant_out", - embed_money x.montant_initial_base_deuxieme_enfant_out ); - ( "montant_initial_base_troisième_enfant_et_plus_out", - embed_money x.montant_initial_base_troisieme_enfant_et_plus_out ); - ("rapport_enfants_total_moyen_out", embed_decimal x.rapport_enfants_total_moyen_out); - ("nombre_moyen_enfants_out", embed_decimal x.nombre_moyen_enfants_out); - ("nombre_total_enfants_out", embed_decimal x.nombre_total_enfants_out); - ("montant_avec_garde_alternée_base_out", embed_money x.montant_avec_garde_alternee_base_out); - ("montant_versé_base_out", embed_money x.montant_verse_base_out); - ("droit_ouvert_forfaitaire_out", unembeddable x.droit_ouvert_forfaitaire_out); - ( "montant_versé_forfaitaire_par_enfant_out", - embed_money x.montant_verse_forfaitaire_par_enfant_out ); - ("montant_versé_forfaitaire_out", embed_money x.montant_verse_forfaitaire_out); - ("droit_ouvert_majoration_out", unembeddable x.droit_ouvert_majoration_out); - ( "montant_initial_métropole_majoration_out", - unembeddable x.montant_initial_metropole_majoration_out ); - ("montant_initial_majoration_out", unembeddable x.montant_initial_majoration_out); - ( "montant_avec_garde_alternée_majoration_out", - unembeddable x.montant_avec_garde_alternee_majoration_out ); - ("montant_versé_majoration_out", embed_money x.montant_verse_majoration_out); - ("droit_ouvert_complément_out", embed_bool x.droit_ouvert_complement_out); - ( "montant_base_complément_pour_base_et_majoration_out", - embed_money x.montant_base_complement_pour_base_et_majoration_out ); - ("complément_dégressif_out", unembeddable x.complement_degressif_out); - ( "montant_versé_complément_pour_base_et_majoration_out", - embed_money x.montant_verse_complement_pour_base_et_majoration_out ); - ( "montant_versé_complément_pour_forfaitaire_out", - embed_money x.montant_verse_complement_pour_forfaitaire_out ); - ("nombre_enfants_l521_1_out", embed_integer x.nombre_enfants_l521_1_out); - ("âge_minimum_alinéa_1_l521_3_out", unembeddable x.age_minimum_alinea_1_l521_3_out); - ("nombre_enfants_alinéa_2_l521_3_out", embed_integer x.nombre_enfants_alinea_2_l521_3_out); - ("est_enfant_le_plus_âgé_out", unembeddable x.est_enfant_le_plus_age_out); - ("plafond_I_d521_3_out", embed_money x.plafond_I_d521_3_out); - ("plafond_II_d521_3_out", embed_money x.plafond_II_d521_3_out); - ] ) - type allocations_familiales_in = { personne_charge_effective_permanente_est_parent_in : unit -> bool; personne_charge_effective_permanente_remplit_titre_I_in : unit -> bool; @@ -404,63 +180,6 @@ type allocations_familiales_in = { plafond_II_d521_3_in : unit -> money; } -let embed_allocations_familiales_in (x : allocations_familiales_in) : runtime_value = - Struct - ( [ "AllocationsFamiliales_in" ], - [ - ( "personne_charge_effective_permanente_est_parent_in", - unembeddable x.personne_charge_effective_permanente_est_parent_in ); - ( "personne_charge_effective_permanente_remplit_titre_I_in", - unembeddable x.personne_charge_effective_permanente_remplit_titre_I_in ); - ("ressources_ménage_in", unembeddable x.ressources_menage_in); - ("résidence_in", unembeddable x.residence_in); - ("date_courante_in", unembeddable x.date_courante_in); - ("enfants_à_charge_in", unembeddable x.enfants_a_charge_in); - ( "enfants_à_charge_droit_ouvert_prestation_familiale_in", - unembeddable x.enfants_a_charge_droit_ouvert_prestation_familiale_in ); - ("prise_en_compte_in", unembeddable x.prise_en_compte_in); - ("versement_in", unembeddable x.versement_in); - ("montant_versé_in", unembeddable x.montant_verse_in); - ("droit_ouvert_base_in", unembeddable x.droit_ouvert_base_in); - ("montant_initial_base_in", unembeddable x.montant_initial_base_in); - ( "montant_initial_base_premier_enfant_in", - unembeddable x.montant_initial_base_premier_enfant_in ); - ( "montant_initial_base_deuxième_enfant_in", - unembeddable x.montant_initial_base_deuxieme_enfant_in ); - ( "montant_initial_base_troisième_enfant_et_plus_in", - unembeddable x.montant_initial_base_troisieme_enfant_et_plus_in ); - ("rapport_enfants_total_moyen_in", unembeddable x.rapport_enfants_total_moyen_in); - ("nombre_moyen_enfants_in", unembeddable x.nombre_moyen_enfants_in); - ("nombre_total_enfants_in", unembeddable x.nombre_total_enfants_in); - ("montant_avec_garde_alternée_base_in", unembeddable x.montant_avec_garde_alternee_base_in); - ("montant_versé_base_in", unembeddable x.montant_verse_base_in); - ("droit_ouvert_forfaitaire_in", unembeddable x.droit_ouvert_forfaitaire_in); - ( "montant_versé_forfaitaire_par_enfant_in", - unembeddable x.montant_verse_forfaitaire_par_enfant_in ); - ("montant_versé_forfaitaire_in", unembeddable x.montant_verse_forfaitaire_in); - ("droit_ouvert_majoration_in", unembeddable x.droit_ouvert_majoration_in); - ( "montant_initial_métropole_majoration_in", - unembeddable x.montant_initial_metropole_majoration_in ); - ("montant_initial_majoration_in", unembeddable x.montant_initial_majoration_in); - ( "montant_avec_garde_alternée_majoration_in", - unembeddable x.montant_avec_garde_alternee_majoration_in ); - ("montant_versé_majoration_in", unembeddable x.montant_verse_majoration_in); - ("droit_ouvert_complément_in", unembeddable x.droit_ouvert_complement_in); - ( "montant_base_complément_pour_base_et_majoration_in", - unembeddable x.montant_base_complement_pour_base_et_majoration_in ); - ("complément_dégressif_in", unembeddable x.complement_degressif_in); - ( "montant_versé_complément_pour_base_et_majoration_in", - unembeddable x.montant_verse_complement_pour_base_et_majoration_in ); - ( "montant_versé_complément_pour_forfaitaire_in", - unembeddable x.montant_verse_complement_pour_forfaitaire_in ); - ("nombre_enfants_l521_1_in", unembeddable x.nombre_enfants_l521_1_in); - ("âge_minimum_alinéa_1_l521_3_in", unembeddable x.age_minimum_alinea_1_l521_3_in); - ("nombre_enfants_alinéa_2_l521_3_in", unembeddable x.nombre_enfants_alinea_2_l521_3_in); - ("est_enfant_le_plus_âgé_in", unembeddable x.est_enfant_le_plus_age_in); - ("plafond_I_d521_3_in", unembeddable x.plafond_I_d521_3_in); - ("plafond_II_d521_3_in", unembeddable x.plafond_II_d521_3_in); - ] ) - type interface_allocations_familiales_out = { date_courante_out : date; enfants_out : enfant_entree array; @@ -472,23 +191,6 @@ type interface_allocations_familiales_out = { personne_charge_effective_permanente_remplit_titre_I_out : bool; } -let embed_interface_allocations_familiales_out (x : interface_allocations_familiales_out) : - runtime_value = - Struct - ( [ "InterfaceAllocationsFamiliales_out" ], - [ - ("date_courante_out", embed_date x.date_courante_out); - ("enfants_out", embed_array embed_enfant_entree x.enfants_out); - ("enfants_à_charge_out", embed_array embed_enfant x.enfants_a_charge_out); - ("ressources_ménage_out", embed_money x.ressources_menage_out); - ("résidence_out", embed_collectivite x.residence_out); - ("montant_versé_out", embed_money x.montant_verse_out); - ( "personne_charge_effective_permanente_est_parent_out", - embed_bool x.personne_charge_effective_permanente_est_parent_out ); - ( "personne_charge_effective_permanente_remplit_titre_I_out", - embed_bool x.personne_charge_effective_permanente_remplit_titre_I_out ); - ] ) - type interface_allocations_familiales_in = { date_courante_in : unit -> date; enfants_in : unit -> enfant_entree array; @@ -500,232 +202,112 @@ type interface_allocations_familiales_in = { personne_charge_effective_permanente_remplit_titre_I_in : unit -> bool; } -let embed_interface_allocations_familiales_in (x : interface_allocations_familiales_in) : - runtime_value = - Struct - ( [ "InterfaceAllocationsFamiliales_in" ], - [ - ("date_courante_in", unembeddable x.date_courante_in); - ("enfants_in", unembeddable x.enfants_in); - ("enfants_à_charge_in", unembeddable x.enfants_a_charge_in); - ("ressources_ménage_in", unembeddable x.ressources_menage_in); - ("résidence_in", unembeddable x.residence_in); - ("montant_versé_in", unembeddable x.montant_verse_in); - ( "personne_charge_effective_permanente_est_parent_in", - unembeddable x.personne_charge_effective_permanente_est_parent_in ); - ( "personne_charge_effective_permanente_remplit_titre_I_in", - unembeddable x.personne_charge_effective_permanente_remplit_titre_I_in ); - ] ) - let smic (smic_in : smic_in) = let date_courante_ : unit -> date = smic_in.date_courante_in in let residence_ : unit -> collectivite = smic_in.residence_in in let brut_horaire_ : unit -> money = smic_in.brut_horaire_in in let date_courante_ : date = - log_variable_definition [ "Smic"; "date_courante" ] embed_date - (try date_courante_ () - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 42; - start_column = 12; - end_line = 42; - end_column = 25; - law_headings = [ "Prologue" ]; - })) + try date_courante_ () + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 42; + start_column = 12; + end_line = 42; + end_column = 25; + law_headings = [ "Prologue" ]; + }) in let residence_ : collectivite = - log_variable_definition [ "Smic"; "résidence" ] embed_collectivite - (try residence_ () - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 43; - start_column = 12; - end_line = 43; - end_column = 21; - law_headings = [ "Prologue" ]; - })) + try residence_ () + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 43; + start_column = 12; + end_line = 43; + end_column = 21; + law_headings = [ "Prologue" ]; + }) in let brut_horaire_ : money = - log_variable_definition [ "Smic"; "brut_horaire" ] embed_money - (try - try brut_horaire_ () - with EmptyError -> - handle_default - [| - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./decrets_divers.catala_fr"; - start_line = 313; - start_column = 5; - end_line = 315; - end_column = 6; - law_headings = - [ - "Article 1"; - "Décret n° 2020-1598 du 16 décembre 2020 portant relèvement du \ - salaire minimum de croissance"; - "Montant du salaire minimum de croissance"; - ]; - } - (date_courante_ >=@ date_of_numbers 2021 1 1 - && date_courante_ <=@ date_of_numbers 2021 12 31 - && residence_ = Mayotte ()) - then money_of_cents_string "774" - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./decrets_divers.catala_fr"; - start_line = 295; - start_column = 5; - end_line = 304; - end_column = 6; - law_headings = - [ - "Article 1"; - "Décret n° 2020-1598 du 16 décembre 2020 portant relèvement du \ - salaire minimum de croissance"; - "Montant du salaire minimum de croissance"; - ]; - } - (date_courante_ >=@ date_of_numbers 2021 1 1 - && date_courante_ <=@ date_of_numbers 2021 12 31 - && (residence_ = Metropole () || residence_ = Guadeloupe () - || residence_ = Guyane () || residence_ = Martinique () - || residence_ = LaReunion () || residence_ = SaintBarthelemy () - || residence_ = SaintMartin () - || residence_ = SaintPierreEtMiquelon ())) - then money_of_cents_string "1025" - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./decrets_divers.catala_fr"; - start_line = 274; - start_column = 5; - end_line = 276; - end_column = 6; - law_headings = - [ - "Article 1"; - "Décret n° 2019-1387 du 18 décembre 2019 portant relèvement du \ - salaire minimum de croissance"; - "Montant du salaire minimum de croissance"; - ]; - } - (date_courante_ >=@ date_of_numbers 2020 1 1 - && date_courante_ <=@ date_of_numbers 2020 12 31 - && residence_ = Mayotte ()) - then money_of_cents_string "766" - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./decrets_divers.catala_fr"; - start_line = 256; - start_column = 5; - end_line = 265; - end_column = 6; - law_headings = - [ - "Article 1"; - "Décret n° 2019-1387 du 18 décembre 2019 portant relèvement du \ - salaire minimum de croissance"; - "Montant du salaire minimum de croissance"; - ]; - } - (date_courante_ >=@ date_of_numbers 2020 1 1 - && date_courante_ <=@ date_of_numbers 2020 12 31 - && (residence_ = Metropole () || residence_ = Guadeloupe () - || residence_ = Guyane () || residence_ = Martinique () - || residence_ = LaReunion () || residence_ = SaintBarthelemy () - || residence_ = SaintMartin () - || residence_ = SaintPierreEtMiquelon ())) - then money_of_cents_string "1015" - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./decrets_divers.catala_fr"; - start_line = 235; - start_column = 5; - end_line = 237; - end_column = 6; - law_headings = - [ - "Article 1"; - "Décret n° 2018-1173 du 19 décembre 2018 portant relèvement du \ - salaire minimum de croissance"; - "Montant du salaire minimum de croissance"; - ]; - } - (date_courante_ >=@ date_of_numbers 2019 1 1 - && date_courante_ <=@ date_of_numbers 2019 12 31 - && residence_ = Mayotte ()) - then money_of_cents_string "757" - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./decrets_divers.catala_fr"; - start_line = 217; - start_column = 5; - end_line = 226; - end_column = 6; - law_headings = - [ - "Article 1"; - "Décret n° 2018-1173 du 19 décembre 2018 portant relèvement du \ - salaire minimum de croissance"; - "Montant du salaire minimum de croissance"; - ]; - } - (date_courante_ >=@ date_of_numbers 2019 1 1 - && date_courante_ <=@ date_of_numbers 2019 12 31 - && (residence_ = Metropole () || residence_ = Guadeloupe () - || residence_ = Guyane () || residence_ = Martinique () - || residence_ = LaReunion () || residence_ = SaintBarthelemy () - || residence_ = SaintMartin () - || residence_ = SaintPierreEtMiquelon ())) - then money_of_cents_string "1003" - else raise EmptyError); - |] - (fun (_ : _) -> - log_decision_taken - { - filename = ""; - start_line = 0; - start_column = 1; - end_line = 0; - end_column = 1; - law_headings = []; - } - false) - (fun (_ : _) -> raise EmptyError) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 44; - start_column = 12; - end_line = 44; - end_column = 24; - law_headings = [ "Prologue" ]; - })) + try + try brut_horaire_ () + with EmptyError -> + handle_default + [| + (fun (_ : _) -> + if + date_courante_ >=@ date_of_numbers 2021 1 1 + && date_courante_ <=@ date_of_numbers 2021 12 31 + && residence_ = Mayotte () + then money_of_cents_string "774" + else raise EmptyError); + (fun (_ : _) -> + if + date_courante_ >=@ date_of_numbers 2021 1 1 + && date_courante_ <=@ date_of_numbers 2021 12 31 + && (residence_ = Metropole () || residence_ = Guadeloupe () + || residence_ = Guyane () || residence_ = Martinique () + || residence_ = LaReunion () || residence_ = SaintBarthelemy () + || residence_ = SaintMartin () + || residence_ = SaintPierreEtMiquelon ()) + then money_of_cents_string "1025" + else raise EmptyError); + (fun (_ : _) -> + if + date_courante_ >=@ date_of_numbers 2020 1 1 + && date_courante_ <=@ date_of_numbers 2020 12 31 + && residence_ = Mayotte () + then money_of_cents_string "766" + else raise EmptyError); + (fun (_ : _) -> + if + date_courante_ >=@ date_of_numbers 2020 1 1 + && date_courante_ <=@ date_of_numbers 2020 12 31 + && (residence_ = Metropole () || residence_ = Guadeloupe () + || residence_ = Guyane () || residence_ = Martinique () + || residence_ = LaReunion () || residence_ = SaintBarthelemy () + || residence_ = SaintMartin () + || residence_ = SaintPierreEtMiquelon ()) + then money_of_cents_string "1015" + else raise EmptyError); + (fun (_ : _) -> + if + date_courante_ >=@ date_of_numbers 2019 1 1 + && date_courante_ <=@ date_of_numbers 2019 12 31 + && residence_ = Mayotte () + then money_of_cents_string "757" + else raise EmptyError); + (fun (_ : _) -> + if + date_courante_ >=@ date_of_numbers 2019 1 1 + && date_courante_ <=@ date_of_numbers 2019 12 31 + && (residence_ = Metropole () || residence_ = Guadeloupe () + || residence_ = Guyane () || residence_ = Martinique () + || residence_ = LaReunion () || residence_ = SaintBarthelemy () + || residence_ = SaintMartin () + || residence_ = SaintPierreEtMiquelon ()) + then money_of_cents_string "1003" + else raise EmptyError); + |] + (fun (_ : _) -> false) + (fun (_ : _) -> raise EmptyError) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 44; + start_column = 12; + end_line = 44; + end_column = 24; + law_headings = [ "Prologue" ]; + }) in { date_courante_out = date_courante_; @@ -739,21 +321,18 @@ let allocation_familiales_avril2008 allocation_familiales_avril2008_in.age_minimum_alinea_1_l521_3_in in let age_minimum_alinea_1_l521_3_ : integer = - log_variable_definition - [ "AllocationFamilialesAvril2008"; "âge_minimum_alinéa_1_l521_3" ] - embed_integer - (try try age_minimum_alinea_1_l521_3_ () with EmptyError -> integer_of_string "16" - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 82; - start_column = 12; - end_line = 82; - end_column = 39; - law_headings = [ "Prologue" ]; - })) + try try age_minimum_alinea_1_l521_3_ () with EmptyError -> integer_of_string "16" + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 82; + start_column = 12; + end_line = 82; + end_column = 39; + law_headings = [ "Prologue" ]; + }) in { age_minimum_alinea_1_l521_3_out = age_minimum_alinea_1_l521_3_ } @@ -761,54 +340,48 @@ let enfant_le_plus_age (enfant_le_plus_age_in : enfant_le_plus_age_in) = let enfants_ : unit -> enfant array = enfant_le_plus_age_in.enfants_in in let le_plus_age_ : unit -> enfant = enfant_le_plus_age_in.le_plus_age_in in let enfants_ : enfant array = - log_variable_definition - [ "EnfantLePlusÂgé"; "enfants" ] - (embed_array embed_enfant) - (try enfants_ () - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 85; - start_column = 12; - end_line = 85; - end_column = 19; - law_headings = [ "Prologue" ]; - })) + try enfants_ () + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 85; + start_column = 12; + end_line = 85; + end_column = 19; + law_headings = [ "Prologue" ]; + }) in let le_plus_age_ : enfant = - log_variable_definition - [ "EnfantLePlusÂgé"; "le_plus_âgé" ] - embed_enfant - (try - try le_plus_age_ () - with EmptyError -> - let predicate_ : _ = fun (potentiel_plus_age_ : _) -> potentiel_plus_age_.age in - Array.fold_left - (fun (acc_ : _) (item_ : _) -> - if predicate_ acc_ >! predicate_ item_ then acc_ else item_) - { - identifiant = ~-!(integer_of_string "1"); - obligation_scolaire = Pendant (); - remuneration_mensuelle = money_of_cents_string "0"; - date_de_naissance = date_of_numbers 1900 1 1; - age = integer_of_string "0"; - prise_en_charge = EffectiveEtPermanente (); - a_deja_ouvert_droit_aux_allocations_familiales = false; - } - enfants_ - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 86; - start_column = 12; - end_line = 86; - end_column = 23; - law_headings = [ "Prologue" ]; - })) + try + try le_plus_age_ () + with EmptyError -> + let predicate_ : _ = fun (potentiel_plus_age_ : _) -> potentiel_plus_age_.age in + Array.fold_left + (fun (acc_ : _) (item_ : _) -> + if predicate_ acc_ >! predicate_ item_ then acc_ else item_) + { + identifiant = ~-!(integer_of_string "1"); + obligation_scolaire = Pendant (); + remuneration_mensuelle = money_of_cents_string "0"; + date_de_naissance = date_of_numbers 1900 1 1; + age = integer_of_string "0"; + prise_en_charge = EffectiveEtPermanente (); + a_deja_ouvert_droit_aux_allocations_familiales = false; + } + enfants_ + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 86; + start_column = 12; + end_line = 86; + end_column = 23; + law_headings = [ "Prologue" ]; + }) in { enfants_out = enfants_; le_plus_age_out = le_plus_age_ } @@ -829,459 +402,262 @@ let prestations_familiales (prestations_familiales_in : prestations_familiales_i let residence_ : unit -> collectivite = prestations_familiales_in.residence_in in let base_mensuelle_ : unit -> money = prestations_familiales_in.base_mensuelle_in in let age_l512_3_2_ : integer = - log_variable_definition - [ "PrestationsFamiliales"; "âge_l512_3_2" ] - embed_integer - (try try age_l512_3_2_ () with EmptyError -> integer_of_string "20" - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 69; - start_column = 12; - end_line = 69; - end_column = 24; - law_headings = [ "Prologue" ]; - })) + try try age_l512_3_2_ () with EmptyError -> integer_of_string "20" + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 69; + start_column = 12; + end_line = 69; + end_column = 24; + law_headings = [ "Prologue" ]; + }) in let date_courante_ : date = - log_variable_definition - [ "PrestationsFamiliales"; "date_courante" ] - embed_date - (try date_courante_ () - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 71; - start_column = 12; - end_line = 71; - end_column = 25; - law_headings = [ "Prologue" ]; - })) + try date_courante_ () + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 71; + start_column = 12; + end_line = 71; + end_column = 25; + law_headings = [ "Prologue" ]; + }) in let prestation_courante_ : element_prestations_familiales = - log_variable_definition - [ "PrestationsFamiliales"; "prestation_courante" ] - embed_element_prestations_familiales - (try prestation_courante_ () - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 72; - start_column = 12; - end_line = 72; - end_column = 31; - law_headings = [ "Prologue" ]; - })) + try prestation_courante_ () + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 72; + start_column = 12; + end_line = 72; + end_column = 31; + law_headings = [ "Prologue" ]; + }) in let residence_ : collectivite = - log_variable_definition - [ "PrestationsFamiliales"; "résidence" ] - embed_collectivite - (try residence_ () - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 73; - start_column = 12; - end_line = 73; - end_column = 21; - law_headings = [ "Prologue" ]; - })) + try residence_ () + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 73; + start_column = 12; + end_line = 73; + end_column = 21; + law_headings = [ "Prologue" ]; + }) in let base_mensuelle_ : money = - log_variable_definition - [ "PrestationsFamiliales"; "base_mensuelle" ] - embed_money - (try - try base_mensuelle_ () - with EmptyError -> - handle_default - [| - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./decrets_divers.catala_fr"; - start_line = 58; - start_column = 5; - end_line = 59; - end_column = 34; - law_headings = - [ - "Instruction interministérielle n°DSS/2B/2021/65 du 19 mars 2021 \ - relative à la revalorisation au 1er avril 2021 des prestations \ - familiales servies en métropole, en Guadeloupe, en Guyane, en \ - Martinique, à la Réunion, à Saint-Barthélemy, à Saint-Martin et \ - dans le département de Mayotte"; - "Montant de la base mensuelle des allocations familiales"; - ]; - } - (date_courante_ >=@ date_of_numbers 2021 4 1 - && date_courante_ <@ date_of_numbers 2022 4 1) - then money_of_cents_string "41481" - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./decrets_divers.catala_fr"; - start_line = 42; - start_column = 5; - end_line = 43; - end_column = 34; - law_headings = - [ - "Instruction interministérielle no DSS/SD2B/2020/33 du 18 février \ - 2020 relative à la revalorisation au 1er avril 2020 des prestations \ - familiales servies en métropole, en Guadeloupe, en Guyane, en \ - Martinique, à La Réunion, à Saint-Barthélemy, à Saint-Martin et \ - dans le département de Mayotte"; - "Montant de la base mensuelle des allocations familiales"; - ]; - } - (date_courante_ >=@ date_of_numbers 2020 4 1 - && date_courante_ <@ date_of_numbers 2021 4 1) - then money_of_cents_string "41404" - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./decrets_divers.catala_fr"; - start_line = 22; - start_column = 5; - end_line = 23; - end_column = 34; - law_headings = - [ - "Instruction ministérielle N°DSS/SD2B/2019/65 du 25 mars 2019 \ - relative à la revalorisation au 1er avril 2019 des prestations \ - familiales servies en métropole"; - "Montant de la base mensuelle des allocations familiales"; - ]; - } - (date_courante_ >=@ date_of_numbers 2019 4 1 - && date_courante_ <@ date_of_numbers 2020 4 1) - then money_of_cents_string "41316" - else raise EmptyError); - |] - (fun (_ : _) -> - log_decision_taken - { - filename = ""; - start_line = 0; - start_column = 1; - end_line = 0; - end_column = 1; - law_headings = []; - } - false) - (fun (_ : _) -> raise EmptyError) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 75; - start_column = 12; - end_line = 75; - end_column = 26; - law_headings = [ "Prologue" ]; - })) - in - let smic_dot_date_courante_ : unit -> date = - fun (_ : unit) -> - log_variable_definition - [ "PrestationsFamiliales"; "smic.date_courante" ] - embed_date date_courante_ - in - let smic_dot_residence_ : unit -> collectivite = - fun (_ : unit) -> - log_variable_definition - [ "PrestationsFamiliales"; "smic.résidence" ] - embed_collectivite residence_ + try + try base_mensuelle_ () + with EmptyError -> + handle_default + [| + (fun (_ : _) -> + if + date_courante_ >=@ date_of_numbers 2021 4 1 + && date_courante_ <@ date_of_numbers 2022 4 1 + then money_of_cents_string "41481" + else raise EmptyError); + (fun (_ : _) -> + if + date_courante_ >=@ date_of_numbers 2020 4 1 + && date_courante_ <@ date_of_numbers 2021 4 1 + then money_of_cents_string "41404" + else raise EmptyError); + (fun (_ : _) -> + if + date_courante_ >=@ date_of_numbers 2019 4 1 + && date_courante_ <@ date_of_numbers 2020 4 1 + then money_of_cents_string "41316" + else raise EmptyError); + |] + (fun (_ : _) -> false) + (fun (_ : _) -> raise EmptyError) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 75; + start_column = 12; + end_line = 75; + end_column = 26; + law_headings = [ "Prologue" ]; + }) in + let smic_dot_date_courante_ : unit -> date = fun (_ : unit) -> date_courante_ in + let smic_dot_residence_ : unit -> collectivite = fun (_ : unit) -> residence_ in let result_ : smic_out = - log_end_call - [ "PrestationsFamiliales"; "smic"; "Smic" ] - (log_begin_call - [ "PrestationsFamiliales"; "smic"; "Smic" ] - smic - { - date_courante_in = smic_dot_date_courante_; - residence_in = smic_dot_residence_; - brut_horaire_in = (fun (_ : unit) -> raise EmptyError); - }) + smic + { + date_courante_in = smic_dot_date_courante_; + residence_in = smic_dot_residence_; + brut_horaire_in = (fun (_ : unit) -> raise EmptyError); + } in let smic_dot_date_courante_ : date = result_.date_courante_out in let smic_dot_residence_ : collectivite = result_.residence_out in let smic_dot_brut_horaire_ : money = result_.brut_horaire_out in let regime_outre_mer_l751_1_ : bool = - log_variable_definition - [ "PrestationsFamiliales"; "régime_outre_mer_l751_1" ] - embed_bool - (try - try regime_outre_mer_l751_1_ () - with EmptyError -> ( - try - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 354; - start_column = 5; - end_line = 359; - end_column = 30; - law_headings = - [ - "Article L751-1"; - "Chapitre 1er : Généralités"; - "Titre 5 : Dispositions particulières à la Guadeloupe, à la Guyane, à \ - la Martinique, à La Réunion, à Saint-Barthélemy et à Saint-Martin"; - "Livre 7 : Régimes divers - Dispositions diverses"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - (residence_ = Guadeloupe () || residence_ = Guyane () || residence_ = Martinique () - || residence_ = LaReunion () || residence_ = SaintBarthelemy () - || residence_ = SaintMartin ()) - then true - else raise EmptyError - with EmptyError -> false) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 70; - start_column = 12; - end_line = 70; - end_column = 35; - law_headings = [ "Prologue" ]; - })) + try + try regime_outre_mer_l751_1_ () + with EmptyError -> ( + try + if + residence_ = Guadeloupe () || residence_ = Guyane () || residence_ = Martinique () + || residence_ = LaReunion () || residence_ = SaintBarthelemy () + || residence_ = SaintMartin () + then true + else raise EmptyError + with EmptyError -> false) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 70; + start_column = 12; + end_line = 70; + end_column = 35; + law_headings = [ "Prologue" ]; + }) in let plafond_l512_3_2_ : money = - log_variable_definition - [ "PrestationsFamiliales"; "plafond_l512_3_2" ] - embed_money - (try - try plafond_l512_3_2_ () - with EmptyError -> ( - try - if - log_decision_taken - { - filename = "./securite_sociale_R.catala_fr"; - start_line = 216; - start_column = 18; - end_line = 216; - end_column = 41; - law_headings = - [ - "Article R755-0-2"; - "Chapitre 5 : Prestations familiales et prestations assimilées"; - "Titre 5 : Départements d'outre-mer"; - "Livre 7 : Régimes divers - Dispositions diverses"; - "Partie réglementaire - Décrets en Conseil d'Etat"; - "Code de la sécurité sociale"; - ]; - } - regime_outre_mer_l751_1_ - then smic_dot_brut_horaire_ *$ decimal_of_string "0.55" *$ decimal_of_string "169." - else raise EmptyError - with EmptyError -> - smic_dot_brut_horaire_ *$ decimal_of_string "0.55" *$ decimal_of_string "169.") - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 68; - start_column = 12; - end_line = 68; - end_column = 28; - law_headings = [ "Prologue" ]; - })) + try + try plafond_l512_3_2_ () + with EmptyError -> ( + try + if regime_outre_mer_l751_1_ then + smic_dot_brut_horaire_ *$ decimal_of_string "0.55" *$ decimal_of_string "169." + else raise EmptyError + with EmptyError -> + smic_dot_brut_horaire_ *$ decimal_of_string "0.55" *$ decimal_of_string "169.") + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 68; + start_column = 12; + end_line = 68; + end_column = 28; + law_headings = [ "Prologue" ]; + }) in let conditions_hors_age_ : enfant -> bool = - log_variable_definition - [ "PrestationsFamiliales"; "conditions_hors_âge" ] - unembeddable - (try - try conditions_hors_age_ () - with EmptyError -> ( - fun (param_ : enfant) -> - try - try - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 68; - start_column = 5; - end_line = 71; - end_column = 57; - law_headings = - [ - "Article L512-3"; - "Chapitre 2 : Champ d'application"; - "Titre 1 : Champ d'application - Généralités"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - ((match param_.obligation_scolaire with - | Avant _ -> true - | Pendant _ -> false - | Apres _ -> false) - || (match param_.obligation_scolaire with - | Avant _ -> false - | Pendant _ -> true - | Apres _ -> false) - || (match param_.obligation_scolaire with - | Avant _ -> false - | Pendant _ -> false - | Apres _ -> true) - && param_.remuneration_mensuelle <=$ plafond_l512_3_2_) - then true - else raise EmptyError - with EmptyError -> false - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 67; - start_column = 12; - end_line = 67; - end_column = 31; - law_headings = [ "Prologue" ]; - })) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 67; - start_column = 12; - end_line = 67; - end_column = 31; - law_headings = [ "Prologue" ]; - })) + try + try conditions_hors_age_ () + with EmptyError -> ( + fun (param_ : enfant) -> + try + try + if + (match param_.obligation_scolaire with + | Avant _ -> true + | Pendant _ -> false + | Apres _ -> false) + || (match param_.obligation_scolaire with + | Avant _ -> false + | Pendant _ -> true + | Apres _ -> false) + || (match param_.obligation_scolaire with + | Avant _ -> false + | Pendant _ -> false + | Apres _ -> true) + && param_.remuneration_mensuelle <=$ plafond_l512_3_2_ + then true + else raise EmptyError + with EmptyError -> false + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 67; + start_column = 12; + end_line = 67; + end_column = 31; + law_headings = [ "Prologue" ]; + })) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 67; + start_column = 12; + end_line = 67; + end_column = 31; + law_headings = [ "Prologue" ]; + }) in let droit_ouvert_ : enfant -> bool = - log_variable_definition - [ "PrestationsFamiliales"; "droit_ouvert" ] - unembeddable - (try - try droit_ouvert_ () - with EmptyError -> ( - fun (param_ : enfant) -> - try - handle_default - [| - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 60; - start_column = 5; - end_line = 62; - end_column = 32; - law_headings = - [ - "Article L512-3"; - "Chapitre 2 : Champ d'application"; - "Titre 1 : Champ d'application - Généralités"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - ((match param_.obligation_scolaire with - | Avant _ -> false - | Pendant _ -> false - | Apres _ -> true) - && param_.remuneration_mensuelle <=$ plafond_l512_3_2_ - && param_.age - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 49; - start_column = 5; - end_line = 50; - end_column = 50; - law_headings = - [ - "Article L512-3"; - "Chapitre 2 : Champ d'application"; - "Titre 1 : Champ d'application - Généralités"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - ((match param_.obligation_scolaire with - | Avant _ -> true - | Pendant _ -> false - | Apres _ -> false) - || - match param_.obligation_scolaire with - | Avant _ -> false - | Pendant _ -> true - | Apres _ -> false) - then true - else raise EmptyError); - |] - (fun (_ : _) -> - log_decision_taken - { - filename = ""; - start_line = 0; - start_column = 1; - end_line = 0; - end_column = 1; - law_headings = []; - } - true) - (fun (_ : _) -> false) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 66; - start_column = 12; - end_line = 66; - end_column = 24; - law_headings = [ "Prologue" ]; - })) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 66; - start_column = 12; - end_line = 66; - end_column = 24; - law_headings = [ "Prologue" ]; - })) + try + try droit_ouvert_ () + with EmptyError -> ( + fun (param_ : enfant) -> + try + handle_default + [| + (fun (_ : _) -> + if + (match param_.obligation_scolaire with + | Avant _ -> false + | Pendant _ -> false + | Apres _ -> true) + && param_.remuneration_mensuelle <=$ plafond_l512_3_2_ + && param_.age + if + (match param_.obligation_scolaire with + | Avant _ -> true + | Pendant _ -> false + | Apres _ -> false) + || + match param_.obligation_scolaire with + | Avant _ -> false + | Pendant _ -> true + | Apres _ -> false + then true + else raise EmptyError); + |] + (fun (_ : _) -> true) + (fun (_ : _) -> false) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 66; + start_column = 12; + end_line = 66; + end_column = 24; + law_headings = [ "Prologue" ]; + })) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 66; + start_column = 12; + end_line = 66; + end_column = 24; + law_headings = [ "Prologue" ]; + }) in { droit_ouvert_out = droit_ouvert_; @@ -1390,551 +766,310 @@ let allocations_familiales (allocations_familiales_in : allocations_familiales_i let plafond__i_d521_3_ : unit -> money = allocations_familiales_in.plafond_I_d521_3_in in let plafond__i_i_d521_3_ : unit -> money = allocations_familiales_in.plafond_II_d521_3_in in let personne_charge_effective_permanente_est_parent_ : bool = - log_variable_definition - [ "AllocationsFamiliales"; "personne_charge_effective_permanente_est_parent" ] - embed_bool - (try try personne_charge_effective_permanente_est_parent_ () with EmptyError -> false - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 91; - start_column = 12; - end_line = 91; - end_column = 59; - law_headings = [ "Prologue" ]; - })) + try try personne_charge_effective_permanente_est_parent_ () with EmptyError -> false + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 91; + start_column = 12; + end_line = 91; + end_column = 59; + law_headings = [ "Prologue" ]; + }) in let personne_charge_effective_permanente_remplit_titre__i_ : bool = - log_variable_definition - [ "AllocationsFamiliales"; "personne_charge_effective_permanente_remplit_titre_I" ] - embed_bool - (try try personne_charge_effective_permanente_remplit_titre__i_ () with EmptyError -> false - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 92; - start_column = 12; - end_line = 92; - end_column = 64; - law_headings = [ "Prologue" ]; - })) + try try personne_charge_effective_permanente_remplit_titre__i_ () with EmptyError -> false + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 92; + start_column = 12; + end_line = 92; + end_column = 64; + law_headings = [ "Prologue" ]; + }) in let ressources_menage_ : money = - log_variable_definition - [ "AllocationsFamiliales"; "ressources_ménage" ] - embed_money - (try ressources_menage_ () - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 93; - start_column = 12; - end_line = 93; - end_column = 29; - law_headings = [ "Prologue" ]; - })) + try ressources_menage_ () + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 93; + start_column = 12; + end_line = 93; + end_column = 29; + law_headings = [ "Prologue" ]; + }) in let residence_ : collectivite = - log_variable_definition - [ "AllocationsFamiliales"; "résidence" ] - embed_collectivite - (try residence_ () - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 94; - start_column = 12; - end_line = 94; - end_column = 21; - law_headings = [ "Prologue" ]; - })) + try residence_ () + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 94; + start_column = 12; + end_line = 94; + end_column = 21; + law_headings = [ "Prologue" ]; + }) in let date_courante_ : date = - log_variable_definition - [ "AllocationsFamiliales"; "date_courante" ] - embed_date - (try date_courante_ () - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 97; - start_column = 12; - end_line = 97; - end_column = 25; - law_headings = [ "Prologue" ]; - })) + try date_courante_ () + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 97; + start_column = 12; + end_line = 97; + end_column = 25; + law_headings = [ "Prologue" ]; + }) in let enfants_a_charge_ : enfant array = - log_variable_definition - [ "AllocationsFamiliales"; "enfants_à_charge" ] - (embed_array embed_enfant) - (try enfants_a_charge_ () - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 100; - start_column = 12; - end_line = 100; - end_column = 28; - law_headings = [ "Prologue" ]; - })) + try enfants_a_charge_ () + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 100; + start_column = 12; + end_line = 100; + end_column = 28; + law_headings = [ "Prologue" ]; + }) in let prise_en_compte_ : enfant -> prise_en_compte = - log_variable_definition - [ "AllocationsFamiliales"; "prise_en_compte" ] - unembeddable - (try - try prise_en_compte_ () - with EmptyError -> ( - fun (param_ : enfant) -> - try - handle_default - [| - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 263; - start_column = 5; - end_line = 264; - end_column = 48; - law_headings = - [ - "Article L521-2"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - (match param_.prise_en_charge with - | GardeAlterneePartageAllocations _ -> false - | GardeAlterneeAllocataireUnique _ -> false - | EffectiveEtPermanente _ -> false - | ServicesSociauxAllocationVerseeALaFamille _ -> true - | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> false) - then Complete () - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 253; - start_column = 5; - end_line = 254; - end_column = 56; - law_headings = - [ - "Article L521-2"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - (match param_.prise_en_charge with - | GardeAlterneePartageAllocations _ -> false - | GardeAlterneeAllocataireUnique _ -> false - | EffectiveEtPermanente _ -> false - | ServicesSociauxAllocationVerseeALaFamille _ -> false - | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> true) - then Zero () - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 214; - start_column = 5; - end_line = 214; - end_column = 70; - law_headings = - [ - "Article L521-2"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - (match param_.prise_en_charge with - | GardeAlterneePartageAllocations _ -> true - | GardeAlterneeAllocataireUnique _ -> false - | EffectiveEtPermanente _ -> false - | ServicesSociauxAllocationVerseeALaFamille _ -> false - | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> false) - then Partagee () - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 204; - start_column = 5; - end_line = 204; - end_column = 69; - law_headings = - [ - "Article L521-2"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - (match param_.prise_en_charge with - | GardeAlterneePartageAllocations _ -> false - | GardeAlterneeAllocataireUnique _ -> true - | EffectiveEtPermanente _ -> false - | ServicesSociauxAllocationVerseeALaFamille _ -> false - | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> false) - then Complete () - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 184; - start_column = 5; - end_line = 184; - end_column = 60; - law_headings = - [ - "Article L521-2"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - (match param_.prise_en_charge with - | GardeAlterneePartageAllocations _ -> false - | GardeAlterneeAllocataireUnique _ -> false - | EffectiveEtPermanente _ -> true - | ServicesSociauxAllocationVerseeALaFamille _ -> false - | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> false) - then Complete () - else raise EmptyError); - |] - (fun (_ : _) -> - log_decision_taken - { - filename = ""; - start_line = 0; - start_column = 1; - end_line = 0; - end_column = 1; - law_headings = []; - } - false) - (fun (_ : _) -> raise EmptyError) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 103; - start_column = 12; - end_line = 103; - end_column = 27; - law_headings = [ "Prologue" ]; - })) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 103; - start_column = 12; - end_line = 103; - end_column = 27; - law_headings = [ "Prologue" ]; - })) + try + try prise_en_compte_ () + with EmptyError -> ( + fun (param_ : enfant) -> + try + handle_default + [| + (fun (_ : _) -> + if + match param_.prise_en_charge with + | GardeAlterneePartageAllocations _ -> false + | GardeAlterneeAllocataireUnique _ -> false + | EffectiveEtPermanente _ -> false + | ServicesSociauxAllocationVerseeALaFamille _ -> true + | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> false + then Complete () + else raise EmptyError); + (fun (_ : _) -> + if + match param_.prise_en_charge with + | GardeAlterneePartageAllocations _ -> false + | GardeAlterneeAllocataireUnique _ -> false + | EffectiveEtPermanente _ -> false + | ServicesSociauxAllocationVerseeALaFamille _ -> false + | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> true + then Zero () + else raise EmptyError); + (fun (_ : _) -> + if + match param_.prise_en_charge with + | GardeAlterneePartageAllocations _ -> true + | GardeAlterneeAllocataireUnique _ -> false + | EffectiveEtPermanente _ -> false + | ServicesSociauxAllocationVerseeALaFamille _ -> false + | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> false + then Partagee () + else raise EmptyError); + (fun (_ : _) -> + if + match param_.prise_en_charge with + | GardeAlterneePartageAllocations _ -> false + | GardeAlterneeAllocataireUnique _ -> true + | EffectiveEtPermanente _ -> false + | ServicesSociauxAllocationVerseeALaFamille _ -> false + | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> false + then Complete () + else raise EmptyError); + (fun (_ : _) -> + if + match param_.prise_en_charge with + | GardeAlterneePartageAllocations _ -> false + | GardeAlterneeAllocataireUnique _ -> false + | EffectiveEtPermanente _ -> true + | ServicesSociauxAllocationVerseeALaFamille _ -> false + | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> false + then Complete () + else raise EmptyError); + |] + (fun (_ : _) -> false) + (fun (_ : _) -> raise EmptyError) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 103; + start_column = 12; + end_line = 103; + end_column = 27; + law_headings = [ "Prologue" ]; + })) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 103; + start_column = 12; + end_line = 103; + end_column = 27; + law_headings = [ "Prologue" ]; + }) in let versement_ : enfant -> versement_allocations = - log_variable_definition - [ "AllocationsFamiliales"; "versement" ] - unembeddable - (try - try versement_ () - with EmptyError -> ( - fun (param_ : enfant) -> - try - handle_default - [| - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 269; - start_column = 5; - end_line = 270; - end_column = 48; - law_headings = - [ - "Article L521-2"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - (match param_.prise_en_charge with - | GardeAlterneePartageAllocations _ -> false - | GardeAlterneeAllocataireUnique _ -> false - | EffectiveEtPermanente _ -> false - | ServicesSociauxAllocationVerseeALaFamille _ -> true - | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> false) - then Normal () - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 258; - start_column = 5; - end_line = 259; - end_column = 56; - law_headings = - [ - "Article L521-2"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - (match param_.prise_en_charge with - | GardeAlterneePartageAllocations _ -> false - | GardeAlterneeAllocataireUnique _ -> false - | EffectiveEtPermanente _ -> false - | ServicesSociauxAllocationVerseeALaFamille _ -> false - | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> true) - then AllocationVerseeAuxServicesSociaux () - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 218; - start_column = 5; - end_line = 218; - end_column = 70; - law_headings = - [ - "Article L521-2"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - (match param_.prise_en_charge with - | GardeAlterneePartageAllocations _ -> true - | GardeAlterneeAllocataireUnique _ -> false - | EffectiveEtPermanente _ -> false - | ServicesSociauxAllocationVerseeALaFamille _ -> false - | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> false) - then Normal () - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 208; - start_column = 5; - end_line = 208; - end_column = 69; - law_headings = - [ - "Article L521-2"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - (match param_.prise_en_charge with - | GardeAlterneePartageAllocations _ -> false - | GardeAlterneeAllocataireUnique _ -> true - | EffectiveEtPermanente _ -> false - | ServicesSociauxAllocationVerseeALaFamille _ -> false - | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> false) - then Normal () - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 188; - start_column = 5; - end_line = 188; - end_column = 60; - law_headings = - [ - "Article L521-2"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - (match param_.prise_en_charge with - | GardeAlterneePartageAllocations _ -> false - | GardeAlterneeAllocataireUnique _ -> false - | EffectiveEtPermanente _ -> true - | ServicesSociauxAllocationVerseeALaFamille _ -> false - | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> false) - then Normal () - else raise EmptyError); - |] - (fun (_ : _) -> - log_decision_taken - { - filename = ""; - start_line = 0; - start_column = 1; - end_line = 0; - end_column = 1; - law_headings = []; - } - false) - (fun (_ : _) -> raise EmptyError) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 104; - start_column = 12; - end_line = 104; - end_column = 21; - law_headings = [ "Prologue" ]; - })) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 104; - start_column = 12; - end_line = 104; - end_column = 21; - law_headings = [ "Prologue" ]; - })) + try + try versement_ () + with EmptyError -> ( + fun (param_ : enfant) -> + try + handle_default + [| + (fun (_ : _) -> + if + match param_.prise_en_charge with + | GardeAlterneePartageAllocations _ -> false + | GardeAlterneeAllocataireUnique _ -> false + | EffectiveEtPermanente _ -> false + | ServicesSociauxAllocationVerseeALaFamille _ -> true + | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> false + then Normal () + else raise EmptyError); + (fun (_ : _) -> + if + match param_.prise_en_charge with + | GardeAlterneePartageAllocations _ -> false + | GardeAlterneeAllocataireUnique _ -> false + | EffectiveEtPermanente _ -> false + | ServicesSociauxAllocationVerseeALaFamille _ -> false + | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> true + then AllocationVerseeAuxServicesSociaux () + else raise EmptyError); + (fun (_ : _) -> + if + match param_.prise_en_charge with + | GardeAlterneePartageAllocations _ -> true + | GardeAlterneeAllocataireUnique _ -> false + | EffectiveEtPermanente _ -> false + | ServicesSociauxAllocationVerseeALaFamille _ -> false + | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> false + then Normal () + else raise EmptyError); + (fun (_ : _) -> + if + match param_.prise_en_charge with + | GardeAlterneePartageAllocations _ -> false + | GardeAlterneeAllocataireUnique _ -> true + | EffectiveEtPermanente _ -> false + | ServicesSociauxAllocationVerseeALaFamille _ -> false + | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> false + then Normal () + else raise EmptyError); + (fun (_ : _) -> + if + match param_.prise_en_charge with + | GardeAlterneePartageAllocations _ -> false + | GardeAlterneeAllocataireUnique _ -> false + | EffectiveEtPermanente _ -> true + | ServicesSociauxAllocationVerseeALaFamille _ -> false + | ServicesSociauxAllocationVerseeAuxServicesSociaux _ -> false + then Normal () + else raise EmptyError); + |] + (fun (_ : _) -> false) + (fun (_ : _) -> raise EmptyError) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 104; + start_column = 12; + end_line = 104; + end_column = 21; + law_headings = [ "Prologue" ]; + })) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 104; + start_column = 12; + end_line = 104; + end_column = 21; + law_headings = [ "Prologue" ]; + }) in let nombre_enfants_l521_1_ : integer = - log_variable_definition - [ "AllocationsFamiliales"; "nombre_enfants_l521_1" ] - embed_integer - (try try nombre_enfants_l521_1_ () with EmptyError -> integer_of_string "3" - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 145; - start_column = 12; - end_line = 145; - end_column = 33; - law_headings = [ "Prologue" ]; - })) + try try nombre_enfants_l521_1_ () with EmptyError -> integer_of_string "3" + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 145; + start_column = 12; + end_line = 145; + end_column = 33; + law_headings = [ "Prologue" ]; + }) in let nombre_enfants_alinea_2_l521_3_ : integer = - log_variable_definition - [ "AllocationsFamiliales"; "nombre_enfants_alinéa_2_l521_3" ] - embed_integer - (try try nombre_enfants_alinea_2_l521_3_ () with EmptyError -> integer_of_string "3" - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 147; - start_column = 12; - end_line = 147; - end_column = 42; - law_headings = [ "Prologue" ]; - })) + try try nombre_enfants_alinea_2_l521_3_ () with EmptyError -> integer_of_string "3" + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 147; + start_column = 12; + end_line = 147; + end_column = 42; + law_headings = [ "Prologue" ]; + }) in let result_ : allocation_familiales_avril2008_out = - log_end_call - [ "AllocationsFamiliales"; "version_avril_2008"; "AllocationFamilialesAvril2008" ] - (log_begin_call - [ "AllocationsFamiliales"; "version_avril_2008"; "AllocationFamilialesAvril2008" ] - allocation_familiales_avril2008 - { age_minimum_alinea_1_l521_3_in = (fun (_ : unit) -> raise EmptyError) }) + allocation_familiales_avril2008 + { age_minimum_alinea_1_l521_3_in = (fun (_ : unit) -> raise EmptyError) } in let version_avril_2008_dot_age_minimum_alinea_1_l521_3_ : integer = result_.age_minimum_alinea_1_l521_3_out in - let prestations_familiales_dot_date_courante_ : unit -> date = - fun (_ : unit) -> - log_variable_definition - [ "AllocationsFamiliales"; "prestations_familiales.date_courante" ] - embed_date date_courante_ - in + let prestations_familiales_dot_date_courante_ : unit -> date = fun (_ : unit) -> date_courante_ in let prestations_familiales_dot_prestation_courante_ : unit -> element_prestations_familiales = - fun (_ : unit) -> - log_variable_definition - [ "AllocationsFamiliales"; "prestations_familiales.prestation_courante" ] - embed_element_prestations_familiales (AllocationsFamiliales ()) - in - let prestations_familiales_dot_residence_ : unit -> collectivite = - fun (_ : unit) -> - log_variable_definition - [ "AllocationsFamiliales"; "prestations_familiales.résidence" ] - embed_collectivite residence_ + fun (_ : unit) -> AllocationsFamiliales () in + let prestations_familiales_dot_residence_ : unit -> collectivite = fun (_ : unit) -> residence_ in let result_ : prestations_familiales_out = - log_end_call - [ "AllocationsFamiliales"; "prestations_familiales"; "PrestationsFamiliales" ] - (log_begin_call - [ "AllocationsFamiliales"; "prestations_familiales"; "PrestationsFamiliales" ] - prestations_familiales - { - droit_ouvert_in = (fun (_ : unit) -> raise EmptyError); - conditions_hors_age_in = (fun (_ : unit) -> raise EmptyError); - plafond_l512_3_2_in = (fun (_ : unit) -> raise EmptyError); - age_l512_3_2_in = (fun (_ : unit) -> raise EmptyError); - regime_outre_mer_l751_1_in = (fun (_ : unit) -> raise EmptyError); - date_courante_in = prestations_familiales_dot_date_courante_; - prestation_courante_in = prestations_familiales_dot_prestation_courante_; - residence_in = prestations_familiales_dot_residence_; - base_mensuelle_in = (fun (_ : unit) -> raise EmptyError); - }) + prestations_familiales + { + droit_ouvert_in = (fun (_ : unit) -> raise EmptyError); + conditions_hors_age_in = (fun (_ : unit) -> raise EmptyError); + plafond_l512_3_2_in = (fun (_ : unit) -> raise EmptyError); + age_l512_3_2_in = (fun (_ : unit) -> raise EmptyError); + regime_outre_mer_l751_1_in = (fun (_ : unit) -> raise EmptyError); + date_courante_in = prestations_familiales_dot_date_courante_; + prestation_courante_in = prestations_familiales_dot_prestation_courante_; + residence_in = prestations_familiales_dot_residence_; + base_mensuelle_in = (fun (_ : unit) -> raise EmptyError); + } in let prestations_familiales_dot_droit_ouvert_ : enfant -> bool = result_.droit_ouvert_out in let prestations_familiales_dot_conditions_hors_age_ : enfant -> bool = @@ -1952,2117 +1087,1008 @@ let allocations_familiales (allocations_familiales_in : allocations_familiales_i let prestations_familiales_dot_residence_ : collectivite = result_.residence_out in let prestations_familiales_dot_base_mensuelle_ : money = result_.base_mensuelle_out in let enfant_le_plus_age_dot_enfants_ : unit -> enfant array = - fun (_ : unit) -> - log_variable_definition - [ "AllocationsFamiliales"; "enfant_le_plus_âgé.enfants" ] - (embed_array embed_enfant) enfants_a_charge_ + fun (_ : unit) -> enfants_a_charge_ in let result_ : enfant_le_plus_age_out = - log_end_call - [ "AllocationsFamiliales"; "enfant_le_plus_âgé"; "EnfantLePlusÂgé" ] - (log_begin_call - [ "AllocationsFamiliales"; "enfant_le_plus_âgé"; "EnfantLePlusÂgé" ] - enfant_le_plus_age - { - enfants_in = enfant_le_plus_age_dot_enfants_; - le_plus_age_in = (fun (_ : unit) -> raise EmptyError); - }) + enfant_le_plus_age + { + enfants_in = enfant_le_plus_age_dot_enfants_; + le_plus_age_in = (fun (_ : unit) -> raise EmptyError); + } in let enfant_le_plus_age_dot_enfants_ : enfant array = result_.enfants_out in let enfant_le_plus_age_dot_le_plus_age_ : enfant = result_.le_plus_age_out in let age_minimum_alinea_1_l521_3_ : enfant -> integer = - log_variable_definition - [ "AllocationsFamiliales"; "âge_minimum_alinéa_1_l521_3" ] - unembeddable - (try - try age_minimum_alinea_1_l521_3_ () - with EmptyError -> ( - fun (param_ : enfant) -> - try - try - if - log_decision_taken - { - filename = "./securite_sociale_R.catala_fr"; - start_line = 83; - start_column = 19; - end_line = 83; - end_column = 69; - law_headings = - [ - "Article R521-1"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets en Conseil d'Etat"; - "Code de la sécurité sociale"; - ]; - } - (param_.date_de_naissance +@ duration_of_numbers 11 0 0 - <=@ date_of_numbers 2008 4 30) - then version_avril_2008_dot_age_minimum_alinea_1_l521_3_ - else raise EmptyError - with EmptyError -> integer_of_string "14" - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 146; - start_column = 12; - end_line = 146; - end_column = 39; - law_headings = [ "Prologue" ]; - })) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 146; - start_column = 12; - end_line = 146; - end_column = 39; - law_headings = [ "Prologue" ]; - })) + try + try age_minimum_alinea_1_l521_3_ () + with EmptyError -> ( + fun (param_ : enfant) -> + try + try + if + param_.date_de_naissance +@ duration_of_numbers 11 0 0 <=@ date_of_numbers 2008 4 30 + then version_avril_2008_dot_age_minimum_alinea_1_l521_3_ + else raise EmptyError + with EmptyError -> integer_of_string "14" + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 146; + start_column = 12; + end_line = 146; + end_column = 39; + law_headings = [ "Prologue" ]; + })) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 146; + start_column = 12; + end_line = 146; + end_column = 39; + law_headings = [ "Prologue" ]; + }) in let enfants_a_charge_droit_ouvert_prestation_familiale_ : enfant array = - log_variable_definition - [ "AllocationsFamiliales"; "enfants_à_charge_droit_ouvert_prestation_familiale" ] - (embed_array embed_enfant) - (try - try enfants_a_charge_droit_ouvert_prestation_familiale_ () - with EmptyError -> - array_filter - (fun (enfant_ : _) -> - log_end_call - [ "PrestationsFamiliales"; "droit_ouvert" ] - (log_variable_definition - [ "PrestationsFamiliales"; "droit_ouvert"; "output" ] - unembeddable - (log_begin_call - [ "PrestationsFamiliales"; "droit_ouvert" ] - prestations_familiales_dot_droit_ouvert_ - (log_variable_definition - [ "PrestationsFamiliales"; "droit_ouvert"; "input" ] - unembeddable enfant_)))) - enfants_a_charge_ - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 101; - start_column = 12; - end_line = 101; - end_column = 62; - law_headings = [ "Prologue" ]; - })) + try + try enfants_a_charge_droit_ouvert_prestation_familiale_ () + with EmptyError -> + array_filter + (fun (enfant_ : _) -> prestations_familiales_dot_droit_ouvert_ enfant_) + enfants_a_charge_ + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 101; + start_column = 12; + end_line = 101; + end_column = 62; + law_headings = [ "Prologue" ]; + }) in let est_enfant_le_plus_age_ : enfant -> bool = - log_variable_definition - [ "AllocationsFamiliales"; "est_enfant_le_plus_âgé" ] - unembeddable - (try - try est_enfant_le_plus_age_ () - with EmptyError -> ( - fun (param_ : enfant) -> - try enfant_le_plus_age_dot_le_plus_age_ = param_ - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 148; - start_column = 12; - end_line = 148; - end_column = 34; - law_headings = [ "Prologue" ]; - })) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 148; - start_column = 12; - end_line = 148; - end_column = 34; - law_headings = [ "Prologue" ]; - })) + try + try est_enfant_le_plus_age_ () + with EmptyError -> ( + fun (param_ : enfant) -> + try enfant_le_plus_age_dot_le_plus_age_ = param_ + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 148; + start_column = 12; + end_line = 148; + end_column = 34; + law_headings = [ "Prologue" ]; + })) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 148; + start_column = 12; + end_line = 148; + end_column = 34; + law_headings = [ "Prologue" ]; + }) in let plafond__i_i_d521_3_ : money = - log_variable_definition - [ "AllocationsFamiliales"; "plafond_II_d521_3" ] - embed_money - (try - try plafond__i_i_d521_3_ () - with EmptyError -> - handle_default - [| - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./decrets_divers.catala_fr"; - start_line = 194; - start_column = 5; - end_line = 194; - end_column = 69; - law_headings = - [ - "Article 1"; - "Arrêté du 14 décembre 2020 relatif au montant des plafonds de \ - ressources de certaines prestations familiales et aux tranches du \ - barème applicable au recouvrement des indus et à la saisie des \ - prestations"; - "Montant des plafonds de ressources"; - ]; - } - (date_courante_ >=@ date_of_numbers 2021 1 1 - && date_courante_ <=@ date_of_numbers 2021 12 31) - then - money_of_cents_string "8155800" - +$ money_of_cents_string "582700" - *$ decimal_of_integer - (array_length enfants_a_charge_droit_ouvert_prestation_familiale_) - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./decrets_divers.catala_fr"; - start_line = 158; - start_column = 5; - end_line = 158; - end_column = 69; - law_headings = - [ - "Instruction interministerielle no DSS/SD2B/2019/261 du 18 décembre \ - 2019 relative à la revalorisation au 1er janvier 2020 des plafonds de \ - ressources d’attribution de certaines prestations familiales servies \ - en métropole, en Guadeloupe, en Guyane, en Martinique, à La \ - Réunion, à Saint-Barthélemy, à Saint-Martin et à Mayotte"; - "Montant des plafonds de ressources"; - ]; - } - (date_courante_ >=@ date_of_numbers 2020 1 1 - && date_courante_ <=@ date_of_numbers 2020 12 31) - then - money_of_cents_string "8083100" - +$ money_of_cents_string "577500" - *$ decimal_of_integer - (array_length enfants_a_charge_droit_ouvert_prestation_familiale_) - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./decrets_divers.catala_fr"; - start_line = 125; - start_column = 5; - end_line = 125; - end_column = 69; - law_headings = - [ - "Instruction interministérielle n° DSS/SD2B/2018/279 du 17 décembre \ - 2018 relative à la revalorisation au 1er janvier 2019 des plafonds de \ - ressources d’attribution de certaines prestations familiales servies \ - en métropole, en Guadeloupe, en Guyane, en Martinique, à la \ - Réunion, à Saint-Barthélemy, à Saint-Martin et à Mayotte"; - "Montant des plafonds de ressources"; - ]; - } - (date_courante_ >=@ date_of_numbers 2019 1 1 - && date_courante_ <=@ date_of_numbers 2019 12 31) - then - money_of_cents_string "7955800" - +$ money_of_cents_string "568400" - *$ decimal_of_integer - (array_length enfants_a_charge_droit_ouvert_prestation_familiale_) - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./decrets_divers.catala_fr"; - start_line = 92; - start_column = 5; - end_line = 92; - end_column = 69; - law_headings = - [ - "Circulaire interministérielle N° DSS/SD2B/2017/352 du 22 décembre \ - 2017 relative à la revalorisation au 1er janvier 2018 des plafonds de \ - ressources d’attribution de certaines prestations familiales servies \ - en métropole, en Guadeloupe, en Guyane, en Martinique, à la \ - Réunion, à Saint-Barthélemy, à Saint-Martin et à Mayotte"; - "Montant des plafonds de ressources"; - ]; - } - (date_courante_ >=@ date_of_numbers 2018 1 1 - && date_courante_ <=@ date_of_numbers 2018 12 31) - then - money_of_cents_string "7877000" - +$ money_of_cents_string "562800" - *$ decimal_of_integer - (array_length enfants_a_charge_droit_ouvert_prestation_familiale_) - else raise EmptyError); - |] - (fun (_ : _) -> - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 308; - start_column = 14; - end_line = 308; - end_column = 31; - law_headings = - [ - "Article D521-3"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - true) - (fun (_ : _) -> - money_of_cents_string "7830000" - +$ money_of_cents_string "559500" - *$ decimal_of_integer - (array_length enfants_a_charge_droit_ouvert_prestation_familiale_)) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 150; - start_column = 12; - end_line = 150; - end_column = 29; - law_headings = [ "Prologue" ]; - })) + try + try plafond__i_i_d521_3_ () + with EmptyError -> + handle_default + [| + (fun (_ : _) -> + if + date_courante_ >=@ date_of_numbers 2021 1 1 + && date_courante_ <=@ date_of_numbers 2021 12 31 + then + money_of_cents_string "8155800" + +$ money_of_cents_string "582700" + *$ decimal_of_integer + (array_length enfants_a_charge_droit_ouvert_prestation_familiale_) + else raise EmptyError); + (fun (_ : _) -> + if + date_courante_ >=@ date_of_numbers 2020 1 1 + && date_courante_ <=@ date_of_numbers 2020 12 31 + then + money_of_cents_string "8083100" + +$ money_of_cents_string "577500" + *$ decimal_of_integer + (array_length enfants_a_charge_droit_ouvert_prestation_familiale_) + else raise EmptyError); + (fun (_ : _) -> + if + date_courante_ >=@ date_of_numbers 2019 1 1 + && date_courante_ <=@ date_of_numbers 2019 12 31 + then + money_of_cents_string "7955800" + +$ money_of_cents_string "568400" + *$ decimal_of_integer + (array_length enfants_a_charge_droit_ouvert_prestation_familiale_) + else raise EmptyError); + (fun (_ : _) -> + if + date_courante_ >=@ date_of_numbers 2018 1 1 + && date_courante_ <=@ date_of_numbers 2018 12 31 + then + money_of_cents_string "7877000" + +$ money_of_cents_string "562800" + *$ decimal_of_integer + (array_length enfants_a_charge_droit_ouvert_prestation_familiale_) + else raise EmptyError); + |] + (fun (_ : _) -> true) + (fun (_ : _) -> + money_of_cents_string "7830000" + +$ money_of_cents_string "559500" + *$ decimal_of_integer + (array_length enfants_a_charge_droit_ouvert_prestation_familiale_)) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 150; + start_column = 12; + end_line = 150; + end_column = 29; + law_headings = [ "Prologue" ]; + }) in let plafond__i_d521_3_ : money = - log_variable_definition - [ "AllocationsFamiliales"; "plafond_I_d521_3" ] - embed_money - (try - try plafond__i_d521_3_ () - with EmptyError -> - handle_default - [| - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./decrets_divers.catala_fr"; - start_line = 178; - start_column = 5; - end_line = 178; - end_column = 69; - law_headings = - [ - "Article 1"; - "Arrêté du 14 décembre 2020 relatif au montant des plafonds de \ - ressources de certaines prestations familiales et aux tranches du \ - barème applicable au recouvrement des indus et à la saisie des \ - prestations"; - "Montant des plafonds de ressources"; - ]; - } - (date_courante_ >=@ date_of_numbers 2021 1 1 - && date_courante_ <=@ date_of_numbers 2021 12 31) - then - money_of_cents_string "5827900" - +$ money_of_cents_string "582700" - *$ decimal_of_integer - (array_length enfants_a_charge_droit_ouvert_prestation_familiale_) - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./decrets_divers.catala_fr"; - start_line = 151; - start_column = 5; - end_line = 151; - end_column = 69; - law_headings = - [ - "Instruction interministerielle no DSS/SD2B/2019/261 du 18 décembre \ - 2019 relative à la revalorisation au 1er janvier 2020 des plafonds de \ - ressources d’attribution de certaines prestations familiales servies \ - en métropole, en Guadeloupe, en Guyane, en Martinique, à La \ - Réunion, à Saint-Barthélemy, à Saint-Martin et à Mayotte"; - "Montant des plafonds de ressources"; - ]; - } - (date_courante_ >=@ date_of_numbers 2020 1 1 - && date_courante_ <=@ date_of_numbers 2020 12 31) - then - money_of_cents_string "5775900" - +$ money_of_cents_string "577500" - *$ decimal_of_integer - (array_length enfants_a_charge_droit_ouvert_prestation_familiale_) - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./decrets_divers.catala_fr"; - start_line = 118; - start_column = 5; - end_line = 118; - end_column = 69; - law_headings = - [ - "Instruction interministérielle n° DSS/SD2B/2018/279 du 17 décembre \ - 2018 relative à la revalorisation au 1er janvier 2019 des plafonds de \ - ressources d’attribution de certaines prestations familiales servies \ - en métropole, en Guadeloupe, en Guyane, en Martinique, à la \ - Réunion, à Saint-Barthélemy, à Saint-Martin et à Mayotte"; - "Montant des plafonds de ressources"; - ]; - } - (date_courante_ >=@ date_of_numbers 2019 1 1 - && date_courante_ <=@ date_of_numbers 2019 12 31) - then - money_of_cents_string "5684900" - +$ money_of_cents_string "568400" - *$ decimal_of_integer - (array_length enfants_a_charge_droit_ouvert_prestation_familiale_) - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./decrets_divers.catala_fr"; - start_line = 85; - start_column = 5; - end_line = 85; - end_column = 69; - law_headings = - [ - "Circulaire interministérielle N° DSS/SD2B/2017/352 du 22 décembre \ - 2017 relative à la revalorisation au 1er janvier 2018 des plafonds de \ - ressources d’attribution de certaines prestations familiales servies \ - en métropole, en Guadeloupe, en Guyane, en Martinique, à la \ - Réunion, à Saint-Barthélemy, à Saint-Martin et à Mayotte"; - "Montant des plafonds de ressources"; - ]; - } - (date_courante_ >=@ date_of_numbers 2018 1 1 - && date_courante_ <=@ date_of_numbers 2018 12 31) - then - money_of_cents_string "5628600" - +$ money_of_cents_string "562800" - *$ decimal_of_integer - (array_length enfants_a_charge_droit_ouvert_prestation_familiale_) - else raise EmptyError); - |] - (fun (_ : _) -> - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 298; - start_column = 14; - end_line = 298; - end_column = 30; - law_headings = - [ - "Article D521-3"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - true) - (fun (_ : _) -> - money_of_cents_string "5595000" - +$ money_of_cents_string "559500" - *$ decimal_of_integer - (array_length enfants_a_charge_droit_ouvert_prestation_familiale_)) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 149; - start_column = 12; - end_line = 149; - end_column = 28; - law_headings = [ "Prologue" ]; - })) + try + try plafond__i_d521_3_ () + with EmptyError -> + handle_default + [| + (fun (_ : _) -> + if + date_courante_ >=@ date_of_numbers 2021 1 1 + && date_courante_ <=@ date_of_numbers 2021 12 31 + then + money_of_cents_string "5827900" + +$ money_of_cents_string "582700" + *$ decimal_of_integer + (array_length enfants_a_charge_droit_ouvert_prestation_familiale_) + else raise EmptyError); + (fun (_ : _) -> + if + date_courante_ >=@ date_of_numbers 2020 1 1 + && date_courante_ <=@ date_of_numbers 2020 12 31 + then + money_of_cents_string "5775900" + +$ money_of_cents_string "577500" + *$ decimal_of_integer + (array_length enfants_a_charge_droit_ouvert_prestation_familiale_) + else raise EmptyError); + (fun (_ : _) -> + if + date_courante_ >=@ date_of_numbers 2019 1 1 + && date_courante_ <=@ date_of_numbers 2019 12 31 + then + money_of_cents_string "5684900" + +$ money_of_cents_string "568400" + *$ decimal_of_integer + (array_length enfants_a_charge_droit_ouvert_prestation_familiale_) + else raise EmptyError); + (fun (_ : _) -> + if + date_courante_ >=@ date_of_numbers 2018 1 1 + && date_courante_ <=@ date_of_numbers 2018 12 31 + then + money_of_cents_string "5628600" + +$ money_of_cents_string "562800" + *$ decimal_of_integer + (array_length enfants_a_charge_droit_ouvert_prestation_familiale_) + else raise EmptyError); + |] + (fun (_ : _) -> true) + (fun (_ : _) -> + money_of_cents_string "5595000" + +$ money_of_cents_string "559500" + *$ decimal_of_integer + (array_length enfants_a_charge_droit_ouvert_prestation_familiale_)) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 149; + start_column = 12; + end_line = 149; + end_column = 28; + law_headings = [ "Prologue" ]; + }) in let droit_ouvert_complement_ : bool = - log_variable_definition - [ "AllocationsFamiliales"; "droit_ouvert_complément" ] - embed_bool - (try - try droit_ouvert_complement_ () - with EmptyError -> ( - try - try - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 426; - start_column = 5; - end_line = 427; - end_column = 71; - law_headings = - [ - "Article L755-12"; - "Chapitre 5 : Prestations familiales et prestations assimilées"; - "Titre 5 : Dispositions particulières à la Guadeloupe, à la Guyane, à \ - la Martinique, à La Réunion, à Saint-Barthélemy et à Saint-Martin"; - "Livre 7 : Régimes divers - Dispositions diverses"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - (prestations_familiales_dot_regime_outre_mer_l751_1_ - && array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - = integer_of_string "1") - then false - else raise EmptyError - with EmptyError -> true - with EmptyError -> false) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 133; - start_column = 12; - end_line = 133; - end_column = 35; - law_headings = [ "Prologue" ]; - })) + try + try droit_ouvert_complement_ () + with EmptyError -> ( + try + try + if + prestations_familiales_dot_regime_outre_mer_l751_1_ + && array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + = integer_of_string "1" + then false + else raise EmptyError + with EmptyError -> true + with EmptyError -> false) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 133; + start_column = 12; + end_line = 133; + end_column = 35; + law_headings = [ "Prologue" ]; + }) in let droit_ouvert_forfaitaire_ : enfant -> bool = - log_variable_definition - [ "AllocationsFamiliales"; "droit_ouvert_forfaitaire" ] - unembeddable - (try - try droit_ouvert_forfaitaire_ () - with EmptyError -> ( - fun (param_ : enfant) -> - try - try - try - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 420; - start_column = 6; - end_line = 421; - end_column = 72; - law_headings = - [ - "Article L755-12"; - "Chapitre 5 : Prestations familiales et prestations assimilées"; - "Titre 5 : Dispositions particulières à la Guadeloupe, à la \ - Guyane, à la Martinique, à La Réunion, à Saint-Barthélemy et à \ - Saint-Martin"; - "Livre 7 : Régimes divers - Dispositions diverses"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - (prestations_familiales_dot_regime_outre_mer_l751_1_ - && array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - = integer_of_string "1") - then false - else raise EmptyError - with EmptyError -> - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 119; - start_column = 5; - end_line = 125; - end_column = 59; - law_headings = - [ - "Article L521-1"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - (array_length enfants_a_charge_ >=! nombre_enfants_alinea_2_l521_3_ - && param_.age = prestations_familiales_dot_age_l512_3_2_ - && param_.a_deja_ouvert_droit_aux_allocations_familiales - && log_end_call - [ "PrestationsFamiliales"; "conditions_hors_âge" ] - (log_variable_definition - [ "PrestationsFamiliales"; "conditions_hors_âge"; "output" ] - unembeddable - (log_begin_call - [ "PrestationsFamiliales"; "conditions_hors_âge" ] - prestations_familiales_dot_conditions_hors_age_ - (log_variable_definition - [ "PrestationsFamiliales"; "conditions_hors_âge"; "input" ] - unembeddable param_)))) - then true - else raise EmptyError - with EmptyError -> false - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 121; - start_column = 12; - end_line = 121; - end_column = 36; - law_headings = [ "Prologue" ]; - })) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 121; - start_column = 12; - end_line = 121; - end_column = 36; - law_headings = [ "Prologue" ]; - })) + try + try droit_ouvert_forfaitaire_ () + with EmptyError -> ( + fun (param_ : enfant) -> + try + try + try + if + prestations_familiales_dot_regime_outre_mer_l751_1_ + && array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + = integer_of_string "1" + then false + else raise EmptyError + with EmptyError -> + if + array_length enfants_a_charge_ >=! nombre_enfants_alinea_2_l521_3_ + && param_.age = prestations_familiales_dot_age_l512_3_2_ + && param_.a_deja_ouvert_droit_aux_allocations_familiales + && prestations_familiales_dot_conditions_hors_age_ param_ + then true + else raise EmptyError + with EmptyError -> false + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 121; + start_column = 12; + end_line = 121; + end_column = 36; + law_headings = [ "Prologue" ]; + })) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 121; + start_column = 12; + end_line = 121; + end_column = 36; + law_headings = [ "Prologue" ]; + }) in let nombre_total_enfants_ : decimal = - log_variable_definition - [ "AllocationsFamiliales"; "nombre_total_enfants" ] - embed_decimal - (try - try nombre_total_enfants_ () - with EmptyError -> - decimal_of_integer (array_length enfants_a_charge_droit_ouvert_prestation_familiale_) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 116; - start_column = 12; - end_line = 116; - end_column = 32; - law_headings = [ "Prologue" ]; - })) + try + try nombre_total_enfants_ () + with EmptyError -> + decimal_of_integer (array_length enfants_a_charge_droit_ouvert_prestation_familiale_) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 116; + start_column = 12; + end_line = 116; + end_column = 32; + law_headings = [ "Prologue" ]; + }) in let nombre_moyen_enfants_ : decimal = - log_variable_definition - [ "AllocationsFamiliales"; "nombre_moyen_enfants" ] - embed_decimal - (try - try nombre_moyen_enfants_ () - with EmptyError -> - Array.fold_left - (fun (acc_ : decimal) (enfant_ : _) -> - acc_ - +& - match - log_end_call - [ "AllocationsFamiliales"; "prise_en_compte" ] - (log_variable_definition - [ "AllocationsFamiliales"; "prise_en_compte"; "output" ] - unembeddable - (log_begin_call - [ "AllocationsFamiliales"; "prise_en_compte" ] - prise_en_compte_ - (log_variable_definition - [ "AllocationsFamiliales"; "prise_en_compte"; "input" ] - unembeddable enfant_))) - with - | Complete _ -> decimal_of_string "1." - | Partagee _ -> decimal_of_string "0.5" - | Zero _ -> decimal_of_string "0.") - (decimal_of_string "0.") enfants_a_charge_droit_ouvert_prestation_familiale_ - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 115; - start_column = 12; - end_line = 115; - end_column = 32; - law_headings = [ "Prologue" ]; - })) + try + try nombre_moyen_enfants_ () + with EmptyError -> + Array.fold_left + (fun (acc_ : decimal) (enfant_ : _) -> + acc_ + +& + match prise_en_compte_ enfant_ with + | Complete _ -> decimal_of_string "1." + | Partagee _ -> decimal_of_string "0.5" + | Zero _ -> decimal_of_string "0.") + (decimal_of_string "0.") enfants_a_charge_droit_ouvert_prestation_familiale_ + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 115; + start_column = 12; + end_line = 115; + end_column = 32; + law_headings = [ "Prologue" ]; + }) in let montant_initial_base_premier_enfant_ : money = - log_variable_definition - [ "AllocationsFamiliales"; "montant_initial_base_premier_enfant" ] - embed_money - (try - try montant_initial_base_premier_enfant_ () - with EmptyError -> - handle_default - [| - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 360; - start_column = 6; - end_line = 360; - end_column = 70; - law_headings = - [ - "Article D755-5"; - "Chapitre 5 : Prestations familiales et prestations assimilées"; - "Titre 5 : Départements d'outre-mer"; - "Livre 7 : Régimes divers - Dispositions diverses"; - "Partie réglementaire - Décrets simples"; - ]; - } - (array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - = integer_of_string "1") - then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.0588" - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 356; - start_column = 6; - end_line = 356; - end_column = 71; - law_headings = - [ - "Article D755-5"; - "Chapitre 5 : Prestations familiales et prestations assimilées"; - "Titre 5 : Départements d'outre-mer"; - "Livre 7 : Régimes divers - Dispositions diverses"; - "Partie réglementaire - Décrets simples"; - ]; - } - (array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - <> integer_of_string "1") - then money_of_cents_string "0" - else raise EmptyError); - |] - (fun (_ : _) -> - log_decision_taken - { - filename = ""; - start_line = 0; - start_column = 1; - end_line = 0; - end_column = 1; - law_headings = []; - } - false) - (fun (_ : _) -> raise EmptyError) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 111; - start_column = 12; - end_line = 111; - end_column = 47; - law_headings = [ "Prologue" ]; - })) + try + try montant_initial_base_premier_enfant_ () + with EmptyError -> + handle_default + [| + (fun (_ : _) -> + if + array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + = integer_of_string "1" + then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.0588" + else raise EmptyError); + (fun (_ : _) -> + if + array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + <> integer_of_string "1" + then money_of_cents_string "0" + else raise EmptyError); + |] + (fun (_ : _) -> false) + (fun (_ : _) -> raise EmptyError) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 111; + start_column = 12; + end_line = 111; + end_column = 47; + law_headings = [ "Prologue" ]; + }) in let droit_ouvert_base_ : bool = - log_variable_definition - [ "AllocationsFamiliales"; "droit_ouvert_base" ] - embed_bool - (try - try droit_ouvert_base_ () - with EmptyError -> ( - try - try - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 406; - start_column = 5; - end_line = 407; - end_column = 72; - law_headings = - [ - "Article L755-12"; - "Chapitre 5 : Prestations familiales et prestations assimilées"; - "Titre 5 : Dispositions particulières à la Guadeloupe, à la Guyane, à \ - la Martinique, à La Réunion, à Saint-Barthélemy et à Saint-Martin"; - "Livre 7 : Régimes divers - Dispositions diverses"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - (prestations_familiales_dot_regime_outre_mer_l751_1_ - && array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - >=! integer_of_string "1") - then true - else raise EmptyError - with EmptyError -> - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 101; - start_column = 5; - end_line = 101; - end_column = 70; - law_headings = - [ - "Article L521-1"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - (array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - >=! integer_of_string "2") - then true - else raise EmptyError - with EmptyError -> false) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 109; - start_column = 12; - end_line = 109; - end_column = 29; - law_headings = [ "Prologue" ]; - })) + try + try droit_ouvert_base_ () + with EmptyError -> ( + try + try + if + prestations_familiales_dot_regime_outre_mer_l751_1_ + && array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + >=! integer_of_string "1" + then true + else raise EmptyError + with EmptyError -> + if + array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + >=! integer_of_string "2" + then true + else raise EmptyError + with EmptyError -> false) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 109; + start_column = 12; + end_line = 109; + end_column = 29; + law_headings = [ "Prologue" ]; + }) in let droit_ouvert_majoration_ : enfant -> bool = - log_variable_definition - [ "AllocationsFamiliales"; "droit_ouvert_majoration" ] - unembeddable - (try - try droit_ouvert_majoration_ () - with EmptyError -> ( - fun (param_ : enfant) -> - try - try - try - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 313; - start_column = 5; - end_line = 315; - end_column = 58; - law_headings = - [ - "Article L521-3"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - (array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - >=! nombre_enfants_alinea_2_l521_3_ - && param_.age - >=! log_end_call - [ "AllocationsFamiliales"; "âge_minimum_alinéa_1_l521_3" ] - (log_variable_definition - [ - "AllocationsFamiliales"; - "âge_minimum_alinéa_1_l521_3"; - "output"; - ] - unembeddable - (log_begin_call - [ "AllocationsFamiliales"; "âge_minimum_alinéa_1_l521_3" ] - age_minimum_alinea_1_l521_3_ - (log_variable_definition - [ - "AllocationsFamiliales"; - "âge_minimum_alinéa_1_l521_3"; - "input"; - ] - unembeddable param_)))) - then true - else raise EmptyError - with EmptyError -> - if - log_decision_taken - { - filename = "./securite_sociale_L.catala_fr"; - start_line = 299; - start_column = 5; - end_line = 300; - end_column = 58; - law_headings = - [ - "Article L521-3"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie législative"; - "Code de la sécurité sociale"; - ]; - } - ((not - (log_end_call - [ "AllocationsFamiliales"; "est_enfant_le_plus_âgé" ] - (log_variable_definition - [ "AllocationsFamiliales"; "est_enfant_le_plus_âgé"; "output" ] - unembeddable - (log_begin_call - [ "AllocationsFamiliales"; "est_enfant_le_plus_âgé" ] - est_enfant_le_plus_age_ - (log_variable_definition - [ - "AllocationsFamiliales"; - "est_enfant_le_plus_âgé"; - "input"; - ] - unembeddable param_))))) - && param_.age - >=! log_end_call - [ "AllocationsFamiliales"; "âge_minimum_alinéa_1_l521_3" ] - (log_variable_definition - [ - "AllocationsFamiliales"; - "âge_minimum_alinéa_1_l521_3"; - "output"; - ] - unembeddable - (log_begin_call - [ "AllocationsFamiliales"; "âge_minimum_alinéa_1_l521_3" ] - age_minimum_alinea_1_l521_3_ - (log_variable_definition - [ - "AllocationsFamiliales"; - "âge_minimum_alinéa_1_l521_3"; - "input"; - ] - unembeddable param_)))) - then true - else raise EmptyError - with EmptyError -> false - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 126; - start_column = 12; - end_line = 126; - end_column = 35; - law_headings = [ "Prologue" ]; - })) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 126; - start_column = 12; - end_line = 126; - end_column = 35; - law_headings = [ "Prologue" ]; - })) + try + try droit_ouvert_majoration_ () + with EmptyError -> ( + fun (param_ : enfant) -> + try + try + try + if + array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + >=! nombre_enfants_alinea_2_l521_3_ + && param_.age >=! age_minimum_alinea_1_l521_3_ param_ + then true + else raise EmptyError + with EmptyError -> + if + (not (est_enfant_le_plus_age_ param_)) + && param_.age >=! age_minimum_alinea_1_l521_3_ param_ + then true + else raise EmptyError + with EmptyError -> false + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 126; + start_column = 12; + end_line = 126; + end_column = 35; + law_headings = [ "Prologue" ]; + })) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 126; + start_column = 12; + end_line = 126; + end_column = 35; + law_headings = [ "Prologue" ]; + }) in let complement_degressif_ : money -> money = - log_variable_definition - [ "AllocationsFamiliales"; "complément_dégressif" ] - unembeddable - (try - try complement_degressif_ () - with EmptyError -> ( - fun (param_ : money) -> - try - handle_default - [| - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 170; - start_column = 5; - end_line = 171; - end_column = 68; - law_headings = - [ - "Article D521-1"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - (ressources_menage_ >$ plafond__i_i_d521_3_ - && ressources_menage_ - <=$ plafond__i_i_d521_3_ +$ (param_ *$ decimal_of_string "12.")) - then - (plafond__i_i_d521_3_ - +$ ((param_ *$ decimal_of_string "12.") -$ ressources_menage_)) - *$ (decimal_of_string "1." /& decimal_of_string "12.") - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 162; - start_column = 5; - end_line = 163; - end_column = 68; - law_headings = - [ - "Article D521-1"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - (ressources_menage_ >$ plafond__i_d521_3_ - && ressources_menage_ - <=$ plafond__i_d521_3_ +$ (param_ *$ decimal_of_string "12.")) - then - (plafond__i_d521_3_ - +$ ((param_ *$ decimal_of_string "12.") -$ ressources_menage_)) - *$ (decimal_of_string "1." /& decimal_of_string "12.") - else raise EmptyError); - |] - (fun (_ : _) -> - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 176; - start_column = 14; - end_line = 176; - end_column = 34; - law_headings = - [ - "Article D521-1"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - true) - (fun (_ : _) -> money_of_cents_string "0") - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 135; - start_column = 12; - end_line = 135; - end_column = 32; - law_headings = [ "Prologue" ]; - })) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 135; - start_column = 12; - end_line = 135; - end_column = 32; - law_headings = [ "Prologue" ]; - })) + try + try complement_degressif_ () + with EmptyError -> ( + fun (param_ : money) -> + try + handle_default + [| + (fun (_ : _) -> + if + ressources_menage_ >$ plafond__i_i_d521_3_ + && ressources_menage_ + <=$ plafond__i_i_d521_3_ +$ (param_ *$ decimal_of_string "12.") + then + (plafond__i_i_d521_3_ + +$ ((param_ *$ decimal_of_string "12.") -$ ressources_menage_)) + *$ (decimal_of_string "1." /& decimal_of_string "12.") + else raise EmptyError); + (fun (_ : _) -> + if + ressources_menage_ >$ plafond__i_d521_3_ + && ressources_menage_ + <=$ plafond__i_d521_3_ +$ (param_ *$ decimal_of_string "12.") + then + (plafond__i_d521_3_ + +$ ((param_ *$ decimal_of_string "12.") -$ ressources_menage_)) + *$ (decimal_of_string "1." /& decimal_of_string "12.") + else raise EmptyError); + |] + (fun (_ : _) -> true) + (fun (_ : _) -> money_of_cents_string "0") + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 135; + start_column = 12; + end_line = 135; + end_column = 32; + law_headings = [ "Prologue" ]; + })) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 135; + start_column = 12; + end_line = 135; + end_column = 32; + law_headings = [ "Prologue" ]; + }) in let montant_verse_forfaitaire_par_enfant_ : money = - log_variable_definition - [ "AllocationsFamiliales"; "montant_versé_forfaitaire_par_enfant" ] - embed_money - (try - try montant_verse_forfaitaire_par_enfant_ () - with EmptyError -> - handle_default - [| - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 243; - start_column = 5; - end_line = 243; - end_column = 43; - law_headings = - [ - "Article D521-2"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - (ressources_menage_ >$ plafond__i_i_d521_3_) - then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.0559" - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 229; - start_column = 5; - end_line = 230; - end_column = 46; - law_headings = - [ - "Article D521-2"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - (ressources_menage_ >$ plafond__i_d521_3_ - && ressources_menage_ <=$ plafond__i_i_d521_3_) - then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.1117" - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 215; - start_column = 5; - end_line = 215; - end_column = 43; - law_headings = - [ - "Article D521-2"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - (ressources_menage_ <=$ plafond__i_d521_3_) - then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.20234" - else raise EmptyError); - |] - (fun (_ : _) -> - log_decision_taken - { - filename = ""; - start_line = 0; - start_column = 1; - end_line = 0; - end_column = 1; - law_headings = []; - } - false) - (fun (_ : _) -> raise EmptyError) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 122; - start_column = 12; - end_line = 122; - end_column = 48; - law_headings = [ "Prologue" ]; - })) + try + try montant_verse_forfaitaire_par_enfant_ () + with EmptyError -> + handle_default + [| + (fun (_ : _) -> + if ressources_menage_ >$ plafond__i_i_d521_3_ then + prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.0559" + else raise EmptyError); + (fun (_ : _) -> + if + ressources_menage_ >$ plafond__i_d521_3_ + && ressources_menage_ <=$ plafond__i_i_d521_3_ + then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.1117" + else raise EmptyError); + (fun (_ : _) -> + if ressources_menage_ <=$ plafond__i_d521_3_ then + prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.20234" + else raise EmptyError); + |] + (fun (_ : _) -> false) + (fun (_ : _) -> raise EmptyError) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 122; + start_column = 12; + end_line = 122; + end_column = 48; + law_headings = [ "Prologue" ]; + }) in let montant_initial_base_troisieme_enfant_et_plus_ : money = - log_variable_definition - [ "AllocationsFamiliales"; "montant_initial_base_troisième_enfant_et_plus" ] - embed_money - (try - try montant_initial_base_troisieme_enfant_et_plus_ () - with EmptyError -> - handle_default - [| - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 113; - start_column = 3; - end_line = 113; - end_column = 41; - law_headings = - [ - "Article D521-1"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - (ressources_menage_ >$ plafond__i_i_d521_3_) - then - if - array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - >! integer_of_string "2" - then - prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.1025" - *$ decimal_of_integer - (array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - -! integer_of_string "2") - else money_of_cents_string "0" - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 74; - start_column = 3; - end_line = 75; - end_column = 44; - law_headings = - [ - "Article D521-1"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - (ressources_menage_ >$ plafond__i_d521_3_ - && ressources_menage_ <=$ plafond__i_i_d521_3_) - then - if - array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - >! integer_of_string "2" - then - prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.205" - *$ decimal_of_integer - (array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - -! integer_of_string "2") - else money_of_cents_string "0" - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 35; - start_column = 3; - end_line = 35; - end_column = 41; - law_headings = - [ - "Article D521-1"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - (ressources_menage_ <=$ plafond__i_d521_3_) - then - if - array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - >! integer_of_string "2" - then - prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.41" - *$ decimal_of_integer - (array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - -! integer_of_string "2") - else money_of_cents_string "0" - else raise EmptyError); - |] - (fun (_ : _) -> - log_decision_taken - { - filename = ""; - start_line = 0; - start_column = 1; - end_line = 0; - end_column = 1; - law_headings = []; - } - false) - (fun (_ : _) -> raise EmptyError) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 113; - start_column = 12; - end_line = 113; - end_column = 57; - law_headings = [ "Prologue" ]; - })) + try + try montant_initial_base_troisieme_enfant_et_plus_ () + with EmptyError -> + handle_default + [| + (fun (_ : _) -> + if ressources_menage_ >$ plafond__i_i_d521_3_ then + if + array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + >! integer_of_string "2" + then + prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.1025" + *$ decimal_of_integer + (array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + -! integer_of_string "2") + else money_of_cents_string "0" + else raise EmptyError); + (fun (_ : _) -> + if + ressources_menage_ >$ plafond__i_d521_3_ + && ressources_menage_ <=$ plafond__i_i_d521_3_ + then + if + array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + >! integer_of_string "2" + then + prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.205" + *$ decimal_of_integer + (array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + -! integer_of_string "2") + else money_of_cents_string "0" + else raise EmptyError); + (fun (_ : _) -> + if ressources_menage_ <=$ plafond__i_d521_3_ then + if + array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + >! integer_of_string "2" + then + prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.41" + *$ decimal_of_integer + (array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + -! integer_of_string "2") + else money_of_cents_string "0" + else raise EmptyError); + |] + (fun (_ : _) -> false) + (fun (_ : _) -> raise EmptyError) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 113; + start_column = 12; + end_line = 113; + end_column = 57; + law_headings = [ "Prologue" ]; + }) in let montant_initial_base_deuxieme_enfant_ : money = - log_variable_definition - [ "AllocationsFamiliales"; "montant_initial_base_deuxième_enfant" ] - embed_money - (try - try montant_initial_base_deuxieme_enfant_ () - with EmptyError -> - handle_default - [| - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 113; - start_column = 3; - end_line = 113; - end_column = 41; - law_headings = - [ - "Article D521-1"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - (ressources_menage_ >$ plafond__i_i_d521_3_) - then - if - array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - >! integer_of_string "1" - then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.08" - else money_of_cents_string "0" - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 74; - start_column = 3; - end_line = 75; - end_column = 44; - law_headings = - [ - "Article D521-1"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - (ressources_menage_ >$ plafond__i_d521_3_ - && ressources_menage_ <=$ plafond__i_i_d521_3_) - then - if - array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - >! integer_of_string "1" - then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.16" - else money_of_cents_string "0" - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 35; - start_column = 3; - end_line = 35; - end_column = 41; - law_headings = - [ - "Article D521-1"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - (ressources_menage_ <=$ plafond__i_d521_3_) - then - if - array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - >! integer_of_string "1" - then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.32" - else money_of_cents_string "0" - else raise EmptyError); - |] - (fun (_ : _) -> - log_decision_taken - { - filename = ""; - start_line = 0; - start_column = 1; - end_line = 0; - end_column = 1; - law_headings = []; - } - false) - (fun (_ : _) -> raise EmptyError) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 112; - start_column = 12; - end_line = 112; - end_column = 48; - law_headings = [ "Prologue" ]; - })) + try + try montant_initial_base_deuxieme_enfant_ () + with EmptyError -> + handle_default + [| + (fun (_ : _) -> + if ressources_menage_ >$ plafond__i_i_d521_3_ then + if + array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + >! integer_of_string "1" + then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.08" + else money_of_cents_string "0" + else raise EmptyError); + (fun (_ : _) -> + if + ressources_menage_ >$ plafond__i_d521_3_ + && ressources_menage_ <=$ plafond__i_i_d521_3_ + then + if + array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + >! integer_of_string "1" + then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.16" + else money_of_cents_string "0" + else raise EmptyError); + (fun (_ : _) -> + if ressources_menage_ <=$ plafond__i_d521_3_ then + if + array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + >! integer_of_string "1" + then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.32" + else money_of_cents_string "0" + else raise EmptyError); + |] + (fun (_ : _) -> false) + (fun (_ : _) -> raise EmptyError) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 112; + start_column = 12; + end_line = 112; + end_column = 48; + law_headings = [ "Prologue" ]; + }) in let rapport_enfants_total_moyen_ : decimal = - log_variable_definition - [ "AllocationsFamiliales"; "rapport_enfants_total_moyen" ] - embed_decimal - (try - try rapport_enfants_total_moyen_ () - with EmptyError -> - if nombre_total_enfants_ = decimal_of_string "0." then decimal_of_string "0." - else nombre_moyen_enfants_ /& nombre_total_enfants_ - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 114; - start_column = 12; - end_line = 114; - end_column = 39; - law_headings = [ "Prologue" ]; - })) + try + try rapport_enfants_total_moyen_ () + with EmptyError -> + if nombre_total_enfants_ = decimal_of_string "0." then decimal_of_string "0." + else nombre_moyen_enfants_ /& nombre_total_enfants_ + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 114; + start_column = 12; + end_line = 114; + end_column = 39; + law_headings = [ "Prologue" ]; + }) in let montant_initial_metropole_majoration_ : enfant -> money = - log_variable_definition - [ "AllocationsFamiliales"; "montant_initial_métropole_majoration" ] - unembeddable - (try - try montant_initial_metropole_majoration_ () - with EmptyError -> ( - fun (param_ : enfant) -> - try - handle_default - [| - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./epilogue.catala_fr"; - start_line = 29; - start_column = 5; - end_line = 29; - end_column = 44; - law_headings = [ "Règles diverses"; "Épilogue" ]; - } - (not - (log_end_call - [ "AllocationsFamiliales"; "droit_ouvert_majoration" ] - (log_variable_definition - [ "AllocationsFamiliales"; "droit_ouvert_majoration"; "output" ] - unembeddable - (log_begin_call - [ "AllocationsFamiliales"; "droit_ouvert_majoration" ] - droit_ouvert_majoration_ - (log_variable_definition - [ - "AllocationsFamiliales"; - "droit_ouvert_majoration"; - "input"; - ] - unembeddable param_))))) - then money_of_cents_string "0" - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 132; - start_column = 3; - end_line = 132; - end_column = 41; - law_headings = - [ - "Article D521-1"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - (ressources_menage_ >$ plafond__i_i_d521_3_ - && log_end_call - [ "AllocationsFamiliales"; "droit_ouvert_majoration" ] - (log_variable_definition - [ "AllocationsFamiliales"; "droit_ouvert_majoration"; "output" ] - unembeddable - (log_begin_call - [ "AllocationsFamiliales"; "droit_ouvert_majoration" ] - droit_ouvert_majoration_ - (log_variable_definition - [ - "AllocationsFamiliales"; "droit_ouvert_majoration"; "input"; - ] - unembeddable param_)))) - then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.04" - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 95; - start_column = 3; - end_line = 96; - end_column = 44; - law_headings = - [ - "Article D521-1"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - ((ressources_menage_ >$ plafond__i_d521_3_ - && ressources_menage_ <=$ plafond__i_i_d521_3_) - && log_end_call - [ "AllocationsFamiliales"; "droit_ouvert_majoration" ] - (log_variable_definition - [ "AllocationsFamiliales"; "droit_ouvert_majoration"; "output" ] - unembeddable - (log_begin_call - [ "AllocationsFamiliales"; "droit_ouvert_majoration" ] - droit_ouvert_majoration_ - (log_variable_definition - [ - "AllocationsFamiliales"; "droit_ouvert_majoration"; "input"; - ] - unembeddable param_)))) - then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.08" - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 55; - start_column = 3; - end_line = 55; - end_column = 41; - law_headings = - [ - "Article D521-1"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - (ressources_menage_ <=$ plafond__i_d521_3_ - && log_end_call - [ "AllocationsFamiliales"; "droit_ouvert_majoration" ] - (log_variable_definition - [ "AllocationsFamiliales"; "droit_ouvert_majoration"; "output" ] - unembeddable - (log_begin_call - [ "AllocationsFamiliales"; "droit_ouvert_majoration" ] - droit_ouvert_majoration_ - (log_variable_definition - [ - "AllocationsFamiliales"; "droit_ouvert_majoration"; "input"; - ] - unembeddable param_)))) - then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.16" - else raise EmptyError); - |] - (fun (_ : _) -> - log_decision_taken - { - filename = ""; - start_line = 0; - start_column = 1; - end_line = 0; - end_column = 1; - law_headings = []; - } - false) - (fun (_ : _) -> raise EmptyError) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 127; - start_column = 12; - end_line = 127; - end_column = 48; - law_headings = [ "Prologue" ]; - })) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 127; - start_column = 12; - end_line = 127; - end_column = 48; - law_headings = [ "Prologue" ]; - })) + try + try montant_initial_metropole_majoration_ () + with EmptyError -> ( + fun (param_ : enfant) -> + try + handle_default + [| + (fun (_ : _) -> + if not (droit_ouvert_majoration_ param_) then money_of_cents_string "0" + else raise EmptyError); + (fun (_ : _) -> + if ressources_menage_ >$ plafond__i_i_d521_3_ && droit_ouvert_majoration_ param_ + then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.04" + else raise EmptyError); + (fun (_ : _) -> + if + (ressources_menage_ >$ plafond__i_d521_3_ + && ressources_menage_ <=$ plafond__i_i_d521_3_) + && droit_ouvert_majoration_ param_ + then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.08" + else raise EmptyError); + (fun (_ : _) -> + if ressources_menage_ <=$ plafond__i_d521_3_ && droit_ouvert_majoration_ param_ + then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.16" + else raise EmptyError); + |] + (fun (_ : _) -> false) + (fun (_ : _) -> raise EmptyError) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 127; + start_column = 12; + end_line = 127; + end_column = 48; + law_headings = [ "Prologue" ]; + })) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 127; + start_column = 12; + end_line = 127; + end_column = 48; + law_headings = [ "Prologue" ]; + }) in let montant_verse_forfaitaire_ : money = - log_variable_definition - [ "AllocationsFamiliales"; "montant_versé_forfaitaire" ] - embed_money - (try - try montant_verse_forfaitaire_ () - with EmptyError -> - montant_verse_forfaitaire_par_enfant_ - *$ decimal_of_integer - (Array.fold_left - (fun (acc_ : integer) (enfant_ : _) -> - if - log_end_call - [ "AllocationsFamiliales"; "droit_ouvert_forfaitaire" ] - (log_variable_definition - [ "AllocationsFamiliales"; "droit_ouvert_forfaitaire"; "output" ] - unembeddable - (log_begin_call - [ "AllocationsFamiliales"; "droit_ouvert_forfaitaire" ] - droit_ouvert_forfaitaire_ - (log_variable_definition - [ "AllocationsFamiliales"; "droit_ouvert_forfaitaire"; "input" ] - unembeddable enfant_))) - then acc_ +! integer_of_string "1" - else acc_) - (integer_of_string "0") enfants_a_charge_) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 123; - start_column = 12; - end_line = 123; - end_column = 37; - law_headings = [ "Prologue" ]; - })) + try + try montant_verse_forfaitaire_ () + with EmptyError -> + montant_verse_forfaitaire_par_enfant_ + *$ decimal_of_integer + (Array.fold_left + (fun (acc_ : integer) (enfant_ : _) -> + if droit_ouvert_forfaitaire_ enfant_ then acc_ +! integer_of_string "1" else acc_) + (integer_of_string "0") enfants_a_charge_) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 123; + start_column = 12; + end_line = 123; + end_column = 37; + law_headings = [ "Prologue" ]; + }) in let montant_initial_base_ : money = - log_variable_definition - [ "AllocationsFamiliales"; "montant_initial_base" ] - embed_money - (try - try montant_initial_base_ () - with EmptyError -> ( - try - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 350; - start_column = 5; - end_line = 351; - end_column = 69; - law_headings = - [ - "Article D755-5"; - "Chapitre 5 : Prestations familiales et prestations assimilées"; - "Titre 5 : Départements d'outre-mer"; - "Livre 7 : Régimes divers - Dispositions diverses"; - "Partie réglementaire - Décrets simples"; - ]; - } - (prestations_familiales_dot_regime_outre_mer_l751_1_ - && array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - = integer_of_string "1") - then montant_initial_base_premier_enfant_ - else raise EmptyError - with EmptyError -> - montant_initial_base_deuxieme_enfant_ +$ montant_initial_base_troisieme_enfant_et_plus_) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 110; - start_column = 12; - end_line = 110; - end_column = 32; - law_headings = [ "Prologue" ]; - })) + try + try montant_initial_base_ () + with EmptyError -> ( + try + if + prestations_familiales_dot_regime_outre_mer_l751_1_ + && array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + = integer_of_string "1" + then montant_initial_base_premier_enfant_ + else raise EmptyError + with EmptyError -> + montant_initial_base_deuxieme_enfant_ +$ montant_initial_base_troisieme_enfant_et_plus_) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 110; + start_column = 12; + end_line = 110; + end_column = 32; + law_headings = [ "Prologue" ]; + }) in let montant_initial_majoration_ : enfant -> money = - log_variable_definition - [ "AllocationsFamiliales"; "montant_initial_majoration" ] - unembeddable - (try - try montant_initial_majoration_ () - with EmptyError -> ( - fun (param_ : enfant) -> - try - handle_default - [| - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 382; - start_column = 5; - end_line = 385; - end_column = 23; - law_headings = - [ - "Article D755-5"; - "Chapitre 5 : Prestations familiales et prestations assimilées"; - "Titre 5 : Départements d'outre-mer"; - "Livre 7 : Régimes divers - Dispositions diverses"; - "Partie réglementaire - Décrets simples"; - ]; - } - (log_end_call - [ "AllocationsFamiliales"; "droit_ouvert_majoration" ] - (log_variable_definition - [ "AllocationsFamiliales"; "droit_ouvert_majoration"; "output" ] - unembeddable - (log_begin_call - [ "AllocationsFamiliales"; "droit_ouvert_majoration" ] - droit_ouvert_majoration_ - (log_variable_definition - [ "AllocationsFamiliales"; "droit_ouvert_majoration"; "input" ] - unembeddable param_))) - && prestations_familiales_dot_regime_outre_mer_l751_1_ - && array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - = integer_of_string "1" - && param_.age >=! integer_of_string "16") - then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.0567" - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 373; - start_column = 5; - end_line = 376; - end_column = 42; - law_headings = - [ - "Article D755-5"; - "Chapitre 5 : Prestations familiales et prestations assimilées"; - "Titre 5 : Départements d'outre-mer"; - "Livre 7 : Régimes divers - Dispositions diverses"; - "Partie réglementaire - Décrets simples"; - ]; - } - (log_end_call - [ "AllocationsFamiliales"; "droit_ouvert_majoration" ] - (log_variable_definition - [ "AllocationsFamiliales"; "droit_ouvert_majoration"; "output" ] - unembeddable - (log_begin_call - [ "AllocationsFamiliales"; "droit_ouvert_majoration" ] - droit_ouvert_majoration_ - (log_variable_definition - [ "AllocationsFamiliales"; "droit_ouvert_majoration"; "input" ] - unembeddable param_))) - && prestations_familiales_dot_regime_outre_mer_l751_1_ - && array_length enfants_a_charge_droit_ouvert_prestation_familiale_ - = integer_of_string "1" - && param_.age >=! integer_of_string "11" - && param_.age - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 22; - start_column = 14; - end_line = 22; - end_column = 40; - law_headings = - [ - "Article D521-1"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - true) - (fun (_ : _) -> - log_end_call - [ "AllocationsFamiliales"; "montant_initial_métropole_majoration" ] - (log_variable_definition - [ - "AllocationsFamiliales"; "montant_initial_métropole_majoration"; "output"; - ] - unembeddable - (log_begin_call - [ "AllocationsFamiliales"; "montant_initial_métropole_majoration" ] - montant_initial_metropole_majoration_ - (log_variable_definition - [ - "AllocationsFamiliales"; - "montant_initial_métropole_majoration"; - "input"; - ] - unembeddable param_)))) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 128; - start_column = 12; - end_line = 128; - end_column = 38; - law_headings = [ "Prologue" ]; - })) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 128; - start_column = 12; - end_line = 128; - end_column = 38; - law_headings = [ "Prologue" ]; - })) + try + try montant_initial_majoration_ () + with EmptyError -> ( + fun (param_ : enfant) -> + try + handle_default + [| + (fun (_ : _) -> + if + droit_ouvert_majoration_ param_ + && prestations_familiales_dot_regime_outre_mer_l751_1_ + && array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + = integer_of_string "1" + && param_.age >=! integer_of_string "16" + then prestations_familiales_dot_base_mensuelle_ *$ decimal_of_string "0.0567" + else raise EmptyError); + (fun (_ : _) -> + if + droit_ouvert_majoration_ param_ + && prestations_familiales_dot_regime_outre_mer_l751_1_ + && array_length enfants_a_charge_droit_ouvert_prestation_familiale_ + = integer_of_string "1" + && param_.age >=! integer_of_string "11" + && param_.age true) + (fun (_ : _) -> montant_initial_metropole_majoration_ param_) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 128; + start_column = 12; + end_line = 128; + end_column = 38; + law_headings = [ "Prologue" ]; + })) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 128; + start_column = 12; + end_line = 128; + end_column = 38; + law_headings = [ "Prologue" ]; + }) in let montant_verse_complement_pour_forfaitaire_ : money = - log_variable_definition - [ "AllocationsFamiliales"; "montant_versé_complément_pour_forfaitaire" ] - embed_money - (try - try montant_verse_complement_pour_forfaitaire_ () - with EmptyError -> - handle_default - [| - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 272; - start_column = 5; - end_line = 274; - end_column = 41; - law_headings = - [ - "Article D521-2"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - (ressources_menage_ >$ plafond__i_i_d521_3_ - && ressources_menage_ - <=$ plafond__i_i_d521_3_ - +$ (montant_verse_forfaitaire_ *$ decimal_of_string "12.")) - then - (plafond__i_i_d521_3_ - +$ ((montant_verse_forfaitaire_ *$ decimal_of_string "12.") -$ ressources_menage_) - ) - *$ (decimal_of_string "1." /& decimal_of_string "12.") - else raise EmptyError); - (fun (_ : _) -> - if - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 262; - start_column = 5; - end_line = 264; - end_column = 42; - law_headings = - [ - "Article D521-2"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - (ressources_menage_ >$ plafond__i_d521_3_ - && ressources_menage_ - <=$ plafond__i_d521_3_ - +$ (montant_verse_forfaitaire_ *$ decimal_of_string "12.")) - then - (plafond__i_d521_3_ - +$ ((montant_verse_forfaitaire_ *$ decimal_of_string "12.") -$ ressources_menage_) - ) - *$ (decimal_of_string "1." /& decimal_of_string "12.") - else raise EmptyError); - |] - (fun (_ : _) -> - log_decision_taken - { - filename = "./securite_sociale_D.catala_fr"; - start_line = 280; - start_column = 14; - end_line = 280; - end_column = 55; - law_headings = - [ - "Article D521-2"; - "Chapitre 1er : Allocations familiales"; - "Titre 2 : Prestations générales d'entretien"; - "Livre 5 : Prestations familiales et prestations assimilées"; - "Partie réglementaire - Décrets simples"; - ]; - } - true) - (fun (_ : _) -> money_of_cents_string "0") - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 137; - start_column = 12; - end_line = 137; - end_column = 53; - law_headings = [ "Prologue" ]; - })) + try + try montant_verse_complement_pour_forfaitaire_ () + with EmptyError -> + handle_default + [| + (fun (_ : _) -> + if + ressources_menage_ >$ plafond__i_i_d521_3_ + && ressources_menage_ + <=$ plafond__i_i_d521_3_ + +$ (montant_verse_forfaitaire_ *$ decimal_of_string "12.") + then + (plafond__i_i_d521_3_ + +$ ((montant_verse_forfaitaire_ *$ decimal_of_string "12.") -$ ressources_menage_)) + *$ (decimal_of_string "1." /& decimal_of_string "12.") + else raise EmptyError); + (fun (_ : _) -> + if + ressources_menage_ >$ plafond__i_d521_3_ + && ressources_menage_ + <=$ plafond__i_d521_3_ +$ (montant_verse_forfaitaire_ *$ decimal_of_string "12.") + then + (plafond__i_d521_3_ + +$ ((montant_verse_forfaitaire_ *$ decimal_of_string "12.") -$ ressources_menage_)) + *$ (decimal_of_string "1." /& decimal_of_string "12.") + else raise EmptyError); + |] + (fun (_ : _) -> true) + (fun (_ : _) -> money_of_cents_string "0") + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 137; + start_column = 12; + end_line = 137; + end_column = 53; + law_headings = [ "Prologue" ]; + }) in let montant_avec_garde_alternee_base_ : money = - log_variable_definition - [ "AllocationsFamiliales"; "montant_avec_garde_alternée_base" ] - embed_money - (try - try montant_avec_garde_alternee_base_ () - with EmptyError -> montant_initial_base_ *$ rapport_enfants_total_moyen_ - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 117; - start_column = 12; - end_line = 117; - end_column = 44; - law_headings = [ "Prologue" ]; - })) + try + try montant_avec_garde_alternee_base_ () + with EmptyError -> montant_initial_base_ *$ rapport_enfants_total_moyen_ + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 117; + start_column = 12; + end_line = 117; + end_column = 44; + law_headings = [ "Prologue" ]; + }) in let montant_avec_garde_alternee_majoration_ : enfant -> money = - log_variable_definition - [ "AllocationsFamiliales"; "montant_avec_garde_alternée_majoration" ] - unembeddable - (try - try montant_avec_garde_alternee_majoration_ () - with EmptyError -> ( - fun (param_ : enfant) -> - try - log_end_call - [ "AllocationsFamiliales"; "montant_initial_majoration" ] - (log_variable_definition - [ "AllocationsFamiliales"; "montant_initial_majoration"; "output" ] - unembeddable - (log_begin_call - [ "AllocationsFamiliales"; "montant_initial_majoration" ] - montant_initial_majoration_ - (log_variable_definition - [ "AllocationsFamiliales"; "montant_initial_majoration"; "input" ] - unembeddable param_))) - *$ - match - log_end_call - [ "AllocationsFamiliales"; "prise_en_compte" ] - (log_variable_definition - [ "AllocationsFamiliales"; "prise_en_compte"; "output" ] - unembeddable - (log_begin_call - [ "AllocationsFamiliales"; "prise_en_compte" ] - prise_en_compte_ - (log_variable_definition - [ "AllocationsFamiliales"; "prise_en_compte"; "input" ] - unembeddable param_))) - with - | Complete _ -> decimal_of_string "1." - | Partagee _ -> decimal_of_string "0.5" - | Zero _ -> decimal_of_string "0." - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 129; - start_column = 12; - end_line = 129; - end_column = 50; - law_headings = [ "Prologue" ]; - })) - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 129; - start_column = 12; - end_line = 129; - end_column = 50; - law_headings = [ "Prologue" ]; - })) + try + try montant_avec_garde_alternee_majoration_ () + with EmptyError -> ( + fun (param_ : enfant) -> + try + montant_initial_majoration_ param_ + *$ + match prise_en_compte_ param_ with + | Complete _ -> decimal_of_string "1." + | Partagee _ -> decimal_of_string "0.5" + | Zero _ -> decimal_of_string "0." + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 129; + start_column = 12; + end_line = 129; + end_column = 50; + law_headings = [ "Prologue" ]; + })) + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 129; + start_column = 12; + end_line = 129; + end_column = 50; + law_headings = [ "Prologue" ]; + }) in let montant_verse_base_ : money = - log_variable_definition - [ "AllocationsFamiliales"; "montant_versé_base" ] - embed_money - (try - try montant_verse_base_ () - with EmptyError -> - if droit_ouvert_base_ then montant_avec_garde_alternee_base_ - else money_of_cents_string "0" - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 118; - start_column = 12; - end_line = 118; - end_column = 30; - law_headings = [ "Prologue" ]; - })) + try + try montant_verse_base_ () + with EmptyError -> + if droit_ouvert_base_ then montant_avec_garde_alternee_base_ else money_of_cents_string "0" + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 118; + start_column = 12; + end_line = 118; + end_column = 30; + law_headings = [ "Prologue" ]; + }) in let montant_verse_majoration_ : money = - log_variable_definition - [ "AllocationsFamiliales"; "montant_versé_majoration" ] - embed_money - (try - try montant_verse_majoration_ () - with EmptyError -> - if droit_ouvert_base_ then - Array.fold_left - (fun (acc_ : money) (enfant_ : _) -> - acc_ - +$ log_end_call - [ "AllocationsFamiliales"; "montant_avec_garde_alternée_majoration" ] - (log_variable_definition - [ - "AllocationsFamiliales"; - "montant_avec_garde_alternée_majoration"; - "output"; - ] - unembeddable - (log_begin_call - [ "AllocationsFamiliales"; "montant_avec_garde_alternée_majoration" ] - montant_avec_garde_alternee_majoration_ - (log_variable_definition - [ - "AllocationsFamiliales"; - "montant_avec_garde_alternée_majoration"; - "input"; - ] - unembeddable enfant_)))) - (money_of_cents_string "0") enfants_a_charge_ - else money_of_cents_string "0" - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 130; - start_column = 12; - end_line = 130; - end_column = 36; - law_headings = [ "Prologue" ]; - })) + try + try montant_verse_majoration_ () + with EmptyError -> + if droit_ouvert_base_ then + Array.fold_left + (fun (acc_ : money) (enfant_ : _) -> + acc_ +$ montant_avec_garde_alternee_majoration_ enfant_) + (money_of_cents_string "0") enfants_a_charge_ + else money_of_cents_string "0" + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 130; + start_column = 12; + end_line = 130; + end_column = 36; + law_headings = [ "Prologue" ]; + }) in let montant_base_complement_pour_base_et_majoration_ : money = - log_variable_definition - [ "AllocationsFamiliales"; "montant_base_complément_pour_base_et_majoration" ] - embed_money - (try - try montant_base_complement_pour_base_et_majoration_ () - with EmptyError -> montant_verse_base_ +$ montant_verse_majoration_ - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 134; - start_column = 12; - end_line = 134; - end_column = 59; - law_headings = [ "Prologue" ]; - })) + try + try montant_base_complement_pour_base_et_majoration_ () + with EmptyError -> montant_verse_base_ +$ montant_verse_majoration_ + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 134; + start_column = 12; + end_line = 134; + end_column = 59; + law_headings = [ "Prologue" ]; + }) in let montant_verse_complement_pour_base_et_majoration_ : money = - log_variable_definition - [ "AllocationsFamiliales"; "montant_versé_complément_pour_base_et_majoration" ] - embed_money - (try - try montant_verse_complement_pour_base_et_majoration_ () - with EmptyError -> - if droit_ouvert_complement_ then - log_end_call - [ "AllocationsFamiliales"; "complément_dégressif" ] - (log_variable_definition - [ "AllocationsFamiliales"; "complément_dégressif"; "output" ] - unembeddable - (log_begin_call - [ "AllocationsFamiliales"; "complément_dégressif" ] - complement_degressif_ - (log_variable_definition - [ "AllocationsFamiliales"; "complément_dégressif"; "input" ] - unembeddable montant_base_complement_pour_base_et_majoration_))) - else money_of_cents_string "0" - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 136; - start_column = 12; - end_line = 136; - end_column = 60; - law_headings = [ "Prologue" ]; - })) + try + try montant_verse_complement_pour_base_et_majoration_ () + with EmptyError -> + if droit_ouvert_complement_ then + complement_degressif_ montant_base_complement_pour_base_et_majoration_ + else money_of_cents_string "0" + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 136; + start_column = 12; + end_line = 136; + end_column = 60; + law_headings = [ "Prologue" ]; + }) in let montant_verse_ : money = - log_variable_definition - [ "AllocationsFamiliales"; "montant_versé" ] - embed_money - (try - try montant_verse_ () - with EmptyError -> - if droit_ouvert_base_ then - montant_verse_base_ - +$ (montant_verse_majoration_ - +$ (montant_verse_forfaitaire_ - +$ (montant_verse_complement_pour_base_et_majoration_ - +$ montant_verse_complement_pour_forfaitaire_))) - else money_of_cents_string "0" - with EmptyError -> - raise - (NoValueProvided - { - filename = "./prologue.catala_fr"; - start_line = 106; - start_column = 12; - end_line = 106; - end_column = 25; - law_headings = [ "Prologue" ]; - })) + try + try montant_verse_ () + with EmptyError -> + if droit_ouvert_base_ then + montant_verse_base_ + +$ (montant_verse_majoration_ + +$ (montant_verse_forfaitaire_ + +$ (montant_verse_complement_pour_base_et_majoration_ + +$ montant_verse_complement_pour_forfaitaire_))) + else money_of_cents_string "0" + with EmptyError -> + raise + (NoValueProvided + { + filename = "./prologue.catala_fr"; + start_line = 106; + start_column = 12; + end_line = 106; + end_column = 25; + law_headings = [ "Prologue" ]; + }) in let (_ : unit) = if @@ -4139,271 +2165,189 @@ let interface_allocations_familiales interface_allocations_familiales_in.personne_charge_effective_permanente_remplit_titre_I_in in let date_courante_ : date = - log_variable_definition - [ "InterfaceAllocationsFamiliales"; "date_courante" ] - embed_date - (try date_courante_ () - with EmptyError -> - raise - (NoValueProvided - { - filename = "./epilogue.catala_fr"; - start_line = 78; - start_column = 12; - end_line = 78; - end_column = 25; - law_headings = [ "Interface du programme"; "Épilogue" ]; - })) + try date_courante_ () + with EmptyError -> + raise + (NoValueProvided + { + filename = "./epilogue.catala_fr"; + start_line = 78; + start_column = 12; + end_line = 78; + end_column = 25; + law_headings = [ "Interface du programme"; "Épilogue" ]; + }) in let enfants_ : enfant_entree array = - log_variable_definition - [ "InterfaceAllocationsFamiliales"; "enfants" ] - (embed_array embed_enfant_entree) - (try enfants_ () - with EmptyError -> - raise - (NoValueProvided - { - filename = "./epilogue.catala_fr"; - start_line = 79; - start_column = 12; - end_line = 79; - end_column = 19; - law_headings = [ "Interface du programme"; "Épilogue" ]; - })) + try enfants_ () + with EmptyError -> + raise + (NoValueProvided + { + filename = "./epilogue.catala_fr"; + start_line = 79; + start_column = 12; + end_line = 79; + end_column = 19; + law_headings = [ "Interface du programme"; "Épilogue" ]; + }) in let ressources_menage_ : money = - log_variable_definition - [ "InterfaceAllocationsFamiliales"; "ressources_ménage" ] - embed_money - (try ressources_menage_ () - with EmptyError -> - raise - (NoValueProvided - { - filename = "./epilogue.catala_fr"; - start_line = 82; - start_column = 12; - end_line = 82; - end_column = 29; - law_headings = [ "Interface du programme"; "Épilogue" ]; - })) + try ressources_menage_ () + with EmptyError -> + raise + (NoValueProvided + { + filename = "./epilogue.catala_fr"; + start_line = 82; + start_column = 12; + end_line = 82; + end_column = 29; + law_headings = [ "Interface du programme"; "Épilogue" ]; + }) in let residence_ : collectivite = - log_variable_definition - [ "InterfaceAllocationsFamiliales"; "résidence" ] - embed_collectivite - (try residence_ () - with EmptyError -> - raise - (NoValueProvided - { - filename = "./epilogue.catala_fr"; - start_line = 83; - start_column = 12; - end_line = 83; - end_column = 21; - law_headings = [ "Interface du programme"; "Épilogue" ]; - })) + try residence_ () + with EmptyError -> + raise + (NoValueProvided + { + filename = "./epilogue.catala_fr"; + start_line = 83; + start_column = 12; + end_line = 83; + end_column = 21; + law_headings = [ "Interface du programme"; "Épilogue" ]; + }) in let personne_charge_effective_permanente_est_parent_ : bool = - log_variable_definition - [ "InterfaceAllocationsFamiliales"; "personne_charge_effective_permanente_est_parent" ] - embed_bool - (try try personne_charge_effective_permanente_est_parent_ () with EmptyError -> false - with EmptyError -> - raise - (NoValueProvided - { - filename = "./epilogue.catala_fr"; - start_line = 85; - start_column = 12; - end_line = 85; - end_column = 59; - law_headings = [ "Interface du programme"; "Épilogue" ]; - })) + try try personne_charge_effective_permanente_est_parent_ () with EmptyError -> false + with EmptyError -> + raise + (NoValueProvided + { + filename = "./epilogue.catala_fr"; + start_line = 85; + start_column = 12; + end_line = 85; + end_column = 59; + law_headings = [ "Interface du programme"; "Épilogue" ]; + }) in let personne_charge_effective_permanente_remplit_titre__i_ : bool = - log_variable_definition - [ "InterfaceAllocationsFamiliales"; "personne_charge_effective_permanente_remplit_titre_I" ] - embed_bool - (try try personne_charge_effective_permanente_remplit_titre__i_ () with EmptyError -> false - with EmptyError -> - raise - (NoValueProvided - { - filename = "./epilogue.catala_fr"; - start_line = 86; - start_column = 12; - end_line = 86; - end_column = 64; - law_headings = [ "Interface du programme"; "Épilogue" ]; - })) + try try personne_charge_effective_permanente_remplit_titre__i_ () with EmptyError -> false + with EmptyError -> + raise + (NoValueProvided + { + filename = "./epilogue.catala_fr"; + start_line = 86; + start_column = 12; + end_line = 86; + end_column = 64; + law_headings = [ "Interface du programme"; "Épilogue" ]; + }) in let enfants_a_charge_ : enfant array = - log_variable_definition - [ "InterfaceAllocationsFamiliales"; "enfants_à_charge" ] - (embed_array embed_enfant) - (try - try enfants_a_charge_ () - with EmptyError -> - Array.map - (fun (enfant_ : _) -> - { - identifiant = enfant_.d_identifiant; - obligation_scolaire = - (if enfant_.d_date_de_naissance +@ duration_of_numbers 3 0 0 >=@ date_courante_ - then Avant () - else if - enfant_.d_date_de_naissance +@ duration_of_numbers 16 0 0 >=@ date_courante_ - then Pendant () - else Apres ()); - remuneration_mensuelle = enfant_.d_remuneration_mensuelle; - date_de_naissance = enfant_.d_date_de_naissance; - age = - year_of_date - (date_of_numbers 0 1 1 +@ (date_courante_ -@ enfant_.d_date_de_naissance)); - prise_en_charge = enfant_.d_prise_en_charge; - a_deja_ouvert_droit_aux_allocations_familiales = - enfant_.d_a_deja_ouvert_droit_aux_allocations_familiales; - }) - enfants_ - with EmptyError -> - raise - (NoValueProvided - { - filename = "./epilogue.catala_fr"; - start_line = 80; - start_column = 12; - end_line = 80; - end_column = 28; - law_headings = [ "Interface du programme"; "Épilogue" ]; - })) + try + try enfants_a_charge_ () + with EmptyError -> + Array.map + (fun (enfant_ : _) -> + { + identifiant = enfant_.d_identifiant; + obligation_scolaire = + (if enfant_.d_date_de_naissance +@ duration_of_numbers 3 0 0 >=@ date_courante_ then + Avant () + else if enfant_.d_date_de_naissance +@ duration_of_numbers 16 0 0 >=@ date_courante_ + then Pendant () + else Apres ()); + remuneration_mensuelle = enfant_.d_remuneration_mensuelle; + date_de_naissance = enfant_.d_date_de_naissance; + age = + year_of_date + (date_of_numbers 0 1 1 +@ (date_courante_ -@ enfant_.d_date_de_naissance)); + prise_en_charge = enfant_.d_prise_en_charge; + a_deja_ouvert_droit_aux_allocations_familiales = + enfant_.d_a_deja_ouvert_droit_aux_allocations_familiales; + }) + enfants_ + with EmptyError -> + raise + (NoValueProvided + { + filename = "./epilogue.catala_fr"; + start_line = 80; + start_column = 12; + end_line = 80; + end_column = 28; + law_headings = [ "Interface du programme"; "Épilogue" ]; + }) in let allocations_familiales_dot_personne_charge_effective_permanente_est_parent_ : unit -> bool = fun (_ : unit) -> - log_variable_definition - [ - "InterfaceAllocationsFamiliales"; - "allocations_familiales.personne_charge_effective_permanente_est_parent"; - ] - embed_bool - (try - if - log_decision_taken - { - filename = "./epilogue.catala_fr"; - start_line = 95; - start_column = 20; - end_line = 95; - end_column = 67; - law_headings = [ "Interface du programme"; "Épilogue" ]; - } - personne_charge_effective_permanente_est_parent_ - then true - else raise EmptyError - with EmptyError -> false) + try if personne_charge_effective_permanente_est_parent_ then true else raise EmptyError + with EmptyError -> false in let allocations_familiales_dot_personne_charge_effective_permanente_remplit_titre__i_ : unit -> bool = fun (_ : unit) -> - log_variable_definition - [ - "InterfaceAllocationsFamiliales"; - "allocations_familiales.personne_charge_effective_permanente_remplit_titre_I"; - ] - embed_bool - (try - if - log_decision_taken - { - filename = "./epilogue.catala_fr"; - start_line = 98; - start_column = 20; - end_line = 98; - end_column = 72; - law_headings = [ "Interface du programme"; "Épilogue" ]; - } - personne_charge_effective_permanente_remplit_titre__i_ - then true - else raise EmptyError - with EmptyError -> false) + try if personne_charge_effective_permanente_remplit_titre__i_ then true else raise EmptyError + with EmptyError -> false in let allocations_familiales_dot_ressources_menage_ : unit -> money = - fun (_ : unit) -> - log_variable_definition - [ "InterfaceAllocationsFamiliales"; "allocations_familiales.ressources_ménage" ] - embed_money ressources_menage_ - in - let allocations_familiales_dot_residence_ : unit -> collectivite = - fun (_ : unit) -> - log_variable_definition - [ "InterfaceAllocationsFamiliales"; "allocations_familiales.résidence" ] - embed_collectivite residence_ - in - let allocations_familiales_dot_date_courante_ : unit -> date = - fun (_ : unit) -> - log_variable_definition - [ "InterfaceAllocationsFamiliales"; "allocations_familiales.date_courante" ] - embed_date date_courante_ + fun (_ : unit) -> ressources_menage_ in + let allocations_familiales_dot_residence_ : unit -> collectivite = fun (_ : unit) -> residence_ in + let allocations_familiales_dot_date_courante_ : unit -> date = fun (_ : unit) -> date_courante_ in let allocations_familiales_dot_enfants_a_charge_ : unit -> enfant array = - fun (_ : unit) -> - log_variable_definition - [ "InterfaceAllocationsFamiliales"; "allocations_familiales.enfants_à_charge" ] - (embed_array embed_enfant) enfants_a_charge_ + fun (_ : unit) -> enfants_a_charge_ in let result_ : allocations_familiales_out = - log_end_call - [ "InterfaceAllocationsFamiliales"; "allocations_familiales"; "AllocationsFamiliales" ] - (log_begin_call - [ "InterfaceAllocationsFamiliales"; "allocations_familiales"; "AllocationsFamiliales" ] - allocations_familiales - { - personne_charge_effective_permanente_est_parent_in = - allocations_familiales_dot_personne_charge_effective_permanente_est_parent_; - personne_charge_effective_permanente_remplit_titre_I_in = - allocations_familiales_dot_personne_charge_effective_permanente_remplit_titre__i_; - ressources_menage_in = allocations_familiales_dot_ressources_menage_; - residence_in = allocations_familiales_dot_residence_; - date_courante_in = allocations_familiales_dot_date_courante_; - enfants_a_charge_in = allocations_familiales_dot_enfants_a_charge_; - enfants_a_charge_droit_ouvert_prestation_familiale_in = - (fun (_ : unit) -> raise EmptyError); - prise_en_compte_in = (fun (_ : unit) -> raise EmptyError); - versement_in = (fun (_ : unit) -> raise EmptyError); - montant_verse_in = (fun (_ : unit) -> raise EmptyError); - droit_ouvert_base_in = (fun (_ : unit) -> raise EmptyError); - montant_initial_base_in = (fun (_ : unit) -> raise EmptyError); - montant_initial_base_premier_enfant_in = (fun (_ : unit) -> raise EmptyError); - montant_initial_base_deuxieme_enfant_in = (fun (_ : unit) -> raise EmptyError); - montant_initial_base_troisieme_enfant_et_plus_in = (fun (_ : unit) -> raise EmptyError); - rapport_enfants_total_moyen_in = (fun (_ : unit) -> raise EmptyError); - nombre_moyen_enfants_in = (fun (_ : unit) -> raise EmptyError); - nombre_total_enfants_in = (fun (_ : unit) -> raise EmptyError); - montant_avec_garde_alternee_base_in = (fun (_ : unit) -> raise EmptyError); - montant_verse_base_in = (fun (_ : unit) -> raise EmptyError); - droit_ouvert_forfaitaire_in = (fun (_ : unit) -> raise EmptyError); - montant_verse_forfaitaire_par_enfant_in = (fun (_ : unit) -> raise EmptyError); - montant_verse_forfaitaire_in = (fun (_ : unit) -> raise EmptyError); - droit_ouvert_majoration_in = (fun (_ : unit) -> raise EmptyError); - montant_initial_metropole_majoration_in = (fun (_ : unit) -> raise EmptyError); - montant_initial_majoration_in = (fun (_ : unit) -> raise EmptyError); - montant_avec_garde_alternee_majoration_in = (fun (_ : unit) -> raise EmptyError); - montant_verse_majoration_in = (fun (_ : unit) -> raise EmptyError); - droit_ouvert_complement_in = (fun (_ : unit) -> raise EmptyError); - montant_base_complement_pour_base_et_majoration_in = (fun (_ : unit) -> raise EmptyError); - complement_degressif_in = (fun (_ : unit) -> raise EmptyError); - montant_verse_complement_pour_base_et_majoration_in = - (fun (_ : unit) -> raise EmptyError); - montant_verse_complement_pour_forfaitaire_in = (fun (_ : unit) -> raise EmptyError); - nombre_enfants_l521_1_in = (fun (_ : unit) -> raise EmptyError); - age_minimum_alinea_1_l521_3_in = (fun (_ : unit) -> raise EmptyError); - nombre_enfants_alinea_2_l521_3_in = (fun (_ : unit) -> raise EmptyError); - est_enfant_le_plus_age_in = (fun (_ : unit) -> raise EmptyError); - plafond_I_d521_3_in = (fun (_ : unit) -> raise EmptyError); - plafond_II_d521_3_in = (fun (_ : unit) -> raise EmptyError); - }) + allocations_familiales + { + personne_charge_effective_permanente_est_parent_in = + allocations_familiales_dot_personne_charge_effective_permanente_est_parent_; + personne_charge_effective_permanente_remplit_titre_I_in = + allocations_familiales_dot_personne_charge_effective_permanente_remplit_titre__i_; + ressources_menage_in = allocations_familiales_dot_ressources_menage_; + residence_in = allocations_familiales_dot_residence_; + date_courante_in = allocations_familiales_dot_date_courante_; + enfants_a_charge_in = allocations_familiales_dot_enfants_a_charge_; + enfants_a_charge_droit_ouvert_prestation_familiale_in = (fun (_ : unit) -> raise EmptyError); + prise_en_compte_in = (fun (_ : unit) -> raise EmptyError); + versement_in = (fun (_ : unit) -> raise EmptyError); + montant_verse_in = (fun (_ : unit) -> raise EmptyError); + droit_ouvert_base_in = (fun (_ : unit) -> raise EmptyError); + montant_initial_base_in = (fun (_ : unit) -> raise EmptyError); + montant_initial_base_premier_enfant_in = (fun (_ : unit) -> raise EmptyError); + montant_initial_base_deuxieme_enfant_in = (fun (_ : unit) -> raise EmptyError); + montant_initial_base_troisieme_enfant_et_plus_in = (fun (_ : unit) -> raise EmptyError); + rapport_enfants_total_moyen_in = (fun (_ : unit) -> raise EmptyError); + nombre_moyen_enfants_in = (fun (_ : unit) -> raise EmptyError); + nombre_total_enfants_in = (fun (_ : unit) -> raise EmptyError); + montant_avec_garde_alternee_base_in = (fun (_ : unit) -> raise EmptyError); + montant_verse_base_in = (fun (_ : unit) -> raise EmptyError); + droit_ouvert_forfaitaire_in = (fun (_ : unit) -> raise EmptyError); + montant_verse_forfaitaire_par_enfant_in = (fun (_ : unit) -> raise EmptyError); + montant_verse_forfaitaire_in = (fun (_ : unit) -> raise EmptyError); + droit_ouvert_majoration_in = (fun (_ : unit) -> raise EmptyError); + montant_initial_metropole_majoration_in = (fun (_ : unit) -> raise EmptyError); + montant_initial_majoration_in = (fun (_ : unit) -> raise EmptyError); + montant_avec_garde_alternee_majoration_in = (fun (_ : unit) -> raise EmptyError); + montant_verse_majoration_in = (fun (_ : unit) -> raise EmptyError); + droit_ouvert_complement_in = (fun (_ : unit) -> raise EmptyError); + montant_base_complement_pour_base_et_majoration_in = (fun (_ : unit) -> raise EmptyError); + complement_degressif_in = (fun (_ : unit) -> raise EmptyError); + montant_verse_complement_pour_base_et_majoration_in = (fun (_ : unit) -> raise EmptyError); + montant_verse_complement_pour_forfaitaire_in = (fun (_ : unit) -> raise EmptyError); + nombre_enfants_l521_1_in = (fun (_ : unit) -> raise EmptyError); + age_minimum_alinea_1_l521_3_in = (fun (_ : unit) -> raise EmptyError); + nombre_enfants_alinea_2_l521_3_in = (fun (_ : unit) -> raise EmptyError); + est_enfant_le_plus_age_in = (fun (_ : unit) -> raise EmptyError); + plafond_I_d521_3_in = (fun (_ : unit) -> raise EmptyError); + plafond_II_d521_3_in = (fun (_ : unit) -> raise EmptyError); + } in let allocations_familiales_dot_personne_charge_effective_permanente_est_parent_ : bool = result_.personne_charge_effective_permanente_est_parent_out @@ -4504,21 +2448,18 @@ let interface_allocations_familiales let allocations_familiales_dot_plafond__i_d521_3_ : money = result_.plafond_I_d521_3_out in let allocations_familiales_dot_plafond__i_i_d521_3_ : money = result_.plafond_II_d521_3_out in let montant_verse_ : money = - log_variable_definition - [ "InterfaceAllocationsFamiliales"; "montant_versé" ] - embed_money - (try try montant_verse_ () with EmptyError -> allocations_familiales_dot_montant_verse_ - with EmptyError -> - raise - (NoValueProvided - { - filename = "./epilogue.catala_fr"; - start_line = 84; - start_column = 12; - end_line = 84; - end_column = 25; - law_headings = [ "Interface du programme"; "Épilogue" ]; - })) + try try montant_verse_ () with EmptyError -> allocations_familiales_dot_montant_verse_ + with EmptyError -> + raise + (NoValueProvided + { + filename = "./epilogue.catala_fr"; + start_line = 84; + start_column = 12; + end_line = 84; + end_column = 25; + law_headings = [ "Interface du programme"; "Épilogue" ]; + }) in { date_courante_out = date_courante_; diff --git a/french_law/python/catala_runtime.py b/french_law/python/catala_runtime.py index 20c98d6c..d54a7b21 100644 --- a/french_law/python/catala_runtime.py +++ b/french_law/python/catala_runtime.py @@ -12,7 +12,7 @@ from gmpy2 import log2, mpz, mpq, mpfr, mpc # type: ignore import datetime import dateutil.relativedelta # type: ignore -from typing import NewType, List, Callable, Tuple, Optional, TypeVar +from typing import NewType, List, Callable, Tuple, Optional, TypeVar, Iterable # ===== # Types @@ -25,6 +25,10 @@ Date = NewType('Date', datetime.date) Duration = NewType('Duration', object) +class Unit: + pass + + class SourcePosition: def __init__(self, filename: str, @@ -61,6 +65,58 @@ class NoValueProvided(Exception): def __init__(self, source_position: SourcePosition) -> None: self.source_position = SourcePosition + +def raise_(ex): + raise ex + + +class TryCatch: + def __init__(self, fun, *args, **kwargs): + self.fun = fun + self.args = args + self.kwargs = kwargs + + self.exception_types_and_handlers = [] + self.finalize = None + + def rescue(self, exception_types, handler): + if not isinstance(exception_types, Iterable): + exception_types = (exception_types,) + + self.exception_types_and_handlers.append((exception_types, handler)) + return self + + def ensure(self, finalize, *finalize_args, **finalize_kwargs): + if self.finalize is not None: + raise Exception('ensure() called twice') + + self.finalize = finalize + self.finalize_args = finalize_args + self.finalize_kwargs = finalize_kwargs + return self + + def __call__(self): + try: + return self.fun(*self.args, **self.kwargs) + + except BaseException as exc: + handler = self.find_applicable_handler(exc) + if handler is None: + raise + return handler(exc) + + finally: + if self.finalize is not None: + self.finalize() + + def find_applicable_handler(self, exc): + applicable_handlers = ( + handler + for exception_types, handler in self.exception_types_and_handlers + if isinstance(exc, exception_types) + ) + return next(applicable_handlers, None) + # ============================ # Constructors and conversions # ============================