├── tests ├── edges │ ├── empty │ │ ├── empty.fs │ │ ├── empty.output │ │ └── empty.c │ ├── return_zero │ │ ├── return_zero.output │ │ ├── return_zero.fs │ │ └── return_zero.c │ ├── ty_unbound │ │ ├── ty_unbound.output │ │ └── ty_unbound.fs │ ├── pat_with_vis │ │ ├── pat_with_vis.output │ │ └── pat_with_vis.fs │ ├── resolved_issues │ │ ├── resolved_issues.output │ │ └── variant_wrapper_auto_box.fs │ ├── unary_op_syntax │ │ ├── unary_op_syntax.output │ │ ├── unary_op_syntax.fs │ │ └── unary_op_syntax.c │ ├── newtype_in_records │ │ └── newtype_in_records.output │ ├── record_vs_generics │ │ ├── record_vs_generics.output │ │ └── record_vs_generics.fs │ ├── generic_right_angles │ │ ├── generic_right_angles.output │ │ └── generic_right_angles.fs │ ├── module_open_shadowed │ │ ├── module_open_shadowed.output │ │ ├── sub.fs │ │ ├── module_open_shadowed.fs │ │ └── module_open_shadowed_sub.c │ ├── pat_or_deep_branches │ │ ├── pat_or_deep_branches.output │ │ ├── pat_or_deep_branches.c │ │ └── pat_or_deep_branches.fs │ ├── union_generic_crash │ │ ├── union_generic_crash.output │ │ └── union_generic_crash.fs │ ├── match_nested_nonbinding │ │ ├── match_nested_nonbinding.output │ │ └── match_nested_nonbinding.fs │ ├── fun_forward_use │ │ ├── fun_forward_use.output │ │ ├── fun_forward_use.c │ │ └── fun_forward_use.fs │ ├── fun_monomorphization_bug │ │ ├── fun_monomorphization_bug.output │ │ └── fun_monomorphization_bug.fs │ ├── fun_generic_ty_degeneration │ │ └── fun_generic_ty_degeneration.output │ ├── match_parse_issue │ │ ├── match_parse_issue.output │ │ ├── match_parse_issue.c │ │ └── match_parse_issue.fs │ ├── match_with_no_arms │ │ ├── match_with_no_arms.output │ │ ├── match_with_no_arms.c │ │ └── match_with_no_arms.fs │ ├── union_generic_newtype_issue │ │ ├── union_generic_newtype_issue.output │ │ └── union_generic_newtype_issue.fs │ ├── recursive_ty_error_by_synonym │ │ ├── recursive_ty_error_by_synonym.output │ │ ├── recursive_ty_error_by_synonym.fs │ │ └── recursive_ty_error_by_synonym.c │ ├── union_generic_ty_error │ │ ├── union_generic_ty_error.output │ │ ├── union_generic_ty_error.c │ │ └── union_generic_ty_error.fs │ ├── monomorphization_bug_1 │ │ ├── monomorphization_bug_1.output │ │ └── monomorphization_bug_1.fs │ ├── fun_underlying_fun_forward_decl_issue │ │ ├── fun_underlying_fun_forward_decl_issue.output │ │ └── sub.fs │ └── ty_var_unified_unexpectedly │ │ ├── ty_var_unified_unexpectedly.output │ │ ├── ty_var_unified_unexpectedly.c │ │ └── ty_var_unified_unexpectedly.fs ├── primitives │ ├── own │ │ └── own.output │ ├── option │ │ ├── option.output │ │ └── option.fs │ ├── result │ │ └── result.output │ ├── effect_file_io │ │ ├── input.txt │ │ ├── output.txt │ │ ├── effect_file_io.output │ │ └── effect_file_io.fs │ ├── list_pat │ │ ├── list_pat.output │ │ └── list_pat.fs │ ├── never_ty │ │ └── never_ty.output │ ├── std_int │ │ └── std_int.output │ ├── std_iter │ │ └── std_iter.output │ ├── std_list │ │ └── std_list.output │ ├── std_loop │ │ └── std_loop.output │ ├── int_flavors │ │ └── int_flavors.output │ ├── list_equal │ │ ├── list_equal.output │ │ └── list_equal.fs │ ├── native_cast │ │ ├── native_cast.output │ │ ├── native_cast.fs │ │ └── native_cast.c │ ├── native_type │ │ └── native_type.output │ ├── nativeptr │ │ └── nativeptr.output │ ├── std_block │ │ └── std_block.output │ ├── std_option │ │ └── std_option.output │ ├── std_result │ │ └── std_result.output │ ├── std_string │ │ └── std_string.output │ ├── tuple_arg │ │ ├── tuple_arg.output │ │ └── tuple_arg.fs │ ├── tuple_equal │ │ └── tuple_equal.output │ ├── tuple_large │ │ ├── tuple_large.output │ │ └── tuple_large.fs │ ├── bool_if_expr │ │ ├── bool_if_expr.output │ │ ├── bool_if_expr.fs │ │ └── bool_if_expr.c │ ├── effect_region │ │ └── effect_region.output │ ├── int_operators │ │ └── int_operators.output │ ├── int_to_string │ │ ├── int_to_string.output │ │ └── int_to_string.fs │ ├── option_equal │ │ ├── option_equal.output │ │ └── option_equal.fs │ ├── string_length │ │ ├── string_length.output │ │ └── string_length.fs │ ├── tuple_string │ │ ├── tuple_string.output │ │ └── tuple_string.fs │ ├── union_runtime │ │ ├── union_runtime.output │ │ ├── union_runtime.fs │ │ └── union_runtime.c │ ├── union_string │ │ ├── union_string.output │ │ └── union_string.fs │ ├── bool_operators │ │ └── bool_operators.output │ ├── char_operators │ │ └── char_operators.output │ ├── list_operators │ │ └── list_operators.output │ ├── native_fun_call │ │ ├── native_fun_call.output │ │ └── native_fun_call.fs │ ├── string_operators │ │ └── string_operators.output │ ├── float │ │ └── float.output │ ├── std_native_interop │ │ └── std_native_interop.output │ ├── string_literal_raw │ │ ├── string_literal_raw.output │ │ └── string_literal_raw.fs │ ├── int_flavor_unsigned │ │ └── int_flavor_unsigned.output │ ├── obj_box_unbox │ │ └── obj_box_unbox.output │ ├── string_literal_escape │ │ ├── string_literal_escape.output │ │ ├── string_literal_escape.c │ │ └── string_literal_escape.fs │ ├── native_code │ │ └── native_code.output │ ├── native_fun_ptr │ │ └── native_fun_ptr.output │ ├── tuple │ │ ├── tuple.output │ │ └── tuple.fs │ ├── bool_if_expr_complicated │ │ ├── bool_if_expr_complicated.output │ │ └── bool_if_expr_complicated.fs │ ├── effect_assert │ │ ├── effect_assert.output │ │ ├── effect_assert.fs │ │ └── effect_assert.c │ └── effect_printfn │ │ ├── effect_printfn.output │ │ ├── effect_printfn.fs │ │ └── effect_printfn.c ├── features │ ├── modules │ │ ├── modules.output │ │ ├── sub.fs │ │ ├── modules_sub.c │ │ └── modules.fs │ ├── nav_ty │ │ ├── nav_ty.output │ │ ├── sub.fs │ │ └── nav_ty.fs │ ├── nav_var │ │ ├── nav_var.output │ │ ├── sub.fs │ │ ├── nav_var.fs │ │ ├── nav_var_sub.c │ │ └── nav_var.c │ ├── pat_as │ │ ├── pat_as.output │ │ └── pat_as.fs │ ├── pat_or │ │ └── pat_or.output │ ├── record │ │ ├── record.output │ │ ├── record.fs │ │ └── record.c │ ├── ty_var │ │ ├── ty_var.output │ │ └── ty_var.fs │ ├── union │ │ └── union.output │ ├── pat_when │ │ ├── pat_when.output │ │ └── pat_when.fs │ ├── fun_closure │ │ └── fun_closure.output │ ├── fun_lambda │ │ ├── fun_lambda.output │ │ └── fun_lambda.fs │ ├── global_var │ │ ├── global_var.output │ │ └── global_var.fs │ ├── module_inner │ │ ├── module_inner.output │ │ ├── sub.fs │ │ ├── module_inner_sub.c │ │ └── module_inner.fs │ ├── nav_nested │ │ ├── nav_nested.output │ │ ├── sub.fs │ │ └── nav_nested.fs │ ├── pat_literals │ │ ├── pat_literals.output │ │ └── pat_literals.fs │ ├── record_large │ │ ├── record_large.output │ │ └── record_large.fs │ ├── record_with │ │ ├── record_with.output │ │ └── record_with.fs │ ├── ty_ascribe │ │ ├── ty_ascribe.output │ │ └── ty_ascribe.fs │ ├── ty_synonym │ │ ├── ty_synonym.output │ │ └── ty_synonym.fs │ ├── union_equal │ │ └── union_equal.output │ ├── fun_rec │ │ ├── fun_rec.output │ │ └── fun_rec.fs │ ├── module_prelude │ │ ├── module_prelude.output │ │ ├── module_prelude.fs │ │ └── module_prelude.c │ ├── module_synonym │ │ ├── module_synonym.output │ │ ├── sub.fs │ │ ├── module_synonym_sub.c │ │ ├── module_synonym.fs │ │ └── module_synonym.c │ ├── pat_shadowing │ │ ├── pat_shadowing.output │ │ ├── pat_shadowing.fs │ │ └── pat_shadowing.c │ ├── record_generic │ │ └── record_generic.output │ ├── records_c_repr │ │ ├── records_c_repr.output │ │ └── records_c_repr.fs │ ├── union_generic │ │ └── union_generic.output │ ├── union_newtype │ │ ├── union_newtype.output │ │ ├── union_newtype.fs │ │ └── union_newtype.c │ ├── union_unitlike │ │ └── union_unitlike.output │ ├── fun_partial_app │ │ ├── fun_partial_app.output │ │ └── fun_partial_app.fs │ ├── match_complicated │ │ └── match_complicated.output │ ├── match_exhaustive │ │ ├── match_exhaustive.output │ │ └── match_exhaustive.fs │ ├── record_inference │ │ └── record_inference.output │ ├── record_unordered │ │ ├── record_unordered.output │ │ ├── record_unordered.fs │ │ └── record_unordered.c │ ├── union_complicated │ │ └── union_complicated.output │ ├── union_newtype_rec │ │ ├── union_newtype_rec.output │ │ └── union_newtype_rec.fs │ ├── union_rec_direct │ │ ├── union_rec_direct.output │ │ └── union_rec_direct.fs │ ├── match_nonexhaustive │ │ ├── match_nonexhaustive.output │ │ └── match_nonexhaustive.fs │ ├── module_dependencies │ │ ├── module_dependencies.output │ │ ├── root.fs │ │ ├── second.fs │ │ ├── third.fs │ │ ├── module_dependencies.fs │ │ ├── module_dependencies_root.c │ │ ├── module_dependencies_third.c │ │ ├── module_dependencies_second.c │ │ └── module_dependencies.c │ ├── module_milone_core │ │ ├── module_milone_core.output │ │ └── module_milone_core.fs │ ├── record_with_nested │ │ ├── record_with_nested.output │ │ └── record_with_nested.fs │ ├── ty_synonym_generic │ │ ├── ty_synonym_generic.output │ │ └── ty_synonym_generic.fs │ ├── fun_pipeline_operator │ │ ├── fun_pipeline_operator.output │ │ └── fun_pipeline_operator.fs │ ├── global_var_initializer │ │ ├── global_var_initializer.output │ │ └── global_var_initializer.fs │ ├── module_along_with_type │ │ ├── module_along_with_type.output │ │ └── sub.fs │ ├── module_rec_mutual_fun │ │ ├── module_rec_mutual_fun.output │ │ └── module_rec_mutual_fun.fs │ ├── module_rec_mutual_ty │ │ └── module_rec_mutual_ty.output │ ├── pat_discard │ │ ├── pat_discard.output │ │ ├── pat_discard.fs │ │ └── pat_discard.c │ ├── fun_generic_complicated │ │ └── fun_generic_complicated.output │ ├── union_newtype_rec_mutual │ │ ├── union_newtype_rec_mutual.output │ │ └── union_newtype_rec_mutual.fs │ ├── union_rec │ │ └── union_rec.output │ ├── fun_generic │ │ └── fun_generic.output │ └── fun_with_fun_arg │ │ ├── fun_with_fun_arg.output │ │ └── fun_with_fun_arg.fs ├── examples │ ├── factorial │ │ ├── factorial.output │ │ └── factorial.fs │ ├── Competitive │ │ ├── Competitive.output │ │ ├── milone_manifest │ │ ├── .gitignore │ │ ├── ABC140A.fs │ │ ├── Competitive.fs │ │ └── Competitive.fsproj │ ├── x_algorithm │ │ ├── x_algorithm.output │ │ └── x_algorithm.fs │ ├── hello_world │ │ ├── hello_world.output │ │ └── hello_world.fs │ ├── calc │ │ └── calc.output │ ├── x_json │ │ └── x_json.output │ ├── x_dyck_lang │ │ ├── x_dyck_lang.output │ │ └── x_dyck_lang.fs │ ├── fizz_buzz │ │ ├── fizz_buzz.output │ │ └── fizz_buzz.fs │ └── MatchChecker │ │ └── MatchChecker.output ├── pendings │ ├── never_id_bug │ │ ├── never_id_bug.output │ │ ├── never_id_bug.c │ │ └── never_id_bug.fs │ ├── octet_literal_bug │ │ ├── octet_literal_bug.output │ │ ├── octet_literal_bug.c │ │ └── octet_literal_bug.fs │ ├── newtype_of_fun_ty_bug │ │ ├── newtype_of_fun_ty_bug.output │ │ └── newtype_of_fun_ty_bug.fs │ ├── record_private_fields │ │ ├── record_private_fields.output │ │ ├── record_private_fields.c │ │ └── record_private_fields.fs │ ├── union_private_variants │ │ ├── union_private_variants.output │ │ ├── union_private_variants.c │ │ └── union_private_variants.fs │ ├── unreachable_match_bug │ │ ├── unreachable_match_bug.output │ │ └── unreachable_match_bug.c │ ├── fun_arity_app │ │ ├── fun_arity_app.output │ │ ├── fun_arity_app.c │ │ └── fun_arity_app.fs │ ├── fun_arity_over │ │ ├── fun_arity_over.output │ │ ├── fun_arity_over.c │ │ └── fun_arity_over.fs │ ├── pat_or_bindings │ │ ├── pat_or_bindings.output │ │ ├── pat_or_bindings.c │ │ └── pat_or_bindings.fs │ ├── module_forward_reference_bug │ │ ├── module_forward_reference_bug.output │ │ └── module_forward_reference_bug.fs │ ├── let_with_refutable_pat │ │ ├── let_with_refutable_pat.output │ │ ├── let_with_refutable_pat.c │ │ └── let_with_refutable_pat.fs │ └── fun_forward_reference_inference_bug │ │ ├── fun_forward_reference_inference_bug.output │ │ ├── fun_forward_reference_inference_bug.c │ │ └── fun_forward_reference_inference_bug.fs └── errors │ ├── own_err │ └── own_err.output │ ├── token_err │ ├── token_err.output │ └── token_err.fs │ ├── ty_errors │ ├── ty_errors.output │ ├── ty_errors.fs │ └── ty_errors.c │ ├── ty_var_err │ ├── ty_var_err.output │ ├── ty_var_err.c │ └── ty_var_err.fs │ ├── module_nonrec │ ├── module_nonrec.output │ ├── module_nonrec.fs │ └── module_nonrec.c │ ├── nativeptr_err │ └── nativeptr_err.output │ ├── ty_label_err │ ├── ty_label_err.output │ ├── ty_label_err.fs │ └── ty_label_err.c │ ├── fun_nonrec_err │ ├── fun_nonrec_err.output │ ├── fun_nonrec_err.c │ └── fun_nonrec_err.fs │ ├── module_no_leak │ ├── module_no_leak.output │ ├── module_no_leak.c │ ├── module_no_leak_f1.fs │ ├── module_no_leak_f2.fs │ └── module_no_leak.fs │ ├── vis_private_err │ ├── vis_private_err.output │ ├── vis_private_sub.fs │ ├── vis_private_err.c │ └── vis_private_err.fs │ ├── int_lit_range_err │ ├── int_lit_range_err.output │ ├── int_lit_range_err.c │ └── int_lit_range_err.fs │ ├── not_equatable_err │ ├── not_equatable_err.output │ └── not_equatable_err.c │ ├── range_as_value_err │ ├── range_as_value_err.output │ └── range_as_value_err.fs │ ├── record_missing_err │ ├── record_missing_err.output │ ├── record_missing_err.c │ └── record_missing_err.fs │ ├── record_noinfer_err │ ├── record_noinfer_err.output │ ├── record_noinfer_err.c │ └── record_noinfer_err.fs │ ├── synonym_arity_err │ ├── synonym_arity_err.output │ ├── synonym_arity_err.c │ └── synonym_arity_err.fs │ ├── union_with_ty_args │ ├── union_with_ty_args.output │ ├── union_with_ty_args.c │ └── union_with_ty_args.fs │ ├── illegal_use_prim_err │ ├── illegal_use_prim_err.output │ ├── illegal_use_prim_err.fs │ └── illegal_use_prim_err.c │ ├── main_fun_invalid_err │ ├── main_fun_invalid_err.output │ ├── main_fun_invalid_err.c │ └── main_fun_invalid_err.fs │ ├── record_redundant_err │ ├── record_redundant_err.output │ ├── record_redundant_err.c │ └── record_redundant_err.fs │ ├── fun_ptr_of_local_error │ ├── fun_ptr_of_local_error.output │ ├── fun_ptr_of_local_error.fs │ └── fun_ptr_of_local_error.c │ ├── module_used_as_ty_err │ ├── module_used_as_ty_err.output │ ├── sub.fs │ ├── module_used_as_ty_err.fs │ └── module_used_as_ty_err.c │ ├── pat_nav_unresolved_err │ ├── pat_nav_unresolved_err.output │ ├── pat_nav_unresolved_err.c │ └── pat_nav_unresolved_err.fs │ ├── pat_or_asymmetric_err │ ├── pat_or_asymmetric_err.output │ ├── pat_or_asymmetric_err.fs │ └── pat_or_asymmetric_err.c │ ├── pat_resolved_as_fun_err │ ├── pat_resolved_as_fun_err.output │ ├── sub.fs │ ├── pat_resolved_as_fun_err.c │ └── pat_resolved_as_fun_err.fs │ ├── printfn_no_format_err │ ├── printfn_no_format_err.output │ ├── printfn_no_format_err.c │ └── printfn_no_format_err.fs │ ├── scope_undefined_ty_err │ ├── scope_undefined_ty_err.output │ ├── scope_undefined_ty_err.c │ └── scope_undefined_ty_err.fs │ ├── scope_undefined_var_err │ ├── scope_undefined_var_err.output │ ├── scope_undefined_var_err.c │ └── scope_undefined_var_err.fs │ ├── ty_synonym_cyclic_err │ ├── ty_synonym_cyclic_err.output │ ├── ty_synonym_cyclic_err.c │ └── ty_synonym_cyclic_err.fs │ ├── module_open_not_found_err │ ├── module_open_not_found_err.output │ ├── module_open_not_found_err.c │ └── module_open_not_found_err.fs │ ├── pat_or_name_conflict_err │ ├── pat_or_name_conflict_err.output │ ├── pat_or_name_conflict_err.fs │ └── pat_or_name_conflict_err.c │ ├── native_fun_illegal_use_err │ ├── native_fun_illegal_use_err.output │ ├── native_fun_illegal_use_err.c │ └── native_fun_illegal_use_err.fs │ ├── pat_or_var_incompatible_ty_err │ ├── pat_or_var_incompatible_ty_err.output │ ├── pat_or_var_incompatible_ty_err.c │ └── pat_or_var_incompatible_ty_err.fs │ ├── ty_synonym_undefined_ty_var_err │ ├── ty_synonym_undefined_ty_var_err.output │ ├── ty_synonym_undefined_ty_var_err.c │ └── ty_synonym_undefined_ty_var_err.fs │ └── pat_variant_fun_without_payload_err │ ├── pat_variant_fun_without_payload_err.output │ ├── pat_variant_fun_without_payload_err.fs │ └── pat_variant_fun_without_payload_err.c ├── vscode_ext ├── dist │ └── .gitkeep ├── .vscodeignore ├── .editorconfig ├── uninstall ├── install ├── tsconfig.json └── Makefile ├── nursery ├── LibHttpServer │ ├── dist │ │ ├── empty │ │ ├── about │ │ │ └── index.html │ │ ├── index.html │ │ └── main.css │ ├── milone_manifest │ ├── run │ ├── build │ └── req ├── assets │ └── hello.txt ├── CmdCat │ ├── tests │ │ ├── input1.txt │ │ ├── input2.txt │ │ └── output-expected.txt │ ├── milone_manifest │ ├── test │ └── .gitignore ├── LibPoda │ ├── milone_manifest │ └── ExCsv.milone ├── AppBlog │ ├── milone_manifest │ ├── README.md │ ├── build.rs │ ├── data │ │ └── pages │ │ │ └── hello.txt │ ├── Cargo.toml │ └── build.ninja ├── AppGtk │ ├── run │ ├── Program.fs │ ├── build-1 │ ├── AppGtk.fsproj │ ├── Makefile │ ├── .gitignore │ └── build-2 ├── CmdJsonGet │ ├── milone_manifest │ ├── test-expected.txt │ ├── test-input.json │ └── test ├── LibNurseryTests │ ├── milone_manifest │ ├── run │ ├── LibNurseryTests.milone │ └── TestHelper.milone ├── LibSqlite3 │ ├── test-expected.txt │ └── milone_manifest ├── ExDylib │ ├── libplus.c │ ├── milone_manifest │ ├── hello │ │ ├── src │ │ │ └── lib.rs │ │ └── Cargo.toml │ └── run ├── LibData │ └── LibData.milone ├── CmdLspServer │ ├── Erroring │ │ └── Erroring.milone │ └── milone_manifest ├── CmdSqliteTodo │ ├── milone_manifest │ ├── test-expected.txt │ └── test ├── format ├── LibTextProcess │ ├── LibTextProcess.milone │ ├── README.md │ └── TinyYamlTests.milone ├── LibSpan │ ├── Span.milone │ └── SpanMut.milone ├── LibSpanTests │ ├── LibSpanTests.milone │ └── build ├── README.md ├── LibFileSystemTests │ ├── LibFileSystemTests.milone │ └── build ├── install-sqlite3 ├── LibNursery │ └── Runtime.milone └── BenchLoopIter │ └── run ├── scripts ├── ManifestTest │ ├── ManifestTest.milone │ └── milone_manifest ├── SharedObjectTest │ ├── milone_manifest │ ├── run │ ├── SharedObjectTest.milone │ └── app.c ├── StaticLibTest │ ├── milone_manifest │ ├── StaticLibTest.milone │ ├── run │ └── app.c ├── test_output_option │ ├── OutputOptionTest │ │ └── OutputOptionTest.milone │ └── run ├── LinkTest │ ├── milone_manifest │ ├── link_test_runtime.c │ └── LinkTest.milone ├── project-reference-example │ ├── Lib │ │ ├── Lcm.fs │ │ └── Gcd.fs │ ├── app.output │ ├── App │ │ └── App.fs │ └── test ├── test-std ├── install-hashmap ├── install-ninja ├── test-stdio ├── check_region_primitive ├── clean └── prof ├── src ├── MiloneDll │ ├── milone_manifest │ ├── example │ └── MiloneDll.milone ├── Std │ ├── Ptr.milone │ ├── milone_manifest │ ├── Own.milone │ ├── StdEnvBase.milone │ ├── README.md │ ├── StdEnvBase.fs │ ├── StdJsonBase.fs │ ├── Equal.milone │ ├── BoxTests.milone │ ├── StdEnv.fs │ ├── StdAssoc.fs │ ├── .gitignore │ ├── StdLoopBase.fs │ ├── StdIntBase.fs │ ├── StdTesting.fs │ ├── StdInt.fs │ ├── StdPair.fs │ └── Std.milone ├── MiloneLspServer │ ├── json-encode │ ├── test │ ├── tests │ │ └── DiagnosticsTest │ │ │ └── DiagnosticsTest.milone │ ├── req │ ├── dev │ ├── JsonValue.fs │ ├── run-exit │ ├── .gitignore │ └── run-highlight ├── MiloneShared │ ├── UtilProfiler.milone │ ├── .gitignore │ └── MiloneShared.fsproj ├── MiloneCli │ ├── MiloneCli.milone │ ├── MiloneCli.fs │ └── .gitignore ├── MiloneCore │ ├── MiloneCore.fsproj │ ├── .gitignore │ ├── Prelude.milone │ ├── Result.fs │ └── README.md ├── JsonEncode │ ├── .gitignore │ ├── JsonEncode.fsproj │ └── JsonEncode.fs ├── MiloneSyntax │ └── .gitignore ├── MyBuildTool │ ├── .gitignore │ ├── assets │ │ ├── uninstall.sh │ │ └── uninstall.ps1 │ ├── MyBuildTool.fsproj │ └── Util.fs └── MiloneTranslation │ ├── .gitignore │ └── TranslationApiTypes.fs ├── fsharplint.json ├── .clang-format ├── .config └── dotnet-tools.json └── .gitattributes /tests/edges/empty/empty.fs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vscode_ext/dist/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /nursery/LibHttpServer/dist/empty: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /nursery/assets/hello.txt: -------------------------------------------------------------------------------- 1 | Hello, world! 2 | -------------------------------------------------------------------------------- /scripts/ManifestTest/ManifestTest.milone: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/edges/empty/empty.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/own/own.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /nursery/CmdCat/tests/input1.txt: -------------------------------------------------------------------------------- 1 | Input 1. 2 | -------------------------------------------------------------------------------- /nursery/LibPoda/milone_manifest: -------------------------------------------------------------------------------- 1 | cc ex_csv.c 2 | -------------------------------------------------------------------------------- /src/MiloneDll/milone_manifest: -------------------------------------------------------------------------------- 1 | binary shared 2 | -------------------------------------------------------------------------------- /tests/features/modules/modules.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/nav_ty/nav_ty.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/nav_var/nav_var.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/pat_as/pat_as.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/pat_or/pat_or.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/record/record.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/ty_var/ty_var.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/union/union.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/option/option.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/result/result.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /nursery/AppBlog/milone_manifest: -------------------------------------------------------------------------------- 1 | binary staticlib 2 | -------------------------------------------------------------------------------- /nursery/CmdCat/tests/input2.txt: -------------------------------------------------------------------------------- 1 | Input: 2 | - 2. 3 | -------------------------------------------------------------------------------- /tests/edges/return_zero/return_zero.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/edges/ty_unbound/ty_unbound.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/examples/factorial/factorial.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/pat_when/pat_when.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/effect_file_io/input.txt: -------------------------------------------------------------------------------- 1 | hello 2 | -------------------------------------------------------------------------------- /tests/primitives/list_pat/list_pat.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/never_ty/never_ty.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/std_int/std_int.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/std_iter/std_iter.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/std_list/std_list.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/std_loop/std_loop.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /scripts/SharedObjectTest/milone_manifest: -------------------------------------------------------------------------------- 1 | binary shared 2 | -------------------------------------------------------------------------------- /scripts/StaticLibTest/milone_manifest: -------------------------------------------------------------------------------- 1 | binary staticlib 2 | -------------------------------------------------------------------------------- /tests/edges/pat_with_vis/pat_with_vis.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/examples/Competitive/Competitive.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/examples/x_algorithm/x_algorithm.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/fun_closure/fun_closure.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/fun_lambda/fun_lambda.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/global_var/global_var.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/module_inner/module_inner.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/nav_nested/nav_nested.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/pat_literals/pat_literals.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/record_large/record_large.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/record_with/record_with.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/ty_ascribe/ty_ascribe.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/ty_synonym/ty_synonym.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/union_equal/union_equal.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/pendings/never_id_bug/never_id_bug.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/int_flavors/int_flavors.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/list_equal/list_equal.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/native_cast/native_cast.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/native_type/native_type.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/nativeptr/nativeptr.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/std_block/std_block.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/std_option/std_option.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/std_result/std_result.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/std_string/std_string.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/tuple_arg/tuple_arg.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/tuple_equal/tuple_equal.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/tuple_large/tuple_large.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /src/Std/Ptr.milone: -------------------------------------------------------------------------------- 1 | // Std.Ptr contains several primitives. 2 | -------------------------------------------------------------------------------- /src/Std/milone_manifest: -------------------------------------------------------------------------------- 1 | sanitize address,leak,undefined 2 | -------------------------------------------------------------------------------- /tests/edges/resolved_issues/resolved_issues.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/edges/unary_op_syntax/unary_op_syntax.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/fun_rec/fun_rec.output: -------------------------------------------------------------------------------- 1 | 4 2 | 7 3 | $? = 0 4 | -------------------------------------------------------------------------------- /tests/features/module_prelude/module_prelude.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/module_synonym/module_synonym.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/pat_shadowing/pat_shadowing.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/record_generic/record_generic.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/records_c_repr/records_c_repr.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/union_generic/union_generic.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/union_newtype/union_newtype.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/union_unitlike/union_unitlike.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/bool_if_expr/bool_if_expr.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/effect_file_io/output.txt: -------------------------------------------------------------------------------- 1 | hello 2 | world 3 | -------------------------------------------------------------------------------- /tests/primitives/effect_region/effect_region.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/int_operators/int_operators.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/int_to_string/int_to_string.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/option_equal/option_equal.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/string_length/string_length.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/tuple_string/tuple_string.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/union_runtime/union_runtime.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/union_string/union_string.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /nursery/AppBlog/README.md: -------------------------------------------------------------------------------- 1 | Static blog generator as an example. 2 | -------------------------------------------------------------------------------- /nursery/AppGtk/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | make run 6 | -------------------------------------------------------------------------------- /nursery/CmdCat/milone_manifest: -------------------------------------------------------------------------------- 1 | sanitize address,leak,undefined 2 | -------------------------------------------------------------------------------- /src/Std/Own.milone: -------------------------------------------------------------------------------- 1 | // This module also provides some primitives. 2 | -------------------------------------------------------------------------------- /tests/edges/newtype_in_records/newtype_in_records.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/edges/record_vs_generics/record_vs_generics.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/errors/own_err/own_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/features/fun_partial_app/fun_partial_app.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/match_complicated/match_complicated.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/match_exhaustive/match_exhaustive.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/record_inference/record_inference.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/record_unordered/record_unordered.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/union_complicated/union_complicated.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/union_newtype_rec/union_newtype_rec.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/union_rec_direct/union_rec_direct.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/pendings/octet_literal_bug/octet_literal_bug.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/bool_operators/bool_operators.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/char_operators/char_operators.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/effect_file_io/effect_file_io.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/list_operators/list_operators.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/native_fun_call/native_fun_call.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/string_operators/string_operators.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /nursery/CmdCat/tests/output-expected.txt: -------------------------------------------------------------------------------- 1 | Input 1. 2 | Input: 3 | - 2. 4 | -------------------------------------------------------------------------------- /nursery/CmdJsonGet/milone_manifest: -------------------------------------------------------------------------------- 1 | sanitize address,leak,undefined 2 | -------------------------------------------------------------------------------- /nursery/LibNurseryTests/milone_manifest: -------------------------------------------------------------------------------- 1 | sanitize address,undefined 2 | -------------------------------------------------------------------------------- /tests/edges/generic_right_angles/generic_right_angles.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/edges/module_open_shadowed/module_open_shadowed.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/edges/pat_or_deep_branches/pat_or_deep_branches.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/edges/union_generic_crash/union_generic_crash.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/errors/token_err/token_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/ty_errors/ty_errors.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/ty_var_err/ty_var_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/examples/Competitive/milone_manifest: -------------------------------------------------------------------------------- 1 | sanitize address,undefined 2 | -------------------------------------------------------------------------------- /tests/features/match_nonexhaustive/match_nonexhaustive.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/module_dependencies/module_dependencies.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/module_milone_core/module_milone_core.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/record_with_nested/record_with_nested.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/ty_synonym_generic/ty_synonym_generic.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/float/float.output: -------------------------------------------------------------------------------- 1 | Assume PI is 3.140000. 2 | $? = 0 3 | -------------------------------------------------------------------------------- /tests/primitives/std_native_interop/std_native_interop.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/string_literal_raw/string_literal_raw.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /nursery/LibHttpServer/milone_manifest: -------------------------------------------------------------------------------- 1 | std gnu11 2 | cc lib_http_server.c 3 | -------------------------------------------------------------------------------- /tests/edges/match_nested_nonbinding/match_nested_nonbinding.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/errors/module_nonrec/module_nonrec.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/nativeptr_err/nativeptr_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/ty_label_err/ty_label_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/examples/hello_world/hello_world.output: -------------------------------------------------------------------------------- 1 | Hello, world! 2 | $? = 0 3 | -------------------------------------------------------------------------------- /tests/features/fun_pipeline_operator/fun_pipeline_operator.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/global_var_initializer/global_var_initializer.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/module_along_with_type/module_along_with_type.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/module_rec_mutual_fun/module_rec_mutual_fun.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/module_rec_mutual_ty/module_rec_mutual_ty.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/pat_discard/pat_discard.output: -------------------------------------------------------------------------------- 1 | hello 2 | hello 3 | $? = 0 4 | -------------------------------------------------------------------------------- /tests/pendings/newtype_of_fun_ty_bug/newtype_of_fun_ty_bug.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/pendings/record_private_fields/record_private_fields.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/pendings/union_private_variants/union_private_variants.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/pendings/unreachable_match_bug/unreachable_match_bug.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/int_flavor_unsigned/int_flavor_unsigned.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/obj_box_unbox/obj_box_unbox.output: -------------------------------------------------------------------------------- 1 | 2 2 | Fizz 3 | $? = 0 4 | -------------------------------------------------------------------------------- /tests/primitives/string_literal_escape/string_literal_escape.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /fsharplint.json: -------------------------------------------------------------------------------- 1 | { 2 | "canBeReplacedWithComposition": { "enabled": false } 3 | } -------------------------------------------------------------------------------- /nursery/LibSqlite3/test-expected.txt: -------------------------------------------------------------------------------- 1 | 1:asparagus 2 | 2:brocoli 3 | 3:cucumber 4 | -------------------------------------------------------------------------------- /tests/edges/fun_forward_use/fun_forward_use.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/edges/fun_monomorphization_bug/fun_monomorphization_bug.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/errors/fun_nonrec_err/fun_nonrec_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/module_no_leak/module_no_leak.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/vis_private_err/vis_private_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/features/fun_generic_complicated/fun_generic_complicated.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/features/union_newtype_rec_mutual/union_newtype_rec_mutual.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/pendings/fun_arity_app/fun_arity_app.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/pendings/fun_arity_over/fun_arity_over.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /vscode_ext/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | Makefile 3 | node_modules 4 | out 5 | src 6 | -------------------------------------------------------------------------------- /nursery/ExDylib/libplus.c: -------------------------------------------------------------------------------- 1 | int my_plus(int x, int y) { 2 | return x + y; 3 | } 4 | -------------------------------------------------------------------------------- /scripts/test_output_option/OutputOptionTest/OutputOptionTest.milone: -------------------------------------------------------------------------------- 1 | printfn "OK!" 2 | -------------------------------------------------------------------------------- /tests/edges/fun_generic_ty_degeneration/fun_generic_ty_degeneration.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/edges/match_parse_issue/match_parse_issue.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/edges/match_with_no_arms/match_with_no_arms.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/edges/union_generic_newtype_issue/union_generic_newtype_issue.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/errors/int_lit_range_err/int_lit_range_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/not_equatable_err/not_equatable_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/range_as_value_err/range_as_value_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/record_missing_err/record_missing_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/record_noinfer_err/record_noinfer_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/synonym_arity_err/synonym_arity_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/union_with_ty_args/union_with_ty_args.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/features/union_rec/union_rec.output: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 6 4 | 24 5 | 120 6 | $? = 0 7 | -------------------------------------------------------------------------------- /tests/pendings/pat_or_bindings/pat_or_bindings.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/primitives/native_code/native_code.output: -------------------------------------------------------------------------------- 1 | HEY! 2 | YO! 3 | 1 4 | 2 5 | $? = 0 6 | -------------------------------------------------------------------------------- /tests/primitives/native_fun_ptr/native_fun_ptr.output: -------------------------------------------------------------------------------- 1 | f is called: n=42. 2 | $? = 0 3 | -------------------------------------------------------------------------------- /tests/primitives/tuple/tuple.output: -------------------------------------------------------------------------------- 1 | 1 2 | fst 3 | z=z 4 | w=w 5 | p=p 6 | $? = 0 7 | -------------------------------------------------------------------------------- /nursery/ExDylib/milone_manifest: -------------------------------------------------------------------------------- 1 | cc dylib_runtime.c 2 | 3 | # linux only 4 | # lib dl 5 | -------------------------------------------------------------------------------- /tests/edges/recursive_ty_error_by_synonym/recursive_ty_error_by_synonym.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/errors/illegal_use_prim_err/illegal_use_prim_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/main_fun_invalid_err/main_fun_invalid_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/record_redundant_err/record_redundant_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/examples/calc/calc.output: -------------------------------------------------------------------------------- 1 | int 2 2 | op + 3 | int 3 4 | op - 5 | int 4 6 | $? = 0 7 | -------------------------------------------------------------------------------- /tests/features/fun_generic/fun_generic.output: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 1 5 | 4 6 | 9 7 | $? = 0 8 | -------------------------------------------------------------------------------- /tests/features/fun_with_fun_arg/fun_with_fun_arg.output: -------------------------------------------------------------------------------- 1 | 42: The answer 2 | f'' 3 | $? = 0 4 | -------------------------------------------------------------------------------- /tests/pendings/module_forward_reference_bug/module_forward_reference_bug.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/primitives/bool_if_expr_complicated/bool_if_expr_complicated.output: -------------------------------------------------------------------------------- 1 | then 2 | $? = 0 3 | -------------------------------------------------------------------------------- /nursery/AppGtk/Program.fs: -------------------------------------------------------------------------------- 1 | module rec AppGtk.Program 2 | 3 | [] 4 | let main _ = 0 5 | -------------------------------------------------------------------------------- /nursery/LibData/LibData.milone: -------------------------------------------------------------------------------- 1 | open LibData.HashTests 2 | open LibData.RandomAccessListTests 3 | -------------------------------------------------------------------------------- /tests/edges/union_generic_ty_error/union_generic_ty_error.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/fun_ptr_of_local_error/fun_ptr_of_local_error.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/module_used_as_ty_err/module_used_as_ty_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/pat_nav_unresolved_err/pat_nav_unresolved_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/pat_or_asymmetric_err/pat_or_asymmetric_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/pat_resolved_as_fun_err/pat_resolved_as_fun_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/printfn_no_format_err/printfn_no_format_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/scope_undefined_ty_err/scope_undefined_ty_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/scope_undefined_var_err/scope_undefined_var_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/ty_synonym_cyclic_err/ty_synonym_cyclic_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/features/module_synonym/sub.fs: -------------------------------------------------------------------------------- 1 | module rec module_synonym.sub 2 | 3 | let inc x = x + 1 4 | -------------------------------------------------------------------------------- /tests/pendings/let_with_refutable_pat/let_with_refutable_pat.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /nursery/CmdLspServer/Erroring/Erroring.milone: -------------------------------------------------------------------------------- 1 | let bad1 = 1 <> string 2 | 3 | let bad2 = "" |> "" 4 | -------------------------------------------------------------------------------- /tests/edges/monomorphization_bug_1/monomorphization_bug_1.output: -------------------------------------------------------------------------------- 1 | x1 = 'a' 2 | x2 = 'a' 3 | $? = 0 4 | -------------------------------------------------------------------------------- /tests/errors/module_open_not_found_err/module_open_not_found_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/pat_or_name_conflict_err/pat_or_name_conflict_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/edges/fun_underlying_fun_forward_decl_issue/fun_underlying_fun_forward_decl_issue.output: -------------------------------------------------------------------------------- 1 | $? = 0 2 | -------------------------------------------------------------------------------- /tests/edges/ty_var_unified_unexpectedly/ty_var_unified_unexpectedly.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/module_used_as_ty_err/sub.fs: -------------------------------------------------------------------------------- 1 | module rec module_used_as_ty_err.sub 2 | 3 | let f () = () 4 | -------------------------------------------------------------------------------- /tests/errors/native_fun_illegal_use_err/native_fun_illegal_use_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/ty_var_err/ty_var_err.c: -------------------------------------------------------------------------------- 1 | #error ty_var_err.ty_var_err:7:18 Type mismatch: 'string' <> 'int'. 2 | -------------------------------------------------------------------------------- /tests/features/module_dependencies/root.fs: -------------------------------------------------------------------------------- 1 | module rec module_dependencies.root 2 | 3 | let root () = 0 4 | -------------------------------------------------------------------------------- /src/MiloneLspServer/json-encode: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exec dotnet run --project "$(dirname "$0")/../JsonEncode" 4 | -------------------------------------------------------------------------------- /tests/errors/pat_or_var_incompatible_ty_err/pat_or_var_incompatible_ty_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/errors/pat_resolved_as_fun_err/sub.fs: -------------------------------------------------------------------------------- 1 | module rec pat_resolved_as_fun_err.sub 2 | 3 | let f () = () 4 | -------------------------------------------------------------------------------- /scripts/ManifestTest/milone_manifest: -------------------------------------------------------------------------------- 1 | linux: cflags -pg -fsanitize=address 2 | linux: link -pg -fsanitize=address 3 | -------------------------------------------------------------------------------- /src/MiloneLspServer/test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | MILONE_LSP_SERVER_LOG_LEVEL=debug dotnet run -- test 6 | -------------------------------------------------------------------------------- /tests/errors/ty_synonym_undefined_ty_var_err/ty_synonym_undefined_ty_var_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /src/MiloneShared/UtilProfiler.milone: -------------------------------------------------------------------------------- 1 | module rec MiloneShared.UtilProfiler 2 | 3 | type Profiler = Profiler of voidptr 4 | -------------------------------------------------------------------------------- /tests/errors/pat_variant_fun_without_payload_err/pat_variant_fun_without_payload_err.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/features/nav_ty/sub.fs: -------------------------------------------------------------------------------- 1 | module rec nav_ty.sub 2 | 3 | type Node = 4 | | Leaf of int 5 | | Node of Node * Node 6 | -------------------------------------------------------------------------------- /tests/edges/fun_forward_use/fun_forward_use.c: -------------------------------------------------------------------------------- 1 | #error fun_forward_use.fun_forward_use:21:18 Type mismatch: 'string' <> 'int'. 2 | -------------------------------------------------------------------------------- /tests/features/module_inner/sub.fs: -------------------------------------------------------------------------------- 1 | module rec module_inner.sub 2 | 3 | module rec Inner = 4 | let decrement x = x - 1 5 | -------------------------------------------------------------------------------- /tests/pendings/fun_forward_reference_inference_bug/fun_forward_reference_inference_bug.output: -------------------------------------------------------------------------------- 1 | milone-lang compile error. 2 | -------------------------------------------------------------------------------- /tests/edges/match_with_no_arms/match_with_no_arms.c: -------------------------------------------------------------------------------- 1 | #error match_with_no_arms.match_with_no_arms:8:3 Expected at least one arm. 2 | -------------------------------------------------------------------------------- /tests/edges/return_zero/return_zero.fs: -------------------------------------------------------------------------------- 1 | module rec zero.Program 2 | 3 | // Just returns exit code zero. 4 | 5 | let main _ = 0 6 | -------------------------------------------------------------------------------- /tests/edges/module_open_shadowed/sub.fs: -------------------------------------------------------------------------------- 1 | module rec module_open_shadowed.sub 2 | 3 | let f (x: int) = x + 2 4 | let g (x: int) = x + 3 5 | -------------------------------------------------------------------------------- /tests/errors/vis_private_err/vis_private_sub.fs: -------------------------------------------------------------------------------- 1 | module rec vis_private_err.vis_private_sub 2 | 3 | let private privateFun () = () 4 | -------------------------------------------------------------------------------- /tests/examples/hello_world/hello_world.fs: -------------------------------------------------------------------------------- 1 | module rec hello_world.Program 2 | 3 | let main _ = 4 | printfn "Hello, world!" 5 | 0 6 | -------------------------------------------------------------------------------- /tests/examples/x_json/x_json.output: -------------------------------------------------------------------------------- 1 | punct [ 2 | int 0 3 | punct , 4 | int 1000000007 5 | punct , 6 | int 314159 7 | punct ] 8 | $? = 0 9 | -------------------------------------------------------------------------------- /scripts/LinkTest/milone_manifest: -------------------------------------------------------------------------------- 1 | std gnu11 2 | cc ./link_test_runtime.c 3 | lib m 4 | sanitize address,undefined 5 | 6 | # obj other.o 7 | -------------------------------------------------------------------------------- /tests/errors/record_missing_err/record_missing_err.c: -------------------------------------------------------------------------------- 1 | #error record_missing_err.record_missing_err:6:19 Record 'Point' must have fields: Y 2 | -------------------------------------------------------------------------------- /tests/features/modules/sub.fs: -------------------------------------------------------------------------------- 1 | module rec modules.sub 2 | 3 | type Val = 4 | | Int of int 5 | | String of string 6 | 7 | let f x = x 8 | -------------------------------------------------------------------------------- /nursery/AppBlog/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("cargo:rustc-link-search=target"); 3 | println!("cargo:rustc-link-lib=app"); 4 | } 5 | -------------------------------------------------------------------------------- /scripts/project-reference-example/Lib/Lcm.fs: -------------------------------------------------------------------------------- 1 | // module rec Lib.Lcm 2 | 3 | open Lib.Gcd 4 | 5 | let lcm (x: int) (y: int) = (x / gcd x y) * y 6 | -------------------------------------------------------------------------------- /tests/examples/x_dyck_lang/x_dyck_lang.output: -------------------------------------------------------------------------------- 1 | case1 (A): Accept 2 | case2 (A): Accept 3 | case3 (R): Reject 4 | case4 (R): Reject 5 | $? = 0 6 | -------------------------------------------------------------------------------- /tests/features/nav_nested/sub.fs: -------------------------------------------------------------------------------- 1 | module rec nav_nested.sub 2 | 3 | type SubRecord = { Text: string } 4 | 5 | type SubUnion = SubUnion of int 6 | -------------------------------------------------------------------------------- /tests/pendings/pat_or_bindings/pat_or_bindings.c: -------------------------------------------------------------------------------- 1 | #error pat_or_bindings.pat_or_bindings:8:3 OR pattern including some bindings is unimplemented. 2 | -------------------------------------------------------------------------------- /tests/primitives/effect_assert/effect_assert.output: -------------------------------------------------------------------------------- 1 | pass 2 | Notice: test 'effect_assert' intentionally prints an assertion error: 3 | $? = 134 4 | -------------------------------------------------------------------------------- /tests/primitives/effect_printfn/effect_printfn.output: -------------------------------------------------------------------------------- 1 | No formats 2 | Hello! 3 | Welcome to Milone Land. Entry price is $1000000007! 4 | $? = 0 5 | -------------------------------------------------------------------------------- /nursery/LibNurseryTests/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | TARGET=$PWD/../target/LibNurseryTests 6 | 7 | milone run --target-dir "$TARGET" $PWD 8 | -------------------------------------------------------------------------------- /scripts/LinkTest/link_test_runtime.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void println_int(int value) { 4 | fprintf(stdout, "%d\n", value); 5 | } 6 | 7 | -------------------------------------------------------------------------------- /tests/edges/match_parse_issue/match_parse_issue.c: -------------------------------------------------------------------------------- 1 | #error match_parse_issue.match_parse_issue:9:3 PARSE ERROR: Expected negative literal pattern (9:3) 2 | -------------------------------------------------------------------------------- /tests/errors/module_no_leak/module_no_leak.c: -------------------------------------------------------------------------------- 1 | #error module_no_leak.module_no_leak:8:3 The name 'f1' here should denote to some value; but not found. 2 | -------------------------------------------------------------------------------- /tests/errors/module_open_not_found_err/module_open_not_found_err.c: -------------------------------------------------------------------------------- 1 | #error module_open_not_found_err.module_open_not_found_err:5:1 Module not found. 2 | -------------------------------------------------------------------------------- /tests/errors/pat_nav_unresolved_err/pat_nav_unresolved_err.c: -------------------------------------------------------------------------------- 1 | #error pat_nav_unresolved_err.pat_nav_unresolved_err:7:6 Couldn't resolve nav pattern. 2 | -------------------------------------------------------------------------------- /vscode_ext/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{js,ts}] 2 | indent_size = 2 3 | indent_style = space 4 | insert_final_newline = true 5 | trim_trailing_whitespace = true 6 | -------------------------------------------------------------------------------- /tests/edges/union_generic_ty_error/union_generic_ty_error.c: -------------------------------------------------------------------------------- 1 | #error union_generic_ty_error.union_generic_ty_error:10:13 Type mismatch: 'int' <> 'string'. 2 | -------------------------------------------------------------------------------- /tests/errors/module_no_leak/module_no_leak_f1.fs: -------------------------------------------------------------------------------- 1 | module rec module_no_leak.module_no_leak_f1 2 | 3 | // public, but not auto-open. 4 | let f1 () = () 5 | -------------------------------------------------------------------------------- /tests/errors/module_nonrec/module_nonrec.fs: -------------------------------------------------------------------------------- 1 | module module_nonrec.Program 2 | // ^ Non recursive module is unimplemented yet. 3 | 4 | let main _ = 0 5 | -------------------------------------------------------------------------------- /tests/errors/pat_resolved_as_fun_err/pat_resolved_as_fun_err.c: -------------------------------------------------------------------------------- 1 | #error pat_resolved_as_fun_err.pat_resolved_as_fun_err:9:8 Couldn't resolve nav pattern. 2 | -------------------------------------------------------------------------------- /tests/features/module_dependencies/second.fs: -------------------------------------------------------------------------------- 1 | module rec module_dependencies.second 2 | 3 | open module_dependencies.root 4 | 5 | let second () = root () 6 | -------------------------------------------------------------------------------- /tests/features/module_dependencies/third.fs: -------------------------------------------------------------------------------- 1 | module rec module_dependencies.third 2 | 3 | open module_dependencies.root 4 | 5 | let third () = root () 6 | -------------------------------------------------------------------------------- /tests/features/nav_var/sub.fs: -------------------------------------------------------------------------------- 1 | module rec nav_module_var.sub 2 | 3 | let answer = 42 4 | 5 | let getAnswer () = 42 6 | 7 | type Answer = Answer of int 8 | -------------------------------------------------------------------------------- /tests/pendings/fun_arity_over/fun_arity_over.c: -------------------------------------------------------------------------------- 1 | #error fun_arity_over.fun_arity_over:11:5 Arity mismatch: expected (_, _) -> _, but was (_) -> (_) -> _. 2 | -------------------------------------------------------------------------------- /tests/errors/fun_nonrec_err/fun_nonrec_err.c: -------------------------------------------------------------------------------- 1 | #error fun_nonrec_err.fun_nonrec_err:8:5 The name 'nonRecLoop' here should denote to some value; but not found. 2 | -------------------------------------------------------------------------------- /tests/errors/record_redundant_err/record_redundant_err.c: -------------------------------------------------------------------------------- 1 | #error record_redundant_err.record_redundant_err:6:37 The field 'Z' is redundant for record 'Point'. 2 | -------------------------------------------------------------------------------- /nursery/LibHttpServer/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | TARGET=$PWD/../target/LibHttpServer 6 | 7 | ./build 8 | 9 | set -x 10 | $TARGET/httpd "$@" 11 | -------------------------------------------------------------------------------- /src/MiloneLspServer/tests/DiagnosticsTest/DiagnosticsTest.milone: -------------------------------------------------------------------------------- 1 | module rec DiagnosticsTest.Program 2 | 3 | let main _ = 0 4 | 5 | // syntax error 6 | // let x 0 7 | -------------------------------------------------------------------------------- /tests/errors/vis_private_err/vis_private_err.c: -------------------------------------------------------------------------------- 1 | #error vis_private_err.vis_private_err:8:18 The name 'privateFun' here should denote to some value; but not found. 2 | -------------------------------------------------------------------------------- /tests/features/pat_discard/pat_discard.fs: -------------------------------------------------------------------------------- 1 | module rec pat_discard.Program 2 | 3 | let main _ = 4 | let f () = printfn "hello" 5 | let _, _ = f (), f () 6 | 0 7 | -------------------------------------------------------------------------------- /tests/pendings/fun_arity_app/fun_arity_app.c: -------------------------------------------------------------------------------- 1 | #error fun_arity_app.fun_arity_app:11:22 Arity mismatch: expected ((_, _) -> _, ..) -> .., but was ((_) -> _, _) -> _. 2 | -------------------------------------------------------------------------------- /tests/primitives/bool_if_expr/bool_if_expr.fs: -------------------------------------------------------------------------------- 1 | module rec bool_if_expr.Program 2 | 3 | // if expression is supported. 4 | 5 | let main _ = if true then 0 else 1 6 | -------------------------------------------------------------------------------- /nursery/AppBlog/data/pages/hello.txt: -------------------------------------------------------------------------------- 1 | --- 2 | title: Hello, My Blog! 3 | url: /hello 4 | --- 5 | 6 | Hi, this is my first article on [the blog]. 7 | See you next time. 8 | -------------------------------------------------------------------------------- /tests/edges/ty_var_unified_unexpectedly/ty_var_unified_unexpectedly.c: -------------------------------------------------------------------------------- 1 | #error ty_var_unified_unexpectedly.ty_var_unified_unexpectedly:8:3 Type mismatch: 'int' <> ''T'. 2 | -------------------------------------------------------------------------------- /nursery/LibSqlite3/milone_manifest: -------------------------------------------------------------------------------- 1 | cc ../LibSqlite3/lib_sqlite3_runtime.c 2 | obj ../vendor/sqlite3/sqlite3.o 3 | lib dl 4 | lib pthread 5 | sanitize address,leak,undefined 6 | -------------------------------------------------------------------------------- /tests/errors/module_nonrec/module_nonrec.c: -------------------------------------------------------------------------------- 1 | #error module_nonrec.module_nonrec:1:1 PARSE ERROR: Module header requires 'rec'. Hint: `module rec ProjectName.ModuleName`. (1:1) 2 | -------------------------------------------------------------------------------- /tests/primitives/string_literal_escape/string_literal_escape.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vain0x/milone-lang/HEAD/tests/primitives/string_literal_escape/string_literal_escape.c -------------------------------------------------------------------------------- /nursery/CmdJsonGet/test-expected.txt: -------------------------------------------------------------------------------- 1 | 42 2 | "Hello" 3 | false 4 | "3.14" 5 | 2 6 | {"type":"null","value":null} 7 | null 8 | {"type":"boolean","value":true} 9 | true 10 | -------------------------------------------------------------------------------- /nursery/LibNurseryTests/LibNurseryTests.milone: -------------------------------------------------------------------------------- 1 | module rec LibNurseryTests.Program 2 | 3 | open LibNurseryTests.ClapTests 4 | 5 | let main _ = 6 | testClapModule () 7 | 0 8 | -------------------------------------------------------------------------------- /tests/edges/unary_op_syntax/unary_op_syntax.fs: -------------------------------------------------------------------------------- 1 | module rec unary_op_syntax.Program 2 | 3 | let f (n: int) (m: int) = n = m + 1 4 | 5 | let main _ = 6 | assert (f -1 -2) 7 | 0 8 | -------------------------------------------------------------------------------- /tests/errors/main_fun_invalid_err/main_fun_invalid_err.c: -------------------------------------------------------------------------------- 1 | #error main_fun_invalid_err.main_fun_invalid_err:4:1 main function must be defined in the form of: `let main _ = ...`. 2 | -------------------------------------------------------------------------------- /tests/errors/union_with_ty_args/union_with_ty_args.c: -------------------------------------------------------------------------------- 1 | #error union_with_ty_args.union_with_ty_args:6:10 Type arity mismatch. The type 'MyInt' expected 0 arguments; but given 1. 2 | -------------------------------------------------------------------------------- /tests/errors/ty_var_err/ty_var_err.fs: -------------------------------------------------------------------------------- 1 | module rec ty_var_err.Program 2 | 3 | let pair (x: 'x) (y: 'x) = x, y 4 | 5 | let main _ = 6 | // Type error. 7 | let _ = pair 2 "a" 8 | 0 9 | -------------------------------------------------------------------------------- /tests/examples/fizz_buzz/fizz_buzz.output: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | Fizz 4 | 4 5 | Buzz 6 | Fizz 7 | 7 8 | 8 9 | Fizz 10 | Buzz 11 | 11 12 | Fizz 13 | 13 14 | 14 15 | FizzBuzz 16 | $? = 0 17 | -------------------------------------------------------------------------------- /nursery/AppGtk/build-1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | MILONE_HOME=${MILONE_HOME:-"${HOME}/.milone"} 6 | 7 | mkdir -p target 8 | 9 | milone compile "$PWD" >target/app_gtk.c 10 | -------------------------------------------------------------------------------- /nursery/CmdSqliteTodo/milone_manifest: -------------------------------------------------------------------------------- 1 | std gnu11 2 | cc ../LibSqlite3/lib_sqlite3_runtime.c 3 | obj ../vendor/sqlite3/sqlite3.o 4 | lib dl 5 | lib pthread 6 | sanitize address,leak,undefined 7 | -------------------------------------------------------------------------------- /scripts/project-reference-example/app.output: -------------------------------------------------------------------------------- 1 | gcd(1, 1) = 1 2 | lcm(1, 1) = 1 3 | gcd(2, 3) = 1 4 | lcm(2, 3) = 6 5 | gcd(4, 6) = 2 6 | lcm(4, 6) = 12 7 | gcd(8, 16) = 8 8 | lcm(8, 16) = 16 9 | -------------------------------------------------------------------------------- /tests/errors/union_with_ty_args/union_with_ty_args.fs: -------------------------------------------------------------------------------- 1 | module rec union_with_ty_args.Program 2 | 3 | type MyInt = Value of int 4 | 5 | let main _ = 6 | let _: MyInt<_> = Value 0 7 | 0 8 | -------------------------------------------------------------------------------- /tests/primitives/tuple_arg/tuple_arg.fs: -------------------------------------------------------------------------------- 1 | module rec tuple_arg.Program 2 | 3 | // Tuples work as function argument. 4 | 5 | let main _ = 6 | let sub (x, y) = x - y 7 | sub (8, 3) - 5 8 | -------------------------------------------------------------------------------- /tests/errors/scope_undefined_ty_err/scope_undefined_ty_err.c: -------------------------------------------------------------------------------- 1 | #error scope_undefined_ty_err.scope_undefined_ty_err:5:11 The name 'NotExistingTy' here should denote to some type; but not found. 2 | -------------------------------------------------------------------------------- /tests/errors/record_missing_err/record_missing_err.fs: -------------------------------------------------------------------------------- 1 | module rec record_missing_err.Program 2 | 3 | type Point = { X: int; Y: int } 4 | 5 | let main _ = 6 | let _p: Point = { X = 1 } 7 | 8 | 0 9 | -------------------------------------------------------------------------------- /tests/errors/scope_undefined_var_err/scope_undefined_var_err.c: -------------------------------------------------------------------------------- 1 | #error scope_undefined_var_err.scope_undefined_var_err:6:11 The name 'undefinedVar' here should denote to some value; but not found. 2 | -------------------------------------------------------------------------------- /tests/errors/ty_label_err/ty_label_err.fs: -------------------------------------------------------------------------------- 1 | module rec ty_label_err.Program 2 | 3 | // Labeled types can be used inside of payload type. 4 | 5 | type U = V of (label: int) 6 | 7 | let main _ = 0 8 | -------------------------------------------------------------------------------- /nursery/CmdSqliteTodo/test-expected.txt: -------------------------------------------------------------------------------- 1 | No tasks. 2 | 3 | 1:wash cups 4 | 2:wash dishes 5 | 3:wipe table 6 | 7 | 3:wipe table 8 | 9 | 3:wipe table 10 | 11 | 3:wipe table 12 | 4:take bath 13 | -------------------------------------------------------------------------------- /src/MiloneLspServer/req: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # USAGE: echo '{ ... }' | ./req 3 | 4 | set -eu 5 | 6 | BODY=$(cat) 7 | 8 | echo "Content-Length: $(echo "$BODY" | wc -c)" 9 | echo 10 | echo "$BODY" 11 | -------------------------------------------------------------------------------- /src/Std/StdEnvBase.milone: -------------------------------------------------------------------------------- 1 | module rec Std.StdEnvBase 2 | 3 | let getArgCount () : int = __nativeFun "milone_get_arg_count" 4 | 5 | let getArg (index: int) : string = __nativeFun ("milone_get_arg", index) 6 | -------------------------------------------------------------------------------- /tests/edges/fun_underlying_fun_forward_decl_issue/sub.fs: -------------------------------------------------------------------------------- 1 | module rec fun_underlying_fun_forward_decl_issue.sub 2 | 3 | let f (x: int) (y: string) = "x = " + string x + ", y = " + y 4 | 5 | let f2 = f 2 6 | -------------------------------------------------------------------------------- /tests/errors/illegal_use_prim_err/illegal_use_prim_err.fs: -------------------------------------------------------------------------------- 1 | module rec illegal_use_prim_err.Program 2 | 3 | let main _ = 4 | let _ = __discriminant 0 5 | let _ = __discriminant (Some 0) 6 | 7 | 0 8 | -------------------------------------------------------------------------------- /tests/errors/main_fun_invalid_err/main_fun_invalid_err.fs: -------------------------------------------------------------------------------- 1 | module rec main_fun_invalid_err.Program 2 | 3 | // main function's argument is restricted to _ for compatibility with F#. 4 | let main () = 0 5 | -------------------------------------------------------------------------------- /tests/errors/pat_or_var_incompatible_ty_err/pat_or_var_incompatible_ty_err.c: -------------------------------------------------------------------------------- 1 | #error pat_or_var_incompatible_ty_err.pat_or_var_incompatible_ty_err:10:3 OR pattern including some bindings is unimplemented. 2 | -------------------------------------------------------------------------------- /tests/errors/record_noinfer_err/record_noinfer_err.c: -------------------------------------------------------------------------------- 1 | #error record_noinfer_err.record_noinfer_err:8:18 Record type is not inferred. Record type must be known at the point. Hint: Consider add a type ascription. 2 | -------------------------------------------------------------------------------- /tests/pendings/fun_forward_reference_inference_bug/fun_forward_reference_inference_bug.c: -------------------------------------------------------------------------------- 1 | #error fun_forward_reference_inference_bug.fun_forward_reference_inference_bug:8:17 Type mismatch: 'string' <> 'int'. 2 | -------------------------------------------------------------------------------- /nursery/format: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | find -type f -name '*.milone' | \ 6 | xargs -I{} -P4 sh -c 'cp -f {} {}_.fs; dotnet fantomas {}_.fs; if test $? -eq 0; then cat {}_.fs >{}; fi; rm -f {}_.fs' 7 | -------------------------------------------------------------------------------- /tests/errors/printfn_no_format_err/printfn_no_format_err.c: -------------------------------------------------------------------------------- 1 | #error printfn_no_format_err.printfn_no_format_err:7:3 Illegal use of printfn. printfn must have string literal as first argument; e.g. `printfn "%s" s`. 2 | -------------------------------------------------------------------------------- /tests/errors/record_redundant_err/record_redundant_err.fs: -------------------------------------------------------------------------------- 1 | module rec record_redundant_err.Program 2 | 3 | type Point = { X: int; Y: int } 4 | 5 | let main _ = 6 | let _p: Point = { X = 1; Y = 2; Z = 3 } 7 | 0 8 | -------------------------------------------------------------------------------- /src/Std/README.md: -------------------------------------------------------------------------------- 1 | # Std 2 | 3 | **Std** is one of standard library of milone-lang 4 | for modules that are NOT available in F# and/or NOT compatible with F#. 5 | 6 | **WARN**: Interface of this library is unstable. 7 | -------------------------------------------------------------------------------- /tests/errors/module_no_leak/module_no_leak_f2.fs: -------------------------------------------------------------------------------- 1 | module rec module_no_leak.module_no_leak_f2 2 | 3 | open module_no_leak.module_no_leak_f1 4 | 5 | let f2 () = 6 | // f1 is visible thanks to open above. 7 | f1 () 8 | -------------------------------------------------------------------------------- /tests/errors/scope_undefined_ty_err/scope_undefined_ty_err.fs: -------------------------------------------------------------------------------- 1 | module rec scope_undefined_ty_err.Program 2 | 3 | // Use of undefined type name is error. 4 | 5 | let f (_: NotExistingTy) = () 6 | 7 | let main _ = 0 8 | -------------------------------------------------------------------------------- /tests/errors/ty_synonym_undefined_ty_var_err/ty_synonym_undefined_ty_var_err.c: -------------------------------------------------------------------------------- 1 | #error ty_synonym_undefined_ty_var_err.ty_synonym_undefined_ty_var_err:5:25 The name ''U' here should denote to some type; but not found. 2 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | Language: Cpp 2 | 3 | # `if (cond) {` style. 4 | BreakBeforeBraces: Attach 5 | 6 | # Don't rearrange `#include`s. 7 | IncludeBlocks: Preserve 8 | 9 | # Indent with 4 spaces. 10 | IndentWidth: 4 11 | -------------------------------------------------------------------------------- /tests/errors/native_fun_illegal_use_err/native_fun_illegal_use_err.c: -------------------------------------------------------------------------------- 1 | #error native_fun_illegal_use_err.native_fun_illegal_use_err:7:3 Illegal use of __nativeFun. Hint: `__nativeFun ("funName", arg1, arg2, ...): ResultType`. 2 | -------------------------------------------------------------------------------- /.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "fantomas": { 6 | "version": "5.2.0", 7 | "commands": [ 8 | "fantomas" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /nursery/LibTextProcess/LibTextProcess.milone: -------------------------------------------------------------------------------- 1 | open LibTextProcess.LexTests 2 | open LibTextProcess.TextPositionTests 3 | open LibTextProcess.TinyIniTests 4 | open LibTextProcess.TinyYamlTests 5 | open LibTextProcess.UnicodeTests 6 | -------------------------------------------------------------------------------- /src/MiloneLspServer/dev: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | trap 'kill 0' SIGINT 5 | 6 | dotnet watch build --no-restore & 7 | 8 | ( 9 | cd ../../vscode_ext 10 | npm run webpack-watch 11 | ) & 12 | 13 | wait 14 | -------------------------------------------------------------------------------- /nursery/ExDylib/hello/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[no_mangle] 2 | pub extern "C" fn my_plus2(x: i32, y: i32) -> i32 { 3 | x + y 4 | } 5 | 6 | #[no_mangle] 7 | pub extern "C" fn my_hello() { 8 | println!("Hello from Rust."); 9 | } 10 | -------------------------------------------------------------------------------- /vscode_ext/uninstall: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Uninstall the extension from locally-installed VSCode. 3 | # (Works to uninstall either one installed via package manager or locally built.) 4 | 5 | code --uninstall-extension vain0x.milone-lang 6 | -------------------------------------------------------------------------------- /nursery/CmdCat/test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # env: $CAT 3 | 4 | set -eu 5 | 6 | ( 7 | cd tests 8 | ${CAT} input1.txt input2.txt >output.ignored.txt 9 | diff -q output.ignored.txt output-expected.txt 10 | ) 11 | 12 | echo OK 13 | -------------------------------------------------------------------------------- /nursery/LibSpan/Span.milone: -------------------------------------------------------------------------------- 1 | module rec LibSpan.Span 2 | 3 | type Span = __nativeType<``struct Span``> 4 | 5 | let take (len: unativeint) (itemSize: unativeint) (span: Span) : Span = 6 | __nativeFun ("span_take", span, len, itemSize) 7 | -------------------------------------------------------------------------------- /tests/errors/scope_undefined_var_err/scope_undefined_var_err.fs: -------------------------------------------------------------------------------- 1 | module rec scope_undefined_var_err.Program 2 | 3 | // Use of undefined var name is error. 4 | 5 | let main _ = 6 | assert (undefinedVar = 0) 7 | assert false 8 | 0 9 | -------------------------------------------------------------------------------- /tests/examples/factorial/factorial.fs: -------------------------------------------------------------------------------- 1 | module rec factorial.Program 2 | 3 | let main _ = 4 | let rec factorial x = 5 | if x = 0 then 6 | 1 7 | else 8 | x * factorial (x - 1) 9 | 10 | factorial 5 - 120 11 | -------------------------------------------------------------------------------- /tests/edges/pat_with_vis/pat_with_vis.fs: -------------------------------------------------------------------------------- 1 | module rec pat_with_vis.Program 2 | 3 | type Wrap = Wrap of int 4 | 5 | let (Wrap (public x), private y) = Wrap 2, 3 6 | 7 | let main _ = 8 | assert (x = 2) 9 | assert (y = 3) 10 | 0 11 | -------------------------------------------------------------------------------- /tests/errors/pat_nav_unresolved_err/pat_nav_unresolved_err.fs: -------------------------------------------------------------------------------- 1 | module rec pat_nav_unresolved_err.Program 2 | 3 | // Unresolved nav pattern is error. 4 | 5 | let main _ = 6 | match () with 7 | | A.x -> assert false 8 | 9 | 0 10 | -------------------------------------------------------------------------------- /tests/errors/ty_synonym_cyclic_err/ty_synonym_cyclic_err.c: -------------------------------------------------------------------------------- 1 | #error ty_synonym_cyclic_err.ty_synonym_cyclic_err:5:1 Cyclic type synonym is forbidden. 2 | #error ty_synonym_cyclic_err.ty_synonym_cyclic_err:7:1 Cyclic type synonym is forbidden. 3 | -------------------------------------------------------------------------------- /tests/features/ty_synonym_generic/ty_synonym_generic.fs: -------------------------------------------------------------------------------- 1 | module rec ty_synonym_generic.Program 2 | 3 | type Stack<'T> = 'T list 4 | 5 | let newStack () : Stack<_> = [] 6 | 7 | let main _ = 8 | let _stack = 1 :: newStack () 9 | 0 10 | -------------------------------------------------------------------------------- /tests/primitives/tuple_string/tuple_string.fs: -------------------------------------------------------------------------------- 1 | module rec tuple_string.Program 2 | 3 | let main _ = 4 | assert (string () = "()") 5 | assert (string (1, 2, 3) = "(1, 2, 3)") 6 | assert (string (1, 2, (3, 4)) = "(1, 2, (3, 4))") 7 | 0 8 | -------------------------------------------------------------------------------- /scripts/project-reference-example/Lib/Gcd.fs: -------------------------------------------------------------------------------- 1 | module rec Lib.Gcd 2 | 3 | let gcd (x: int) (y: int) = 4 | assert (x >= 0) 5 | assert (y >= 0) 6 | 7 | let rec go (x: int) (y: int) = if y = 0 then x else go y (x % y) 8 | 9 | go x y 10 | -------------------------------------------------------------------------------- /tests/edges/empty/empty.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv); 6 | 7 | int main(int argc, char **argv) { 8 | milone_start(argc, argv); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /scripts/test_output_option/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | MILONE=${MILONE:-milone} 6 | PROJECT_DIR=$(dirname "$0")/OutputOptionTest 7 | OUTPUT=$PROJECT_DIR/a.out 8 | 9 | "$MILONE" build --output "$OUTPUT" "$PROJECT_DIR" && "$OUTPUT" 10 | -------------------------------------------------------------------------------- /src/Std/StdEnvBase.fs: -------------------------------------------------------------------------------- 1 | module rec Std.StdEnvBase 2 | 3 | open System 4 | 5 | let internal getArgCount () : int = Environment.GetCommandLineArgs().Length 6 | 7 | let internal getArg (index: int) : string = 8 | Environment.GetCommandLineArgs().[index] 9 | -------------------------------------------------------------------------------- /nursery/CmdLspServer/milone_manifest: -------------------------------------------------------------------------------- 1 | std gnu11 2 | 3 | cc cmd_lsp_server_runtime.c 4 | 5 | # sqlite3 6 | cc ../LibSqlite3/lib_sqlite3_runtime.c 7 | obj ../vendor/sqlite3/sqlite3.o 8 | lib dl 9 | lib pthread 10 | 11 | sanitize address,undefined 12 | -------------------------------------------------------------------------------- /tests/edges/return_zero/return_zero.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv); 6 | 7 | int main(int argc, char **argv) { 8 | milone_start(argc, argv); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /tests/features/modules/modules_sub.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int32_t modules_sub_Int32Int32Fun1_f(int32_t x_); 6 | 7 | int32_t modules_sub_Int32Int32Fun1_f(int32_t x_) { 8 | return x_; 9 | } 10 | -------------------------------------------------------------------------------- /nursery/AppBlog/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "blog" 3 | version = "0.1.0" 4 | edition = "2021" 5 | build = "build.rs" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /nursery/ExDylib/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | # PIC: position-independent-code 6 | gcc -fPIC -c libplus.c -o libplus.o 7 | gcc -shared -o libplus.so libplus.o 8 | 9 | ( 10 | cd hello 11 | cargo build 12 | ) 13 | 14 | milone run $PWD 15 | -------------------------------------------------------------------------------- /nursery/LibSpanTests/LibSpanTests.milone: -------------------------------------------------------------------------------- 1 | module rec LibSpanTests.Program 2 | 3 | module Buffer = LibSpan.Buffer 4 | 5 | let main _ = 6 | let buffer = Buffer.create (unativeint 1000) 1un 7 | 8 | assert (Buffer.cap buffer = unativeint 1000) 9 | 0 10 | -------------------------------------------------------------------------------- /nursery/README.md: -------------------------------------------------------------------------------- 1 | # Nursery 2 | 3 | WARNING: *Highly unstable. Not maintained well.* 4 | 5 | This directory is an experimental of development with milone-lang. 6 | These code rely on the implementation details of the compiler, such as memory layout of objects. 7 | -------------------------------------------------------------------------------- /tests/errors/module_used_as_ty_err/module_used_as_ty_err.fs: -------------------------------------------------------------------------------- 1 | module rec module_used_as_ty_err.Program 2 | 3 | // Module name cannot be used as type. 4 | 5 | open module_used_as_ty_err.sub 6 | 7 | let main _ = 8 | let x: sub = failwith "error" 9 | 0 10 | -------------------------------------------------------------------------------- /tests/pendings/never_id_bug/never_id_bug.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv); 6 | 7 | int main(int argc, char **argv) { 8 | milone_start(argc, argv); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /scripts/StaticLibTest/StaticLibTest.milone: -------------------------------------------------------------------------------- 1 | [] 2 | let my_gcd (x: int) (y: int) = 3 | assert (y >= 0) 4 | 5 | if y = 0 then 6 | x 7 | else 8 | my_gcd y (x % y) 9 | 10 | [] 11 | let my_multiply (x: int) (y: float) = float x * y 12 | -------------------------------------------------------------------------------- /tests/errors/printfn_no_format_err/printfn_no_format_err.fs: -------------------------------------------------------------------------------- 1 | module rec printfn_no_format_err.Program 2 | 3 | // printfn requires a string literal as first argument. 4 | 5 | let main _ = 6 | let msg = "hello!" 7 | printfn msg 8 | assert false 9 | 0 10 | -------------------------------------------------------------------------------- /tests/features/module_synonym/module_synonym_sub.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int32_t module_synonym_sub_inc(int32_t x_); 6 | 7 | int32_t module_synonym_sub_inc(int32_t x_) { 8 | return (x_ + 1); 9 | } 10 | -------------------------------------------------------------------------------- /tests/edges/recursive_ty_error_by_synonym/recursive_ty_error_by_synonym.fs: -------------------------------------------------------------------------------- 1 | module rec recursive_ty_error_by_synonym.Program 2 | 3 | type Synonym<'T> = 'T 4 | 5 | let just (value: 'T) : Synonym<'T> = value 6 | 7 | let main _ = 8 | assert (just 2 = 2) 9 | 0 10 | -------------------------------------------------------------------------------- /tests/features/module_dependencies/module_dependencies.fs: -------------------------------------------------------------------------------- 1 | module rec module_dependencies.Program 2 | 3 | // Module dependencies are resolved transitively. 4 | 5 | open module_dependencies.second 6 | open module_dependencies.third 7 | 8 | let main _ = second () + third () 9 | -------------------------------------------------------------------------------- /tests/features/module_dependencies/module_dependencies_root.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int32_t module_dependencies_root_root(void); 6 | 7 | int32_t module_dependencies_root_root(void) { 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /tests/pendings/octet_literal_bug/octet_literal_bug.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv); 6 | 7 | int main(int argc, char **argv) { 8 | milone_start(argc, argv); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /src/Std/StdJsonBase.fs: -------------------------------------------------------------------------------- 1 | // F# only 2 | module rec Std.StdJsonBase 3 | 4 | let encodeUtf8 (codePoint: int) : string option = 5 | System.Text.Encoding.UTF32.GetString(System.BitConverter.GetBytes(codePoint)) 6 | |> Some 7 | 8 | let jsonNumberToString (n: float) = string n 9 | -------------------------------------------------------------------------------- /tests/edges/pat_or_deep_branches/pat_or_deep_branches.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv); 6 | 7 | int main(int argc, char **argv) { 8 | milone_start(argc, argv); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /scripts/test-std: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | MILONE_HOME="$(dirname "$0")/.." 6 | # MILONE="$MILONE_HOME/target/MiloneCli/x86_64-unknown-linux-gnu-release/MiloneCli" 7 | MILONE=${MILONE:-milone} 8 | 9 | MILONE_HOME=$MILONE_HOME $MILONE run "$MILONE_HOME/src/Std" 10 | -------------------------------------------------------------------------------- /src/Std/Equal.milone: -------------------------------------------------------------------------------- 1 | module rec Std.Equal 2 | 3 | let genericListEqual (equalFun: 'T -> 'T -> bool) (xs: 'T list) (ys: 'T list) : bool = 4 | match xs, ys with 5 | | [], [] -> true 6 | | x :: xs, y :: ys when equalFun x y -> genericListEqual equalFun xs ys 7 | | _ -> false 8 | -------------------------------------------------------------------------------- /tests/errors/vis_private_err/vis_private_err.fs: -------------------------------------------------------------------------------- 1 | module rec vis_private_err.Program 2 | 3 | // Private definitions should not be visible to outside of module. 4 | 5 | open vis_private_err.vis_private_sub 6 | 7 | let main _ = 8 | vis_private_sub.privateFun () 9 | 0 10 | -------------------------------------------------------------------------------- /tests/features/match_nonexhaustive/match_nonexhaustive.fs: -------------------------------------------------------------------------------- 1 | module rec match_nonexhaustive.Program 2 | 3 | // Non-exhaustive pattern matching. 4 | 5 | let main _ = 6 | match 2 * 2, 3 * 3 with 7 | | 4, 9 -> 0 8 | 9 | | 999, y -> 10 | assert (y <> 9) 11 | 1 12 | -------------------------------------------------------------------------------- /tests/features/module_inner/module_inner_sub.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int32_t module_inner_sub_Inner_decrement(int32_t x_); 6 | 7 | int32_t module_inner_sub_Inner_decrement(int32_t x_) { 8 | return (x_ - 1); 9 | } 10 | -------------------------------------------------------------------------------- /tests/features/module_synonym/module_synonym.fs: -------------------------------------------------------------------------------- 1 | module rec module_synonym.Program 2 | 3 | // S is defined as alias of `module_synonym.sub` 4 | // and `sub` is added to the project. 5 | module S = module_synonym.sub 6 | 7 | let main _ = 8 | assert (S.inc 2 = 3) 9 | 0 10 | -------------------------------------------------------------------------------- /tests/features/record/record.fs: -------------------------------------------------------------------------------- 1 | module rec record.Program 2 | 3 | // Basic use of record type. 4 | 5 | type Point = { X: int; Y: int } 6 | 7 | let main _ = 8 | let point: Point = { X = 40; Y = 2 } 9 | 10 | assert (point.X = 40) 11 | assert (point.Y = 2) 12 | 0 13 | -------------------------------------------------------------------------------- /tests/pendings/record_private_fields/record_private_fields.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv); 6 | 7 | int main(int argc, char **argv) { 8 | milone_start(argc, argv); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /tests/pendings/union_private_variants/union_private_variants.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv); 6 | 7 | int main(int argc, char **argv) { 8 | milone_start(argc, argv); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /tests/pendings/unreachable_match_bug/unreachable_match_bug.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv); 6 | 7 | int main(int argc, char **argv) { 8 | milone_start(argc, argv); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /tests/errors/module_open_not_found_err/module_open_not_found_err.fs: -------------------------------------------------------------------------------- 1 | module rec module_open_not_found_err.Program 2 | 3 | // Trying to open non-existing module is an error. 4 | 5 | open module_open_not_found_err.NotExistingModule 6 | 7 | let main _ = 8 | assert false 9 | 0 10 | -------------------------------------------------------------------------------- /tests/errors/native_fun_illegal_use_err/native_fun_illegal_use_err.fs: -------------------------------------------------------------------------------- 1 | module rec native_fun_illegal_use_err.Program 2 | 3 | // __nativeFun must be used in correct syntax. 4 | 5 | let main _ = 6 | let name = "__someFun" 7 | __nativeFun name 1 2 3 8 | assert false 9 | 0 10 | -------------------------------------------------------------------------------- /tests/features/module_prelude/module_prelude.fs: -------------------------------------------------------------------------------- 1 | module rec module_prelude.Program 2 | 3 | // Prelude functions are visible by default. 4 | // See src/MiloneCore/Prelude.milone for implementations. 5 | 6 | let main _ = 7 | assert (id true) 8 | assert (id 42 = 42) 9 | 0 10 | -------------------------------------------------------------------------------- /src/Std/BoxTests.milone: -------------------------------------------------------------------------------- 1 | open Std.Box 2 | 3 | let testBox () = 4 | let bb = BoxBuffer.create 42 5 | let n, bb = BoxBuffer.read bb 6 | assert (n = 42) 7 | 8 | let bb = BoxBuffer.write 64 bb 9 | let n, bb = BoxBuffer.read bb 10 | assert (n = 64) 11 | BoxBuffer.dispose bb 12 | -------------------------------------------------------------------------------- /tests/errors/illegal_use_prim_err/illegal_use_prim_err.c: -------------------------------------------------------------------------------- 1 | #error illegal_use_prim_err.illegal_use_prim_err:4:11 Illegal use of __discriminant. Hint: `__discriminant Variant`. 2 | #error illegal_use_prim_err.illegal_use_prim_err:5:11 Illegal use of __discriminant. Hint: `__discriminant Variant`. 3 | -------------------------------------------------------------------------------- /tests/errors/module_no_leak/module_no_leak.fs: -------------------------------------------------------------------------------- 1 | module rec module_no_leak.Program 2 | 3 | // Depends on f2 and transitively depends on f1, but module f1 is not open here. 4 | open module_no_leak.module_no_leak_f2 5 | 6 | let main _ = 7 | // This should be error! 8 | f1 () 9 | 0 10 | -------------------------------------------------------------------------------- /tests/primitives/effect_printfn/effect_printfn.fs: -------------------------------------------------------------------------------- 1 | module rec effect_printfn.Program 2 | 3 | let main _ = 4 | printfn "No formats" 5 | 6 | let hello = "Hello!" 7 | printfn "%s" hello 8 | 9 | printfn "Welcome to %s. Entry price is %c%d!" "Milone Land" '$' 1000000007 10 | 0 11 | -------------------------------------------------------------------------------- /tests/primitives/union_runtime/union_runtime.fs: -------------------------------------------------------------------------------- 1 | module rec union_runtime.Program 2 | 3 | type private Color = 4 | | R 5 | | G 6 | | B 7 | 8 | let main _ = 9 | assert (__discriminant R = 0) 10 | assert (__discriminant G = 1) 11 | assert (__discriminant B = 2) 12 | 0 13 | -------------------------------------------------------------------------------- /nursery/CmdJsonGet/test-input.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "3.14", 3 | "entries": [ 4 | { 5 | "type": "null", 6 | "value": null 7 | }, 8 | { 9 | "type": "boolean", 10 | "value": true 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /tests/errors/synonym_arity_err/synonym_arity_err.c: -------------------------------------------------------------------------------- 1 | #error synonym_arity_err.synonym_arity_err:7:16 Type arity mismatch. The type 'Stack' expected 1 arguments; but given 2. 2 | #error synonym_arity_err.synonym_arity_err:10:15 Type arity mismatch. The type 'Stack' expected 1 arguments; but given 0. 3 | -------------------------------------------------------------------------------- /tests/primitives/effect_assert/effect_assert.fs: -------------------------------------------------------------------------------- 1 | module rec effect_assert.Program 2 | 3 | let main _ = 4 | assert true 5 | printfn "pass" 6 | 7 | printfn "Notice: test 'effect_assert' intentionally prints an assertion error:" 8 | assert false 9 | printfn "not pass" 10 | 0 11 | -------------------------------------------------------------------------------- /tests/primitives/tuple_large/tuple_large.fs: -------------------------------------------------------------------------------- 1 | module rec tuple_many.Program 2 | 3 | // Tuple with large number of items. 4 | 5 | let main _ = 6 | let x, y, (z, w) = 1, 2, (3, 4) 7 | assert (x = 1 && y = 2 && z = 3 && w = 4) 8 | 9 | let _t11 = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 10 | 0 11 | -------------------------------------------------------------------------------- /scripts/StaticLibTest/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | PROJECT_DIR=$(dirname "$PWD/$0") 6 | 7 | ( 8 | cd "$PROJECT_DIR" 9 | set -x 10 | 11 | milone build "$PROJECT_DIR" -o mylib.a 12 | gcc -c app.c -o app.o 13 | gcc -o app.out mylib.a app.o 14 | ./app.out 15 | ) 16 | -------------------------------------------------------------------------------- /tests/errors/fun_nonrec_err/fun_nonrec_err.fs: -------------------------------------------------------------------------------- 1 | module rec fun_nonrec_err.Program 2 | 3 | // Function defined with non-rec let can't recursively call itself. 4 | 5 | let main _ = 6 | let nonRecLoop (i: int) = 7 | assert (i <> 0) 8 | nonRecLoop (i + 1) 9 | 10 | nonRecLoop 0 11 | 1 12 | -------------------------------------------------------------------------------- /tests/errors/module_used_as_ty_err/module_used_as_ty_err.c: -------------------------------------------------------------------------------- 1 | #error module_used_as_ty_err.module_used_as_ty_err:8:10 The name 'sub' here should denote to some type; but not found. 2 | #error module_used_as_ty_err.module_used_as_ty_err:8:16 The name 'failwith' here should denote to some value; but not found. 3 | -------------------------------------------------------------------------------- /tests/errors/pat_resolved_as_fun_err/pat_resolved_as_fun_err.fs: -------------------------------------------------------------------------------- 1 | module rec pat_resolved_as_fun_err.Program 2 | 3 | // Function name can't be used as pattern. 4 | 5 | open pat_resolved_as_fun_err.sub 6 | 7 | let main _ = 8 | match fun () -> () with 9 | | sub.f -> assert true 10 | 11 | 0 12 | -------------------------------------------------------------------------------- /tests/errors/pat_or_name_conflict_err/pat_or_name_conflict_err.fs: -------------------------------------------------------------------------------- 1 | module rec pat_or_name_conflict_err.Program 2 | 3 | let main _ = 4 | match [ 2; 2 ] with 5 | | [ x; x ] -> assert (x = x) 6 | | _ -> () 7 | 8 | let y, y = 2, 3 9 | 10 | let (z as z) = 2, 3 11 | 12 | assert false 13 | 0 14 | -------------------------------------------------------------------------------- /tests/errors/ty_synonym_undefined_ty_var_err/ty_synonym_undefined_ty_var_err.fs: -------------------------------------------------------------------------------- 1 | module rec ty_synonym_undefined_ty_var_err.Program 2 | 3 | // Error if synonym definition contains undefined type variables. 4 | 5 | type Synonym<'T> = 'T * 'U 6 | 7 | let main _ = 8 | let s: Synonym<_> = 2, "x" 9 | 0 10 | -------------------------------------------------------------------------------- /tests/features/union_newtype/union_newtype.fs: -------------------------------------------------------------------------------- 1 | module rec union_newtype.Program 2 | 3 | /// New-type union. 4 | type NewTypeInt = NewTypeInt of int 5 | 6 | let main _ = 7 | // New-type union can be unwrap with `let`. 8 | let (NewTypeInt inner) = NewTypeInt 1 9 | assert (inner = 1) 10 | 11 | 0 12 | -------------------------------------------------------------------------------- /tests/edges/union_generic_crash/union_generic_crash.fs: -------------------------------------------------------------------------------- 1 | module rec union_generic_crash.Program 2 | 3 | // Repro. Generic union caused a compile to crash 4 | // while computing mangled name. 5 | 6 | type private GU<'T> = GU of GU<'T> option 7 | 8 | let main _ = 9 | let _: GU = GU None 10 | 0 11 | -------------------------------------------------------------------------------- /tests/features/ty_ascribe/ty_ascribe.fs: -------------------------------------------------------------------------------- 1 | module rec ty_ascribe.Program 2 | 3 | // Type ascription (`xxx : type`). 4 | 5 | let main _ = 6 | let f x : int = x 7 | let g (x: int) = x 8 | let zero = f 1 - g 1 9 | 10 | let xs: _ list = [ 1 ] 11 | 12 | let ys: list = [ "a" ] 13 | 14 | zero 15 | -------------------------------------------------------------------------------- /tests/edges/union_generic_ty_error/union_generic_ty_error.fs: -------------------------------------------------------------------------------- 1 | module rec union_generic_ty_error.Program 2 | 3 | type private MyOption<'T> = 4 | | MyNone 5 | | MySome of 'T 6 | 7 | let main _ = 8 | match MySome 42 with 9 | | MyNone -> assert false 10 | | MySome (s: string) -> assert (s <> "") 11 | 12 | 0 13 | -------------------------------------------------------------------------------- /tests/errors/synonym_arity_err/synonym_arity_err.fs: -------------------------------------------------------------------------------- 1 | module rec synonym_arity_err.Program 2 | 3 | // Use of generic type synonyms with wrong arity should be reported as error. 4 | 5 | type Stack<'T> = 'T list 6 | 7 | let f (_stack: Stack) = () 8 | 9 | let main _ = 10 | let _stack: Stack = [] 11 | 0 12 | -------------------------------------------------------------------------------- /tests/features/match_exhaustive/match_exhaustive.fs: -------------------------------------------------------------------------------- 1 | module rec match_exhaustive.Program 2 | 3 | // Match expression, which is exhaustive. 4 | 5 | let main _ = 6 | let f (x: int) = x * x 7 | 8 | match f 3 with 9 | | 1 -> 10 | assert false 11 | 1 12 | 13 | | y -> 14 | assert (y = 9) 15 | 0 16 | -------------------------------------------------------------------------------- /tests/features/pat_when/pat_when.fs: -------------------------------------------------------------------------------- 1 | module rec pat_when.Program 2 | 3 | // Match arm can have guard expressions. 4 | 5 | let equal (t: int * int) = 6 | match t with 7 | | x, y when x = y -> true 8 | | _ -> false 9 | 10 | let main _ = 11 | assert (equal (1, 1)) 12 | assert (equal (1, 2) |> not) 13 | 0 14 | -------------------------------------------------------------------------------- /scripts/project-reference-example/App/App.fs: -------------------------------------------------------------------------------- 1 | module rec App.App 2 | 3 | open Lib.Lcm 4 | open Lib.Gcd 5 | 6 | let f x y = 7 | printfn "gcd(%d, %d) = %d" x y (gcd x y) 8 | printfn "lcm(%d, %d) = %d" x y (lcm x y) 9 | 10 | [] 11 | let main _ = 12 | f 1 1 13 | f 2 3 14 | f 4 6 15 | f 8 16 16 | 0 17 | -------------------------------------------------------------------------------- /tests/errors/pat_or_name_conflict_err/pat_or_name_conflict_err.c: -------------------------------------------------------------------------------- 1 | #error pat_or_name_conflict_err.pat_or_name_conflict_err:5:10 Variable name conflicts 2 | #error pat_or_name_conflict_err.pat_or_name_conflict_err:8:10 Variable name conflicts 3 | #error pat_or_name_conflict_err.pat_or_name_conflict_err:10:13 Variable name conflicts 4 | -------------------------------------------------------------------------------- /tests/features/global_var/global_var.fs: -------------------------------------------------------------------------------- 1 | module rec global_var.Program 2 | 3 | // Let expression can define global variables. 4 | 5 | let success = 0 6 | 7 | let private failure = 1 8 | 9 | let f () = success 10 | 11 | let g () = f () 12 | 13 | let main _ = 14 | assert (g () = 0) 15 | assert (failure = 1) 16 | 0 17 | -------------------------------------------------------------------------------- /src/MiloneLspServer/JsonValue.fs: -------------------------------------------------------------------------------- 1 | [] 2 | module MiloneLspServer.JsonValue 3 | 4 | type JsonValue = 5 | | JNull 6 | | JString of stringValue: string 7 | | JNumber of numberValue: float 8 | | JBoolean of boolValue: bool 9 | | JArray of items: JsonValue list 10 | | JObject of entries: Map 11 | -------------------------------------------------------------------------------- /tests/features/module_milone_core/module_milone_core.fs: -------------------------------------------------------------------------------- 1 | module rec module_milone_core.Program 2 | 3 | // MiloneCore modules are visible by default. 4 | // See src/MiloneCore for implementations. 5 | 6 | let assertNotEmpty (xs: _ list) = assert (not (List.isEmpty xs)) 7 | 8 | let main _ = 9 | assertNotEmpty [ 1 ] 10 | 0 11 | -------------------------------------------------------------------------------- /tests/pendings/pat_or_bindings/pat_or_bindings.fs: -------------------------------------------------------------------------------- 1 | module rec pat_or_bindings.Program 2 | 3 | // OR patterns including some bindings is not implemented correctly yet. 4 | 5 | let main _ = 6 | match [ 2; 3 ] with 7 | | x :: _ 8 | | _ :: x :: _ -> assert (x = 2 || x = 3) 9 | | _ -> () 10 | 11 | assert false 12 | 0 13 | -------------------------------------------------------------------------------- /scripts/SharedObjectTest/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | PROJECT_DIR=$(dirname "$PWD/$0") 6 | 7 | ( 8 | cd "$PROJECT_DIR" 9 | set -x 10 | 11 | milone build "$PROJECT_DIR" -o libsotest.so 12 | gcc -c app.c -o app.o 13 | gcc -Wl,-R "-Wl,$PROJECT_DIR" -o app.out libsotest.so app.o 14 | ./app.out 15 | ) 16 | -------------------------------------------------------------------------------- /src/MiloneCli/MiloneCli.milone: -------------------------------------------------------------------------------- 1 | /// Entry point of the milone-lang compiler. 2 | module rec MiloneCli.Program 3 | 4 | open MiloneCli.Cli 5 | open MiloneCli.MiloneOnly 6 | open MiloneSyntax.SyntaxApi 7 | open MiloneTranslation.TranslationApi 8 | 9 | let main _ = 10 | cli (newSyntaxApi ()) (newTranslationApi ()) (miloneCliHost ()) 11 | -------------------------------------------------------------------------------- /tests/features/record_unordered/record_unordered.fs: -------------------------------------------------------------------------------- 1 | module rec record_unordered.Program 2 | 3 | // Record creation with shuffled fields. 4 | 5 | type Person = { Name: string; Age: int } 6 | 7 | let main _ = 8 | let _john: Person = { Name = "John Doe"; Age = 16 } 9 | let _jane: Person = { Age = 18; Name = "Jane Doe" } 10 | 0 11 | -------------------------------------------------------------------------------- /tests/pendings/octet_literal_bug/octet_literal_bug.fs: -------------------------------------------------------------------------------- 1 | module rec octet_literal_bug.Program 2 | 3 | // Bug. Int literals with leading zeros are octet literals in C. 4 | // Leading zeros should be stripped. 5 | 6 | // note: avoid doing "0" -> "", "0x1" -> "x1", "0e-1" -> "e-1". 7 | 8 | let main _ = 9 | // assert (042 = 42) 10 | 0 11 | -------------------------------------------------------------------------------- /tests/edges/match_parse_issue/match_parse_issue.fs: -------------------------------------------------------------------------------- 1 | module rec match_parse_issue.Program 2 | 3 | // Regression test: the parser used to run into infinite loop with the following code 4 | // (without the assertion in MiloneSyntax.SyntaxParse.parsePatApp). 5 | 6 | let main _ = 7 | match None with 8 | | None - 9 | | _ -> () 10 | 11 | 0 12 | -------------------------------------------------------------------------------- /tests/errors/ty_label_err/ty_label_err.c: -------------------------------------------------------------------------------- 1 | #error ty_label_err.ty_label_err:5:21 PARSE ERROR: Expected ')' (5:21) 2 | #error ty_label_err.ty_label_err:5:23 PARSE ERROR: Expected an expression (5:23) 3 | #error ty_label_err.ty_label_err:7:1 PARSE ERROR: Expected eof (7:1) 4 | #error ty_label_err.ty_label_err:7:1 PARSE ERROR: Expected an expression (7:1) 5 | -------------------------------------------------------------------------------- /tests/primitives/int_to_string/int_to_string.fs: -------------------------------------------------------------------------------- 1 | let main _ = 2 | assert (int 0 = 0) 3 | assert (int "42" - 42 = 0) 4 | assert (int "-1" + 1 = 0) 5 | 6 | assert (string 0 = "0") 7 | assert (string (0 - 97) = "-97") 8 | assert (string 'a' = "a") 9 | assert (string '\x00' = "") 10 | assert (string "fix" = "fix") 11 | 12 | 0 13 | -------------------------------------------------------------------------------- /tests/primitives/string_literal_raw/string_literal_raw.fs: -------------------------------------------------------------------------------- 1 | module rec string_literal_raw.Program 2 | 3 | let testEol () = 4 | let eol = 5 | """ 6 | """ 7 | 8 | assert (eol = "\n" || eol = "\r\n") 9 | 10 | let testNoEscape () = assert (""" \"" """ = " \\\"\" ") 11 | 12 | let main _ = 13 | testEol () 14 | testNoEscape () 15 | 0 16 | -------------------------------------------------------------------------------- /nursery/LibHttpServer/build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | CC=${CC:-gcc} 6 | MILONE_HOME=${MILONE_HOME:-$HOME/.milone} 7 | TARGET=$PWD/../target/LibHttpServer 8 | 9 | milone build --target-dir "$TARGET" $PWD 10 | mv -f "$TARGET/x86_64-unknown-linux-gnu-debug/LibHttpServer" "$TARGET/httpd" 11 | 12 | echo "trace: Built. '$TARGET/httpd'" >&2 13 | -------------------------------------------------------------------------------- /src/MiloneCli/MiloneCli.fs: -------------------------------------------------------------------------------- 1 | /// Entry point of the milone-lang compiler. 2 | module MiloneCli.Program 3 | 4 | open MiloneCli.Cli 5 | open MiloneCli.FSharpOnly 6 | open MiloneSyntax.SyntaxApi 7 | open MiloneTranslation.TranslationApi 8 | 9 | [] 10 | let main _ = 11 | cli (newSyntaxApi ()) (newTranslationApi ()) (dotnetCliHost ()) 12 | -------------------------------------------------------------------------------- /tests/errors/ty_synonym_cyclic_err/ty_synonym_cyclic_err.fs: -------------------------------------------------------------------------------- 1 | module rec ty_synonym_cyclic_err.Program 2 | 3 | // Cyclic type synonym is forbidden. 4 | 5 | type Hungry = unit -> Hungry 6 | 7 | type Even = int * Odd 8 | 9 | type Odd = string * Even 10 | 11 | let main _ = 12 | let hungry (f: Hungry) = f () 13 | 14 | assert false 15 | 0 16 | -------------------------------------------------------------------------------- /tests/pendings/let_with_refutable_pat/let_with_refutable_pat.c: -------------------------------------------------------------------------------- 1 | #error let_with_refutable_pat.let_with_refutable_pat:11:7 Let expressions cannot contain refutable patterns, which could fail to match for now. 2 | #error let_with_refutable_pat.let_with_refutable_pat:14:13 Let expressions cannot contain refutable patterns, which could fail to match for now. 3 | -------------------------------------------------------------------------------- /tests/primitives/native_fun_call/native_fun_call.fs: -------------------------------------------------------------------------------- 1 | module rec native_fun_call.Program 2 | 3 | // Call statically linked native function. 4 | // See also x_native_code.md in docs. 5 | 6 | let intCompare (l: int) (r: int) : int = 7 | __nativeFun ("milone_int32_compare", l, r) 8 | 9 | let main _ = 10 | assert (intCompare 5 3 = 1) 11 | 0 12 | -------------------------------------------------------------------------------- /tests/edges/ty_unbound/ty_unbound.fs: -------------------------------------------------------------------------------- 1 | module rec ty_unbound.Program 2 | 3 | // Unbound type variable should be degenerated. 4 | 5 | let assertIsEmpty xs = assert (List.isEmpty xs) 6 | 7 | let main _ = 8 | // The item type of list is unbound, so `assertIsEmpty` used here is polymorphic 9 | // after type inference. 10 | assertIsEmpty [] 11 | 0 12 | -------------------------------------------------------------------------------- /tests/errors/ty_errors/ty_errors.fs: -------------------------------------------------------------------------------- 1 | module rec ty_errors.Program 2 | 3 | let main _ = 4 | let deepUnificationError = 5 | match ((1, 2), 3) with 6 | | (1, "type error"), 3 -> () 7 | 8 | // ERROR! Index to int. 9 | // (0).[0] 10 | 11 | // ERROR! Recursive type. 12 | let rec f x = x f 13 | 14 | () // ERROR! This should be an int. 15 | -------------------------------------------------------------------------------- /tests/features/fun_rec/fun_rec.fs: -------------------------------------------------------------------------------- 1 | module rec fun_rec.Program 2 | 3 | // Function defined with `let rec` is recursive. 4 | 5 | let main _ = 6 | let source = "hello world" 7 | let len = source.Length 8 | 9 | let rec go i = 10 | if i < len then 11 | if source.[i] = 'o' then printfn "%d" i 12 | go (i + 1) 13 | 14 | go 0 15 | 0 16 | -------------------------------------------------------------------------------- /tests/primitives/bool_if_expr_complicated/bool_if_expr_complicated.fs: -------------------------------------------------------------------------------- 1 | module rec bool_if_expr_complicated.Program 2 | 3 | let main _ = 4 | if true then 5 | printfn "then" 6 | let hello = "hello" 7 | 8 | if true then 9 | 0 10 | else 11 | printfn "else: %s" hello 12 | 1 13 | else 14 | printfn "else" 15 | 1 16 | -------------------------------------------------------------------------------- /src/MiloneLspServer/run-exit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | { 6 | ./req < int) 7 | 8 | let main _ = 9 | let getF = fun () -> F(fun () -> 42) 10 | let (F f) = getF () 11 | assert (f () = 42) 12 | 0 13 | -------------------------------------------------------------------------------- /nursery/AppGtk/AppGtk.fsproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/edges/match_with_no_arms/match_with_no_arms.fs: -------------------------------------------------------------------------------- 1 | module rec match_with_no_arms.Program 2 | 3 | // Parser should report an error if match-with has no arms. 4 | // It should also recover from that error to parse following code correctly, 5 | // which improves the experiment of intellisense. 6 | 7 | let main _ = 8 | match exit 0 with 9 | 10 | let other () = () 11 | -------------------------------------------------------------------------------- /tests/errors/ty_errors/ty_errors.c: -------------------------------------------------------------------------------- 1 | #error ty_errors.ty_errors:3:1 Type mismatch: 'unit' <> 'int'. 2 | #error ty_errors.ty_errors:6:11 Type mismatch: 'int' <> 'string'. 3 | #error ty_errors.ty_errors:12:18 Arity mismatch: expected (((_) -> _) -> _, ..) -> .., but was (_) -> _. 4 | #error ty_errors.ty_errors:12:19 Recursive type occurred while unifying '?17 -> ?18' to '?22'. 5 | -------------------------------------------------------------------------------- /nursery/AppGtk/Makefile: -------------------------------------------------------------------------------- 1 | # USAGE: 2 | # make 3 | # 4 | # Prerequisites: 5 | # - gcc, milone-lang installed 6 | 7 | default: build 8 | 9 | .PHONY: build run 10 | 11 | target/app_gtk.c: $(wildcard *.fs) $(wildcard *.milone) 12 | ./build-1 13 | 14 | target/app: target/app_gtk.c app_gtk.c 15 | ./build-2 16 | 17 | build: target/app 18 | 19 | run: build 20 | target/app 21 | -------------------------------------------------------------------------------- /scripts/SharedObjectTest/SharedObjectTest.milone: -------------------------------------------------------------------------------- 1 | [] 2 | let my_gcd (x: int) (y: int) = 3 | assert (y >= 0) 4 | 5 | if y = 0 then 6 | x 7 | else 8 | my_gcd y (x % y) 9 | 10 | [] 11 | let my_multiply (x: int) (y: float) = float x * y 12 | 13 | let private staticVar = my_gcd 12 16 14 | 15 | [] 16 | let my_static_var () = staticVar 17 | -------------------------------------------------------------------------------- /tests/features/nav_var/nav_var.fs: -------------------------------------------------------------------------------- 1 | module rec nav_var.Program 2 | 3 | // Nav expressions to access variables defined in modules. 4 | 5 | open nav_var.sub 6 | 7 | let main _ = 8 | // static variable 9 | assert (sub.answer = 42) 10 | 11 | // function 12 | assert (sub.getAnswer () = 42) 13 | 14 | // variant 15 | let myAnswer = sub.Answer 42 16 | 17 | 0 18 | -------------------------------------------------------------------------------- /nursery/AppBlog/build.ninja: -------------------------------------------------------------------------------- 1 | rule milone_build 2 | command = milone build . --output $out 3 | 4 | build target/libapp.a: milone_build . | $ 5 | AppBlog.milone $ 6 | milone_manifest 7 | 8 | rule cargo_run 9 | command = cargo run 10 | 11 | build run: cargo_run | $ 12 | src/main.rs $ 13 | target/libapp.a 14 | pool = console 15 | 16 | default run 17 | -------------------------------------------------------------------------------- /tests/edges/ty_var_unified_unexpectedly/ty_var_unified_unexpectedly.fs: -------------------------------------------------------------------------------- 1 | module rec ty_var_unified_unexpectedly.Program 2 | 3 | // Explicitly named type variables such as `'T` can't unify to another type. 4 | // In F# it's allowed with warning. 5 | 6 | let f () : 'T = 7 | // this unify 'T = int but shouldn't. 8 | 1 9 | 10 | let main _ = 11 | assert (f () = 1) 12 | 0 13 | -------------------------------------------------------------------------------- /tests/errors/pat_or_var_incompatible_ty_err/pat_or_var_incompatible_ty_err.fs: -------------------------------------------------------------------------------- 1 | module rec pat_or_var_incompatible_ty_err.Program 2 | 3 | type IntOrString = 4 | | Int of int 5 | | String of string 6 | 7 | let main _ = 8 | match Int 2 with 9 | | Int x 10 | | String x -> 11 | let n: int = box x |> unbox 12 | assert (n = 2) 13 | 14 | assert false 15 | 0 16 | -------------------------------------------------------------------------------- /tests/errors/range_as_value_err/range_as_value_err.fs: -------------------------------------------------------------------------------- 1 | module rec range_as_value_err.Program 2 | 3 | // Range operators can't include step part for now. 4 | // Range operators can't be used inside of lists for now. 5 | 6 | let main _ = 7 | assert ("hello".[0 .. 2 .. 4] = "") 8 | 9 | let ok = 10 | match [0 .. 1] with 11 | | _ -> false 12 | assert ok 13 | 0 14 | -------------------------------------------------------------------------------- /tests/features/global_var_initializer/global_var_initializer.fs: -------------------------------------------------------------------------------- 1 | module rec global_var_initializer.Program 2 | 3 | // Let expression can define global variable with non-static initializer. 4 | // The initializer is executed at the start of main function. 5 | 6 | let f () = box 1 7 | 8 | let boxedValue = box 1 9 | 10 | let main _ = 11 | assert (f () |> unbox = 1) 12 | 0 13 | -------------------------------------------------------------------------------- /tests/pendings/record_private_fields/record_private_fields.fs: -------------------------------------------------------------------------------- 1 | module rec record_private_fields.Program 2 | 3 | // Visibility modifiers parse (but are unimplemented.) 4 | 5 | type Id = private { Inner: int } 6 | 7 | type AbstractStructure = 8 | private 9 | { X1: int 10 | X2: int 11 | X3: int 12 | X4: int 13 | X5: int } 14 | 15 | let main _ = 0 16 | -------------------------------------------------------------------------------- /tests/primitives/string_literal_escape/string_literal_escape.fs: -------------------------------------------------------------------------------- 1 | module rec string_literal_escape.Program 2 | 3 | let f (_: char) = () 4 | let g (_: string) = () 5 | 6 | let main _ = 7 | f '\'' 8 | f '\\' 9 | f '\x00' 10 | f '\x7f' 11 | f '\xFF' 12 | g "\"HELLO\n WORLD\"" 13 | g "\x7f" 14 | 15 | // escape invalid UTF-8 sequence 16 | g "\x80 \xc1" 17 | 0 18 | -------------------------------------------------------------------------------- /tests/examples/fizz_buzz/fizz_buzz.fs: -------------------------------------------------------------------------------- 1 | module rec fizz_buzz.Program 2 | 3 | let main _ = 4 | let rec fizzBuzz i = 5 | if i <= 15 then 6 | if i % 15 = 0 then printfn "FizzBuzz" 7 | else if i % 3 = 0 then printfn "Fizz" 8 | else if i % 5 = 0 then printfn "Buzz" 9 | else printfn "%d" i 10 | 11 | fizzBuzz (i + 1) 12 | 13 | fizzBuzz 1 14 | 0 15 | -------------------------------------------------------------------------------- /vscode_ext/install: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Build the extension from source and install it to local VSCode. 3 | 4 | set -eu 5 | 6 | # Remove the old output. 7 | test -f milone-lang.vsix && rm milone-lang.vsix 8 | 9 | # Build. 10 | npm run webpack-prod 11 | npm run vsce-package 12 | 13 | # Install to the local VSCode. 14 | ./uninstall || : 15 | code --install-extension milone-lang.vsix 16 | -------------------------------------------------------------------------------- /tests/features/nav_nested/nav_nested.fs: -------------------------------------------------------------------------------- 1 | module rec nav_nested.Program 2 | 3 | // Nav patterns and expressions can be nested. 4 | 5 | open nav_nested.sub 6 | 7 | let main _ = 8 | let text: sub.SubRecord = { Text = "Hello" } 9 | assert (text.Text.Length = 5) 10 | 11 | match sub.SubUnion.SubUnion 42 with 12 | | sub.SubUnion.SubUnion value -> assert (value = 42) 13 | 14 | 0 15 | -------------------------------------------------------------------------------- /scripts/install-hashmap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | URL='https://github.com/sheredom/hashmap.h/raw/c78ba67ab540c3ee2044094f9c0945f877b367d2/hashmap.h' 6 | 7 | if test -x src/libmilonert/hashmap.h 8 | then 9 | echo 'trace: src/libmilonert/hashmap.h is already fetched.' >&2 10 | exit 11 | fi 12 | 13 | dotnet fsi scripts/DownloadText.fsx "$URL" -o src/libmilonert/hashmap.h 14 | -------------------------------------------------------------------------------- /scripts/project-reference-example/test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # USAGE: scripts/project-reference-example/test 3 | 4 | set -eu 5 | 6 | PROJECT_DIR="$PWD/scripts/project-reference-example/App" 7 | MILONE_HOME=${MILONE_HOME:-$PWD} 8 | MILONE=${MILONE:-bin/milone-latest} 9 | 10 | MILONE_HOME=$MILONE_HOME $MILONE run "$PROJECT_DIR" | \ 11 | diff - "$PROJECT_DIR/../app.output" && \ 12 | echo OK 13 | -------------------------------------------------------------------------------- /src/MiloneCore/MiloneCore.fsproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Std/StdEnv.fs: -------------------------------------------------------------------------------- 1 | /// Functions for execution environment. 2 | module rec Std.StdEnv 3 | 4 | module B = Std.StdEnvBase 5 | 6 | /// Gets a list of command line arguments. 7 | let commandLineArgs () = 8 | let count = B.getArgCount () 9 | 10 | let rec go acc i = 11 | if i = 0 then 12 | acc 13 | else 14 | go (B.getArg (i - 1) :: acc) (i - 1) 15 | 16 | go [] count 17 | -------------------------------------------------------------------------------- /tests/features/module_inner/module_inner.fs: -------------------------------------------------------------------------------- 1 | module rec module_inner.Program 2 | 3 | // Inner module statements. 4 | 5 | module sub = module_inner.sub 6 | 7 | module rec Inner = 8 | let f x = x + 1 9 | 10 | let main _ = 11 | // Inner module in the same file. 12 | assert (Inner.f 2 = 3) 13 | 14 | // Inner module in another file. 15 | assert (sub.Inner.decrement 3 = 2) 16 | 0 17 | -------------------------------------------------------------------------------- /tests/features/module_rec_mutual_fun/module_rec_mutual_fun.fs: -------------------------------------------------------------------------------- 1 | module rec module_rec_mutual_fun.Program 2 | 3 | // Recursive modules allow to define mutually recursive functions in its body. 4 | 5 | let rec even n = n = 0 || odd (n - 1) 6 | 7 | let rec odd n = n <> 0 && even (n - 1) 8 | 9 | let main _ = 10 | assert (odd 1) 11 | assert (even 2) 12 | assert (even 3 |> not) 13 | 0 14 | -------------------------------------------------------------------------------- /tests/features/union_newtype/union_newtype.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv); 6 | 7 | int main(int argc, char **argv) { 8 | milone_start(argc, argv); 9 | int32_t inner_; 10 | inner_ = 1; 11 | if ((inner_ != 1)) milone_assert_error("union_newtype/union_newtype.milone", 8, 2); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /tests/edges/record_vs_generics/record_vs_generics.fs: -------------------------------------------------------------------------------- 1 | module rec record_vs_generics.Program 2 | 3 | // Make sure that record values can be used in generic functions. 4 | 5 | type IntWrapper = { Value: int } 6 | 7 | let constant value () = value 8 | 9 | let main _ = 10 | let f = constant ({ Value = 42 }: IntWrapper) 11 | 12 | let wrapper = f () 13 | assert (wrapper.Value = 42) 14 | 0 15 | -------------------------------------------------------------------------------- /tests/errors/record_noinfer_err/record_noinfer_err.fs: -------------------------------------------------------------------------------- 1 | module rec record_noinfer_err.Program 2 | 3 | // Without type ascription, record type cannot be inferred. 4 | 5 | type IntWrapper = { Value: int } 6 | 7 | let main _ = 8 | let _wrapper = { Value = 42 } 9 | // ^ Record expr of unknown type. 10 | 11 | // Correct: 12 | // let _wrapper: IntWrapper = { Value = 42 } 13 | 0 14 | -------------------------------------------------------------------------------- /tests/features/module_dependencies/module_dependencies_third.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int32_t module_dependencies_root_root(void); 6 | 7 | int32_t module_dependencies_third_third(void); 8 | 9 | int32_t module_dependencies_third_third(void) { 10 | int32_t call_; 11 | call_ = module_dependencies_root_root(); 12 | return call_; 13 | } 14 | -------------------------------------------------------------------------------- /tests/features/modules/modules.fs: -------------------------------------------------------------------------------- 1 | module rec modules.Program 2 | 3 | open modules.sub 4 | open modules.sub 5 | 6 | let main _ = 7 | let n = 8 | // imported variant 9 | match Int 0 with 10 | // pattern of imported variant 11 | | Int x -> x 12 | 13 | // nav pattern of imported type 14 | | Val.String _ -> 0 15 | 16 | // `sub.f` is imported 17 | let m = f n 18 | 19 | m 20 | -------------------------------------------------------------------------------- /tests/features/nav_var/nav_var_sub.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int32_t nav_var_sub_getAnswer(void); 6 | 7 | void nav_var_sub_start(void); 8 | 9 | int32_t nav_var_sub_answer; 10 | 11 | int32_t nav_var_sub_getAnswer(void) { 12 | return 42; 13 | } 14 | 15 | void nav_var_sub_start(void) { 16 | nav_var_sub_answer = 42; 17 | return; 18 | } 19 | -------------------------------------------------------------------------------- /tests/edges/module_open_shadowed/module_open_shadowed.fs: -------------------------------------------------------------------------------- 1 | module rec module_open_shadowed.Program 2 | 3 | open module_open_shadowed.sub 4 | 5 | let g () = "g is shadowed" 6 | 7 | let main _ = 8 | assert (f 40 = 42) // not shadowed 9 | 10 | assert (g () = "g is shadowed") 11 | 12 | let () = 13 | let f () = "f is locally shadowed" 14 | assert (f () = "f is locally shadowed") 15 | 16 | 0 17 | -------------------------------------------------------------------------------- /tests/features/module_dependencies/module_dependencies_second.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int32_t module_dependencies_root_root(void); 6 | 7 | int32_t module_dependencies_second_second(void); 8 | 9 | int32_t module_dependencies_second_second(void) { 10 | int32_t call_; 11 | call_ = module_dependencies_root_root(); 12 | return call_; 13 | } 14 | -------------------------------------------------------------------------------- /tests/edges/monomorphization_bug_1/monomorphization_bug_1.fs: -------------------------------------------------------------------------------- 1 | module rec monomorphization_bug_1.Program 2 | 3 | type private Box<'T> = Box of 'T 4 | 5 | let private dup (Box x) : Box<_ * _> = Box(x, x) 6 | 7 | let private bug (b: Box) : Box = dup b 8 | 9 | let main _ = 10 | let (Box (x1, x2)) = bug (Box "a") 11 | 12 | printfn "x1 = '%s'" x1 13 | printfn "x2 = '%s'" x2 14 | 0 15 | -------------------------------------------------------------------------------- /tests/features/pat_shadowing/pat_shadowing.fs: -------------------------------------------------------------------------------- 1 | module rec pat_shadowing.Program 2 | 3 | // Let expressions can define variables with the same name, i.e. shadowing is allowed. 4 | 5 | let main _ = 6 | let case1 = 7 | let x = 1 8 | let x = 0 9 | assert (x = 0) 10 | 11 | let case2 = 12 | let x = 0 13 | 14 | (let x = 1 15 | assert (x = 1)) 16 | 17 | assert (x = 0) 18 | 19 | 0 20 | -------------------------------------------------------------------------------- /nursery/LibNurseryTests/TestHelper.milone: -------------------------------------------------------------------------------- 1 | module rec LibNurseryTests.TestHelper 2 | 3 | let private doEqual (expected: string) (actual: string) : bool = 4 | if actual = expected then 5 | true 6 | else 7 | printfn "Assertion error.\nExpected: %s\nActual: %s" expected actual 8 | false 9 | 10 | let eq (debug: 'T -> string) (expected: 'T) (actual: 'T) : bool = doEqual (debug expected) (debug actual) 11 | -------------------------------------------------------------------------------- /nursery/LibTextProcess/README.md: -------------------------------------------------------------------------------- 1 | # LibTextProcess 2 | 3 | Small text processing libraries as implementation trial. 4 | 5 | *Remark (conformance)*: These libraries aren't fully conformant (compatible) to the specification of languages although they should be. 6 | 7 | - TinyIni: INI file format implementation. DOM-manipulating parser and writer. 8 | - TinyYaml: YAML-ish file format implementation. DOM-generating parser only. 9 | -------------------------------------------------------------------------------- /src/Std/StdAssoc.fs: -------------------------------------------------------------------------------- 1 | module rec Std.StdAssoc 2 | 3 | type Assoc<'K, 'T> = ('K * 'T) list 4 | 5 | module Assoc = 6 | let tryFind keyCompare (key: 'K) (assoc: Assoc<'K, 'T>) : 'T option = 7 | let rec assocFindLoop assoc = 8 | match assoc with 9 | | [] -> None 10 | | (k, v) :: _ when keyCompare k key = 0 -> Some v 11 | | _ :: assoc -> assocFindLoop assoc 12 | 13 | assocFindLoop assoc 14 | -------------------------------------------------------------------------------- /tests/primitives/tuple/tuple.fs: -------------------------------------------------------------------------------- 1 | module rec tuple.Program 2 | 3 | // Tuple creation and decomposition. 4 | 5 | let main _ = 6 | let a = 1, "snd" 7 | let x, _x = a 8 | printfn "%d" x 9 | 10 | let b = "fst", 2 11 | let y, _y = b 12 | printfn "%s" y 13 | 14 | let z, w = "z", "w" 15 | printfn "z=%s" z 16 | printfn "w=%s" w 17 | 18 | let (p, q), r = ("p", "q"), "r" 19 | printfn "p=%s" p 20 | 0 21 | -------------------------------------------------------------------------------- /nursery/LibHttpServer/dist/about/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | About 9 | 10 | 11 | 12 |

About

13 |

How about the root?

14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /scripts/install-ninja: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # See also: https://github.com/ninja-build/ninja 3 | 4 | set -eu 5 | 6 | URL='https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip' 7 | 8 | mkdir -p bin 9 | 10 | if test -x bin/ninja 11 | then 12 | echo 'trace: bin/ninja is already installed.' >&2 13 | exit 14 | fi 15 | 16 | dotnet fsi scripts/DownloadZip.fsx "$URL" -o bin 17 | chmod +x bin/ninja 18 | -------------------------------------------------------------------------------- /tests/pendings/union_private_variants/union_private_variants.fs: -------------------------------------------------------------------------------- 1 | module rec union_private_variants.Program 2 | 3 | // Visibility modifiers parse (but are unimplemented.) 4 | 5 | // Note `type ID = private ID` doesn't parse in F#. 6 | 7 | type Unknown = private | Unknown 8 | 9 | type Id = private Id of int 10 | 11 | type AbstractEvent = 12 | private 13 | | E1 of int 14 | | E2 of int 15 | 16 | let main _ = 0 17 | -------------------------------------------------------------------------------- /nursery/AppGtk/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/fsharp 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=fsharp 4 | 5 | ### fsharp ### 6 | lib/debug 7 | lib/release 8 | Debug 9 | *.suo 10 | *.user 11 | obj 12 | bin 13 | /build/ 14 | *.exe 15 | !.paket/paket.bootstrapper.exe 16 | .ionide/ 17 | 18 | # End of https://www.toptal.com/developers/gitignore/api/fsharp 19 | -------------------------------------------------------------------------------- /tests/edges/module_open_shadowed/module_open_shadowed_sub.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int32_t module_open_shadowed_sub_f(int32_t x_); 6 | 7 | int32_t module_open_shadowed_sub_g(int32_t x_1); 8 | 9 | int32_t module_open_shadowed_sub_f(int32_t x_) { 10 | return (x_ + 2); 11 | } 12 | 13 | int32_t module_open_shadowed_sub_g(int32_t x_1) { 14 | return (x_1 + 3); 15 | } 16 | -------------------------------------------------------------------------------- /vscode_ext/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "esModuleInterop": true, 5 | "lib": [ 6 | "ES2017" 7 | ], 8 | "module": "CommonJS", 9 | "outDir": "target", 10 | "preserveWatchOutput": true, 11 | "rootDir": "src", 12 | "sourceMap": true, 13 | "strict": true, 14 | "target": "ES2017" 15 | } 16 | } -------------------------------------------------------------------------------- /tests/errors/fun_ptr_of_local_error/fun_ptr_of_local_error.fs: -------------------------------------------------------------------------------- 1 | module rec fun_ptr_of_local_error.Program 2 | 3 | // Pointer to a local function is unavailable 4 | // since local functions might capture local variables. 5 | 6 | ignore ( 7 | let inExprStmt () = () 8 | &&inExprStmt 9 | ) 10 | 11 | let _ = 12 | let inVal () = () 13 | &&inVal 14 | 15 | let _f () = 16 | let inFun () = () 17 | &&inFun 18 | 19 | let main _ = 1 20 | -------------------------------------------------------------------------------- /tests/errors/pat_or_asymmetric_err/pat_or_asymmetric_err.fs: -------------------------------------------------------------------------------- 1 | module rec pat_or_asymmetric_err.Program 2 | 3 | let main _ = 4 | match [ 2; 3 ] with 5 | | x :: _ 6 | | [] -> assert (x = 2) 7 | 8 | match [ 2; 3 ] with 9 | | [] 10 | | x :: _ -> assert (x = 2) 11 | 12 | match [ 2; 3 ] with 13 | | [] -> () 14 | | x :: _ 15 | | _ :: ((x :: _) 16 | | (_ :: _ :: _)) -> assert (x = 2) 17 | 18 | assert false 19 | 0 20 | -------------------------------------------------------------------------------- /tests/examples/Competitive/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/fsharp 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=fsharp 4 | 5 | ### fsharp ### 6 | lib/debug 7 | lib/release 8 | Debug 9 | *.suo 10 | *.user 11 | obj 12 | bin 13 | /build/ 14 | *.exe 15 | !.paket/paket.bootstrapper.exe 16 | .ionide/ 17 | 18 | # End of https://www.toptal.com/developers/gitignore/api/fsharp 19 | -------------------------------------------------------------------------------- /tests/examples/Competitive/ABC140A.fs: -------------------------------------------------------------------------------- 1 | // https://atcoder.jp/contests/abc140/tasks/abc140_a 2 | module rec Competitive.ABC140A 3 | 4 | open Competitive.Scan 5 | open Std.IO 6 | open Std.Vector 7 | 8 | let private solve (n: int) = n * n * n 9 | 10 | let abc140aTest () = 11 | assert (solve 2 = 8) 12 | assert (solve 1 = 1) 13 | 14 | let abc140aMain (io: IO) = 15 | let n, io = scanInt io 16 | printfn "%d" (solve n) 17 | io 18 | -------------------------------------------------------------------------------- /tests/features/module_along_with_type/sub.fs: -------------------------------------------------------------------------------- 1 | module rec module_along_with_type.sub 2 | 3 | type Pos = Pos of int * int 4 | 5 | module rec Pos = 6 | let eol = Pos(1, 0) 7 | 8 | let add l r : Pos = 9 | let (Pos (ly, lx)) = l 10 | let (Pos (ry, rx)) = r 11 | Pos(ly + ry, lx + rx) 12 | 13 | // Extension. 14 | module rec Pos = 15 | let toString (Pos (row, column)) = 16 | string (row + 1) + ":" + string (column + 1) 17 | -------------------------------------------------------------------------------- /tests/features/pat_as/pat_as.fs: -------------------------------------------------------------------------------- 1 | module rec pat_as.Program 2 | 3 | // `as` pattern. 4 | 5 | let simpleCase () = 6 | match 1 with 7 | | 1 as x -> assert (x = 1) 8 | | _ -> assert false 9 | 10 | let shadowingCase () = 11 | let x = 1 12 | 13 | match x, 2 with 14 | | _, x as y -> 15 | let y1, y2 = y 16 | assert (x = 2 && y1 = 1 && y2 = 2) 17 | 18 | let main _ = 19 | simpleCase () 20 | shadowingCase () 21 | 0 22 | -------------------------------------------------------------------------------- /src/Std/.gitignore: -------------------------------------------------------------------------------- 1 | .fake 2 | 3 | 4 | 5 | # Created by https://www.toptal.com/developers/gitignore/api/fsharp 6 | # Edit at https://www.toptal.com/developers/gitignore?templates=fsharp 7 | 8 | ### fsharp ### 9 | lib/debug 10 | lib/release 11 | Debug 12 | *.suo 13 | *.user 14 | obj 15 | bin 16 | /build/ 17 | *.exe 18 | !.paket/paket.bootstrapper.exe 19 | .ionide/ 20 | 21 | # End of https://www.toptal.com/developers/gitignore/api/fsharp 22 | -------------------------------------------------------------------------------- /nursery/LibHttpServer/dist/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Hello 9 | 10 | 11 | 12 |

Hello

13 |

Hello, world!

14 |

See also About.

15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/JsonEncode/.gitignore: -------------------------------------------------------------------------------- 1 | .fake 2 | 3 | 4 | 5 | # Created by https://www.toptal.com/developers/gitignore/api/fsharp 6 | # Edit at https://www.toptal.com/developers/gitignore?templates=fsharp 7 | 8 | ### fsharp ### 9 | lib/debug 10 | lib/release 11 | Debug 12 | *.suo 13 | *.user 14 | obj 15 | bin 16 | /build/ 17 | *.exe 18 | !.paket/paket.bootstrapper.exe 19 | .ionide/ 20 | 21 | # End of https://www.toptal.com/developers/gitignore/api/fsharp 22 | -------------------------------------------------------------------------------- /src/MiloneCli/.gitignore: -------------------------------------------------------------------------------- 1 | .fake 2 | 3 | 4 | 5 | # Created by https://www.toptal.com/developers/gitignore/api/fsharp 6 | # Edit at https://www.toptal.com/developers/gitignore?templates=fsharp 7 | 8 | ### fsharp ### 9 | lib/debug 10 | lib/release 11 | Debug 12 | *.suo 13 | *.user 14 | obj 15 | bin 16 | /build/ 17 | *.exe 18 | !.paket/paket.bootstrapper.exe 19 | .ionide/ 20 | 21 | # End of https://www.toptal.com/developers/gitignore/api/fsharp 22 | -------------------------------------------------------------------------------- /src/MiloneCore/.gitignore: -------------------------------------------------------------------------------- 1 | .fake 2 | 3 | 4 | 5 | # Created by https://www.toptal.com/developers/gitignore/api/fsharp 6 | # Edit at https://www.toptal.com/developers/gitignore?templates=fsharp 7 | 8 | ### fsharp ### 9 | lib/debug 10 | lib/release 11 | Debug 12 | *.suo 13 | *.user 14 | obj 15 | bin 16 | /build/ 17 | *.exe 18 | !.paket/paket.bootstrapper.exe 19 | .ionide/ 20 | 21 | # End of https://www.toptal.com/developers/gitignore/api/fsharp 22 | -------------------------------------------------------------------------------- /src/MiloneLspServer/.gitignore: -------------------------------------------------------------------------------- 1 | .fake 2 | 3 | 4 | 5 | # Created by https://www.toptal.com/developers/gitignore/api/fsharp 6 | # Edit at https://www.toptal.com/developers/gitignore?templates=fsharp 7 | 8 | ### fsharp ### 9 | lib/debug 10 | lib/release 11 | Debug 12 | *.suo 13 | *.user 14 | obj 15 | bin 16 | /build/ 17 | *.exe 18 | !.paket/paket.bootstrapper.exe 19 | .ionide/ 20 | 21 | # End of https://www.toptal.com/developers/gitignore/api/fsharp 22 | -------------------------------------------------------------------------------- /src/MiloneShared/.gitignore: -------------------------------------------------------------------------------- 1 | .fake 2 | 3 | 4 | 5 | # Created by https://www.toptal.com/developers/gitignore/api/fsharp 6 | # Edit at https://www.toptal.com/developers/gitignore?templates=fsharp 7 | 8 | ### fsharp ### 9 | lib/debug 10 | lib/release 11 | Debug 12 | *.suo 13 | *.user 14 | obj 15 | bin 16 | /build/ 17 | *.exe 18 | !.paket/paket.bootstrapper.exe 19 | .ionide/ 20 | 21 | # End of https://www.toptal.com/developers/gitignore/api/fsharp 22 | -------------------------------------------------------------------------------- /src/MiloneSyntax/.gitignore: -------------------------------------------------------------------------------- 1 | .fake 2 | 3 | 4 | 5 | # Created by https://www.toptal.com/developers/gitignore/api/fsharp 6 | # Edit at https://www.toptal.com/developers/gitignore?templates=fsharp 7 | 8 | ### fsharp ### 9 | lib/debug 10 | lib/release 11 | Debug 12 | *.suo 13 | *.user 14 | obj 15 | bin 16 | /build/ 17 | *.exe 18 | !.paket/paket.bootstrapper.exe 19 | .ionide/ 20 | 21 | # End of https://www.toptal.com/developers/gitignore/api/fsharp 22 | -------------------------------------------------------------------------------- /src/MyBuildTool/.gitignore: -------------------------------------------------------------------------------- 1 | .fake 2 | 3 | 4 | 5 | # Created by https://www.toptal.com/developers/gitignore/api/fsharp 6 | # Edit at https://www.toptal.com/developers/gitignore?templates=fsharp 7 | 8 | ### fsharp ### 9 | lib/debug 10 | lib/release 11 | Debug 12 | *.suo 13 | *.user 14 | obj 15 | bin 16 | /build/ 17 | *.exe 18 | !.paket/paket.bootstrapper.exe 19 | .ionide/ 20 | 21 | # End of https://www.toptal.com/developers/gitignore/api/fsharp 22 | -------------------------------------------------------------------------------- /src/MiloneTranslation/.gitignore: -------------------------------------------------------------------------------- 1 | .fake 2 | 3 | 4 | 5 | # Created by https://www.toptal.com/developers/gitignore/api/fsharp 6 | # Edit at https://www.toptal.com/developers/gitignore?templates=fsharp 7 | 8 | ### fsharp ### 9 | lib/debug 10 | lib/release 11 | Debug 12 | *.suo 13 | *.user 14 | obj 15 | bin 16 | /build/ 17 | *.exe 18 | !.paket/paket.bootstrapper.exe 19 | .ionide/ 20 | 21 | # End of https://www.toptal.com/developers/gitignore/api/fsharp 22 | -------------------------------------------------------------------------------- /scripts/test-stdio: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | OUTPUT_FILE=output.ignored.txt 6 | EXPECT_FILE=expect.ignored.txt 7 | 8 | echo 'John' | milone run StdIoTest >$OUTPUT_FILE 9 | 10 | printf "What's your name?\nHello, John-san!\n" >$EXPECT_FILE 11 | EQUAL=$( \ 12 | if diff -q $OUTPUT_FILE $EXPECT_FILE 2>/dev/null; \ 13 | then echo 0; else echo 1; 14 | fi ) 15 | diff $OUTPUT_FILE $EXPECT_FILE 16 | rm $OUTPUT_FILE $EXPECT_FILE 17 | 18 | exit $EQUAL 19 | -------------------------------------------------------------------------------- /src/JsonEncode/JsonEncode.fsproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | --allsigs 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /tests/pendings/let_with_refutable_pat/let_with_refutable_pat.fs: -------------------------------------------------------------------------------- 1 | module rec let_with_refutable_pat.Program 2 | 3 | // Currently let expressions cannot contain refutable patterns, 4 | // which could fail to match, e.g. `Some _`. 5 | 6 | type MyUnion = 7 | | A of int 8 | | B of string 9 | 10 | let main _ = 11 | let [ first ] = [ 2; 3 ] 12 | assert (first = 2) 13 | 14 | let isA (A _) = false 15 | assert (isA (A 2)) 16 | 17 | assert false 18 | 0 19 | -------------------------------------------------------------------------------- /src/Std/StdLoopBase.fs: -------------------------------------------------------------------------------- 1 | module rec Std.StdLoopBase 2 | 3 | type private Folder<'S, 'T> = 'S -> 'T -> bool * 'S 4 | type private Loop<'S, 'T> = Folder<'S, Folder<'S, 'T>> 5 | 6 | let shareLoop (xs: Loop) : Loop<'S, 'T> = 7 | fun (state: 'S) folder -> 8 | let ok, state = 9 | xs (box (state: 'S)) (fun state (item: 'T) -> 10 | let ok, state = folder (unbox state: 'S) item 11 | ok, box (state: 'S)) 12 | 13 | ok, (unbox state: 'S) 14 | -------------------------------------------------------------------------------- /tests/examples/MatchChecker/MatchChecker.output: -------------------------------------------------------------------------------- 1 | unit with (): OK 2 | int with literal pats: OK 3 | int with _: OK 4 | int with 1|_: OK 5 | int * unit with _, (): OK 6 | int * int with 1, _ | _, 1: OK 7 | int list with []: OK 8 | int list with _::_: OK 9 | int list with [] | _::_: OK 10 | int list with [] | [_] | _::_::_: OK 11 | int list list with [] | [[]] | [_::_] | _::_::_: OK 12 | int list * int list with [], [] | [], _::_ | _::_, [] | _::_, _::_: OK 13 | $? = 0 14 | -------------------------------------------------------------------------------- /tests/features/module_synonym/module_synonym.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int32_t module_synonym_sub_inc(int32_t); 6 | 7 | int main(int argc, char **argv); 8 | 9 | int main(int argc, char **argv) { 10 | milone_start(argc, argv); 11 | int32_t call_; 12 | call_ = module_synonym_sub_inc(2); 13 | if ((call_ != 3)) milone_assert_error("module_synonym/module_synonym.milone", 7, 2); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /nursery/CmdCat/.gitignore: -------------------------------------------------------------------------------- 1 | cat 2 | *.generated.* 3 | 4 | 5 | 6 | # Created by https://www.toptal.com/developers/gitignore/api/fsharp 7 | # Edit at https://www.toptal.com/developers/gitignore?templates=fsharp 8 | 9 | ### fsharp ### 10 | lib/debug 11 | lib/release 12 | Debug 13 | *.suo 14 | *.user 15 | obj 16 | bin 17 | /build/ 18 | *.exe 19 | !.paket/paket.bootstrapper.exe 20 | .ionide/ 21 | 22 | # End of https://www.toptal.com/developers/gitignore/api/fsharp 23 | 24 | .fake 25 | -------------------------------------------------------------------------------- /tests/errors/fun_ptr_of_local_error/fun_ptr_of_local_error.c: -------------------------------------------------------------------------------- 1 | #error fun_ptr_of_local_error.fun_ptr_of_local_error:8:3 Pointer to a local function is unavailable since it might capture local variables. 2 | #error fun_ptr_of_local_error.fun_ptr_of_local_error:13:3 Pointer to a local function is unavailable since it might capture local variables. 3 | #error fun_ptr_of_local_error.fun_ptr_of_local_error:17:3 Pointer to a local function is unavailable since it might capture local variables. 4 | -------------------------------------------------------------------------------- /tests/pendings/fun_forward_reference_inference_bug/fun_forward_reference_inference_bug.fs: -------------------------------------------------------------------------------- 1 | module rec fun_forward_reference_inference_bug.Program 2 | 3 | // Function inference works incorrectly. 4 | 5 | // Call function defined later. type of value is not determined here. 6 | let fun1 value = fun2 value 7 | 8 | let g () = fun1 "" 9 | 10 | let fun2 (value: int) = value + 1 11 | 12 | let main _ = 13 | let n = fun1 2 14 | assert (n = 3) 15 | 16 | let x = g () 17 | 0 18 | -------------------------------------------------------------------------------- /tests/primitives/string_length/string_length.fs: -------------------------------------------------------------------------------- 1 | module rec string_length.Program 2 | 3 | // string has `Length` property. 4 | 5 | let main _ = 6 | let hello = "hello" 7 | let world = "world" 8 | 9 | assert (hello.Length = 5) 10 | 11 | let message = hello + world 12 | assert (message.Length = 10) 13 | 14 | assert (hello.Length = 5) 15 | 16 | assert ("\x00\x01\x02\x03\x04".Length = 5) 17 | 18 | // unicode character length 19 | assert ("あ".Length = 3) 20 | 0 21 | -------------------------------------------------------------------------------- /tests/edges/match_nested_nonbinding/match_nested_nonbinding.fs: -------------------------------------------------------------------------------- 1 | module rec match_nested_nonbinding.Program 2 | 3 | // Invalid code was generated in the case 4 | // for nested, non-binding matching on union. 5 | 6 | type MyBool = 7 | | MyFalse 8 | | MyTrue 9 | 10 | type MyOption = 11 | | MySome of MyBool 12 | | MyNone 13 | 14 | let main _ = 15 | match MySome MyTrue with 16 | | MySome MyTrue -> () 17 | | MySome _ -> assert false 18 | | MyNone -> assert false 19 | 20 | 0 21 | -------------------------------------------------------------------------------- /tests/pendings/module_forward_reference_bug/module_forward_reference_bug.fs: -------------------------------------------------------------------------------- 1 | module rec module_forward_reference_bug.Program 2 | 3 | // bug: module contents can't be forward reference. 4 | 5 | module rec Early = 6 | let f () = 2 7 | // Here g in Late is considered undefined. 8 | // (The name 'g' here should denote to some value; but not found.) 9 | // let f () = Late.g () 10 | 11 | module rec Late = 12 | let g () = 2 13 | 14 | let main _ = 15 | assert (Early.f () = 2) 16 | 0 17 | -------------------------------------------------------------------------------- /tests/examples/Competitive/Competitive.fs: -------------------------------------------------------------------------------- 1 | module rec Competitive.Program 2 | 3 | open Std.IO 4 | open Std.StdError 5 | open Competitive.Scan 6 | open Competitive.SegTree 7 | open Competitive.ABC140A 8 | open Competitive.ABC140B 9 | open Competitive.ABC140E 10 | 11 | [] 12 | let main _ = 13 | segTreeTest () 14 | abc140aTest () 15 | abc140bTest () 16 | abc140eTest () 17 | 18 | // Comment in the next line to try with stdio. 19 | // IO.exec abc140eMain |> never 20 | 0 21 | -------------------------------------------------------------------------------- /src/MiloneCore/Prelude.milone: -------------------------------------------------------------------------------- 1 | /// Provides functions imported to scope by default. 2 | module rec MiloneCore.Prelude 3 | 4 | // Argument names are to be unique (for small diff in snapshots). 5 | 6 | let ignore (_: 'A) : unit = () 7 | 8 | let id (idArg: 'T) : 'T = idArg 9 | 10 | let fst (fstArg: 'T, _: 'A) : 'T = fstArg 11 | 12 | let snd (_: 'A, sndArg: 'T) : 'T = sndArg 13 | 14 | let exit (exitCode: int) : never = 15 | __nativeStmt (" exit({0});\n", exitCode) 16 | __nativeExpr "never" 17 | -------------------------------------------------------------------------------- /src/MiloneCore/Result.fs: -------------------------------------------------------------------------------- 1 | module rec MiloneCore.Result 2 | 3 | type Result<'T, 'E> = 4 | | Error of 'E 5 | | Ok of 'T 6 | 7 | let bind binder result = 8 | match result with 9 | | Ok value -> binder value 10 | | Error e -> Error e 11 | 12 | let map mapping result = 13 | match result with 14 | | Ok value -> Ok(mapping value) 15 | | Error e -> Error e 16 | 17 | let mapError mapping result = 18 | match result with 19 | | Ok value -> Ok value 20 | | Error e -> Error(mapping e) 21 | -------------------------------------------------------------------------------- /nursery/ExDylib/hello/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [lib] 9 | # For shared object or dynamic link library. 10 | crate-type = ["cdylib"] 11 | 12 | [profile.release] 13 | # Optimize for size. 14 | opt-level = "z" 15 | 16 | # Abort on panic. 17 | panic = "abort" 18 | 19 | # Link time optimization. 20 | lto = true 21 | 22 | [dependencies] 23 | -------------------------------------------------------------------------------- /scripts/StaticLibTest/app.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // From StaticLibTest.a 4 | extern int StaticLibTest_initialize(int argc, char **argv); 5 | extern int my_gcd(int x, int y); 6 | extern double my_multiply(int x, double y); 7 | 8 | int main(int argc, char **argv) { 9 | StaticLibTest_initialize(argc, argv); 10 | 11 | printf("main\n"); 12 | printf("gcd 12 16 = 4? %d\n", my_gcd(12, 16)); 13 | printf("multiply 7 3.14 = 21.98? %lf\n", my_multiply(7, 3.14)); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /tests/features/fun_partial_app/fun_partial_app.fs: -------------------------------------------------------------------------------- 1 | module rec fun_partial_app.Program 2 | 3 | // Partial application is allowed. 4 | 5 | let twice f (x: int) : int = f (f x) 6 | 7 | let dec (y: int) x = x - y 8 | 9 | let add4 (x1: int) x2 x3 x4 = x1 + x2 + x3 + x4 10 | 11 | let main _ = 12 | let dec3 = dec 3 13 | assert (twice dec3 8 = 2) 14 | 15 | let add2 = add4 2 3 16 | assert (add2 5 7 = 2 + 3 + 5 + 7) 17 | 18 | let f = add4 19 | assert (f 1 2 3 4 = 1 + 2 + 3 + 4) 20 | 21 | 0 22 | -------------------------------------------------------------------------------- /tests/primitives/native_cast/native_cast.fs: -------------------------------------------------------------------------------- 1 | module rec native_cast.Program 2 | 3 | // Unsafe pointer casting. 4 | // See also x_native_code.md in docs. 5 | 6 | open Std.Ptr 7 | 8 | let main _ = 9 | let mutNull: voidptr = Ptr.nullPtr 10 | let constNull: VoidInPtr = __nativeCast mutNull 11 | let constIntPtr: InPtr = __nativeCast constNull 12 | let intPtr: nativeptr = __nativeCast constIntPtr 13 | 14 | let address: nativeint = __nativeCast intPtr 15 | assert (address = 0n) 16 | 0 17 | -------------------------------------------------------------------------------- /tests/features/record_with/record_with.fs: -------------------------------------------------------------------------------- 1 | module rec record_with.Program 2 | 3 | // Record update syntax. 4 | 5 | type Person = { Name: string; Age: int } 6 | 7 | let main _ = 8 | let john: Person = { Name = "John Doe"; Age = 16 } 9 | let jane: Person = { john with Name = "Jane Doe" } 10 | 11 | assert (john.Name = "John Doe") 12 | assert (jane.Name = "Jane Doe") 13 | assert (jane.Age = 16) 14 | 15 | let john: Person = { john with Age = john.Age + 1 } 16 | assert (john.Age = 17) 17 | 0 18 | -------------------------------------------------------------------------------- /tests/primitives/bool_if_expr/bool_if_expr.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv); 6 | 7 | int main(int argc, char **argv) { 8 | milone_start(argc, argv); 9 | int32_t if_; 10 | if (true) { 11 | goto then_2; 12 | } else { 13 | goto else_3; 14 | } 15 | then_2:; 16 | if_ = 0; 17 | goto if_next_1; 18 | else_3:; 19 | if_ = 1; 20 | goto if_next_1; 21 | if_next_1:; 22 | return if_; 23 | } 24 | -------------------------------------------------------------------------------- /nursery/LibFileSystemTests/LibFileSystemTests.milone: -------------------------------------------------------------------------------- 1 | module rec LibFileSystemTests.Program 2 | 3 | module Path = LibSpan.Path 4 | module File = LibFileSystem.File 5 | 6 | let private failwith (msg: string) = 7 | printfn "error: %s" msg 8 | exit 1 9 | 10 | let main _ = 11 | let file = 12 | match File.openRead (Path.ofString "assets/hello.txt") with 13 | | Some it -> it 14 | | None -> failwith "open" 15 | 16 | let text = file |> File.readAllText 17 | assert (text = "Hello, world!\n") 18 | 0 19 | -------------------------------------------------------------------------------- /tests/primitives/union_runtime/union_runtime.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv); 6 | 7 | int main(int argc, char **argv) { 8 | milone_start(argc, argv); 9 | if ((0 != 0)) milone_assert_error("union_runtime/union_runtime.milone", 8, 2); 10 | if ((1 != 1)) milone_assert_error("union_runtime/union_runtime.milone", 9, 2); 11 | if ((2 != 2)) milone_assert_error("union_runtime/union_runtime.milone", 10, 2); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /tests/primitives/effect_printfn/effect_printfn.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv); 6 | 7 | int main(int argc, char **argv) { 8 | milone_start(argc, argv); 9 | struct String hello_; 10 | printf("No formats\n"); 11 | hello_ = (struct String){.ptr = "Hello!", .len = 6}; 12 | printf("%s\n", string_to_c_str(hello_)); 13 | printf("Welcome to %s. Entry price is %c%d!\n", "Milone Land", '$', 1000000007); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /tests/edges/generic_right_angles/generic_right_angles.fs: -------------------------------------------------------------------------------- 1 | module rec generic_right_angles.Program 2 | 3 | // Right angle brackets '>' is distinct from shift operators. 4 | 5 | type L<'T> = 'T list 6 | 7 | let main _ = 8 | // End of type arguments. 9 | let n: L>> = [] 10 | // ^^^ 11 | 12 | let ok = 13 | match n with 14 | | [] -> true 15 | | _ -> false 16 | 17 | assert ok 18 | 19 | // Comparison. 20 | assert (3 >= 2) 21 | 22 | // Bit shift. 23 | assert (2 <<< 3 = 16) 24 | 0 25 | -------------------------------------------------------------------------------- /tests/errors/int_lit_range_err/int_lit_range_err.c: -------------------------------------------------------------------------------- 1 | #error int_lit_range_err.int_lit_range_err:7:5 This type of literal can't represent the value. 2 | #error int_lit_range_err.int_lit_range_err:8:5 This type of literal can't represent the value. 3 | #error int_lit_range_err.int_lit_range_err:12:11 This type of literal can't represent the value. 4 | #error int_lit_range_err.int_lit_range_err:13:12 This type of literal can't represent the value. 5 | #error int_lit_range_err.int_lit_range_err:16:11 This type of literal can't represent the value. 6 | -------------------------------------------------------------------------------- /tests/examples/Competitive/Competitive.fsproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /tests/edges/pat_or_deep_branches/pat_or_deep_branches.fs: -------------------------------------------------------------------------------- 1 | module rec pat_or_deep_branches.Program 2 | 3 | // Complicated OR patterns. 4 | // This test doesn't pass because MirGen emits duplicated variable definitions 5 | // and C compiler runs into compile error. 6 | 7 | let main _ = 8 | // match [ 2; 3; 5 ] with 9 | // | x :: y :: _ :: _ :: _ 10 | // | x :: ((y :: _) 11 | // | (_ :: y :: [] 12 | // | _ :: _ :: y :: [])) -> 13 | // assert (x = 2) 14 | // assert (y = 5) 15 | 16 | // | _ -> assert false 17 | 0 18 | -------------------------------------------------------------------------------- /tests/primitives/union_string/union_string.fs: -------------------------------------------------------------------------------- 1 | module rec union_string.Program 2 | 3 | type private MyUnion = 4 | | UnitLike 5 | | CarryingInt of label: int 6 | | CarryingOther of OtherUnion 7 | 8 | type private OtherUnion = private | OtherUnion 9 | 10 | let main _ = 11 | assert (string UnitLike = "MyUnion.UnitLike") 12 | assert (string (CarryingInt 1) = "MyUnion.CarryingInt(1)") 13 | 14 | // #erase_enum_like unfortunately changes semantics 15 | assert (string (CarryingOther OtherUnion) = "MyUnion.CarryingOther(0)") 16 | 0 17 | -------------------------------------------------------------------------------- /src/Std/StdIntBase.fs: -------------------------------------------------------------------------------- 1 | module rec Std.StdIntBase 2 | 3 | open System 4 | 5 | let internal tryParseInt32 (s: string) : int option = 6 | match Int32.TryParse(s) with 7 | | true, value -> Some value 8 | | false, _ -> None 9 | 10 | let internal tryParseInt64 (s: string) : int64 option = 11 | match Int64.TryParse(s) with 12 | | true, value -> Some value 13 | | false, _ -> None 14 | 15 | let internal tryParseUInt64 (s: string) : uint64 option = 16 | match UInt64.TryParse(s) with 17 | | true, value -> Some value 18 | | false, _ -> None 19 | -------------------------------------------------------------------------------- /src/Std/StdTesting.fs: -------------------------------------------------------------------------------- 1 | module rec Std.StdTesting 2 | 3 | open Std.StdError 4 | 5 | let private shouldEqualString (expected: string) (actual: string) : bool = 6 | if actual = expected then 7 | true 8 | else 9 | let message = 10 | "Assertion violation.\n actual = " 11 | + actual 12 | + "\n expected = " 13 | + expected 14 | 15 | __writeErrorLine message 16 | false 17 | 18 | let shouldEqual (debug: 'T -> string) (expected: 'T) (actual: 'T) : bool = 19 | shouldEqualString (debug expected) (debug actual) 20 | -------------------------------------------------------------------------------- /tests/features/module_dependencies/module_dependencies.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int32_t module_dependencies_second_second(void); 6 | 7 | int32_t module_dependencies_third_third(void); 8 | 9 | int main(int argc, char **argv); 10 | 11 | int main(int argc, char **argv) { 12 | milone_start(argc, argv); 13 | int32_t call_; 14 | int32_t call_1; 15 | call_ = module_dependencies_second_second(); 16 | call_1 = module_dependencies_third_third(); 17 | return (call_ + call_1); 18 | } 19 | -------------------------------------------------------------------------------- /nursery/CmdSqliteTodo/test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # env TODO 3 | 4 | set -eu 5 | 6 | rm -f todo.db 7 | 8 | { 9 | $TODO | head -1 10 | echo 11 | 12 | $TODO add 'wash cups' 13 | $TODO add 'wash dishes' 14 | $TODO add 'wipe table' 15 | $TODO list 16 | echo 17 | 18 | $TODO remove wash 19 | $TODO list 20 | echo 21 | 22 | $TODO remove nothing 23 | $TODO list 24 | echo 25 | 26 | $TODO add 'take bath' 27 | $TODO list 28 | } >test-output.txt 29 | 30 | diff -q test-output.txt test-expected.txt 31 | echo OK 32 | -------------------------------------------------------------------------------- /scripts/check_region_primitive: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # USAGE: scripts/check_region_primitive 3 | 4 | set -eu 5 | 6 | CC=${CC:-gcc} 7 | 8 | MILONE_RUNTIME="$PWD/src/libmilonert" 9 | DIR="$PWD/scripts/region_primitive_checks" 10 | OUT_C="$DIR/region_primitive_checks.c" 11 | 12 | milone -q "$DIR" >$OUT_C 13 | 14 | ( 15 | cd "$DIR" 16 | $CC -std=c11 -g \ 17 | -fsanitize=address,leak,undefined \ 18 | -I$MILONE_RUNTIME \ 19 | "$MILONE_RUNTIME/milone.c" \ 20 | "$OUT_C" 21 | ./a.out || echo '$?='$? 22 | echo OK 23 | ) 24 | -------------------------------------------------------------------------------- /src/MyBuildTool/assets/uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Uninstall milone command from your home directory. 3 | 4 | # **IMPORTANT** 5 | # The script must be sync with documentation: binary_package.md, INSTALL.md 6 | 7 | set -eu 8 | 9 | DEFAULT_MILONE_CMD=${XDG_BIN_HOME:-$HOME/.local/bin}/milone 10 | DEFAULT_MILONE_HOME=${XDG_DATA_HOME:-$HOME/.local/share}/milone 11 | 12 | MILONE_CMD=${MILONE_CMD:-$DEFAULT_MILONE_CMD} 13 | MILONE_HOME=${MILONE_HOME:-$DEFAULT_MILONE_HOME} 14 | 15 | rm "$MILONE_CMD" 16 | rm -rf "$MILONE_HOME" 17 | echo 'Uninstalled successfully!' 18 | -------------------------------------------------------------------------------- /tests/features/record_with_nested/record_with_nested.fs: -------------------------------------------------------------------------------- 1 | module rec record_with_nested.Program 2 | 3 | // Nested record. 4 | 5 | type Date = { Year: int; Month: int; Date: int } 6 | 7 | type Person = 8 | { Name: string 9 | Age: int 10 | Birthday: Date } 11 | 12 | let newPerson () : Person = 13 | { Name = "Jane Doe" 14 | Age = 16 15 | Birthday = { Year = 2007; Month = 8; Date = 31 } } 16 | 17 | let main _ = 18 | let john = { newPerson () with Name = "John Doe" } 19 | 20 | let name = john.Name 21 | assert (name.Length = 8) 22 | 0 23 | -------------------------------------------------------------------------------- /tests/features/union_newtype_rec/union_newtype_rec.fs: -------------------------------------------------------------------------------- 1 | module rec union_newtype_rec.Program 2 | 3 | /// Self-recursive newtype variant. 4 | type MyList = MyList of int * MyList option 5 | 6 | let main _ = 7 | let first = MyList(0, None) 8 | 9 | let myCons head tail = MyList(head, Some tail) 10 | 11 | let second = myCons 1 first 12 | 13 | match first with 14 | | MyList (0, None) -> () 15 | | _ -> assert false 16 | 17 | match second with 18 | | MyList (_, Some (MyList (value, _))) -> assert (value = 0) 19 | | _ -> assert false 20 | 21 | 0 22 | -------------------------------------------------------------------------------- /tests/features/union_rec_direct/union_rec_direct.fs: -------------------------------------------------------------------------------- 1 | module rec union_rec_direct.Program 2 | 3 | /// Example of directly recursive discriminated union type. 4 | /// Without indirection, this type has infinite size. 5 | type Expr = 6 | | Int of int 7 | | Add of Expr * Expr 8 | 9 | let main _ = 10 | let rec eval expr = 11 | match expr with 12 | | Expr.Int value -> value 13 | | Expr.Add (l, r) -> eval l + eval r 14 | 15 | let expr = 16 | Expr.Add(Expr.Int 11, Expr.Add(Expr.Int 22, Expr.Int 9)) 17 | 18 | assert (eval expr = 42) 19 | 0 20 | -------------------------------------------------------------------------------- /src/Std/StdInt.fs: -------------------------------------------------------------------------------- 1 | module rec Std.StdInt 2 | 3 | module B = Std.StdIntBase 4 | 5 | [] 6 | let MinValue = 0x80000000 7 | 8 | [] 9 | let MaxValue = 0x7fffffff 10 | 11 | let min (l: int) (r: int) : int = if l < r then l else r 12 | 13 | let max (l: int) (r: int) : int = if l < r then r else l 14 | 15 | let tryParse (s: string) : int option = B.tryParseInt32 s 16 | 17 | /// experimental 18 | module Ext = 19 | let tryParseInt64 (s: string) : int64 option = B.tryParseInt64 s 20 | let tryParseUInt64 (s: string) : uint64 option = B.tryParseUInt64 s 21 | -------------------------------------------------------------------------------- /tests/edges/union_generic_newtype_issue/union_generic_newtype_issue.fs: -------------------------------------------------------------------------------- 1 | module rec union_generic_newtype_issue.Program 2 | 3 | // Repro. There was an issue that when type argument of generic union is a newtype 4 | // it was not unwrapped and generated code was inconsistent. 5 | 6 | type private MyOption<'T> = 7 | | MyNone 8 | | MySome of 'T 9 | 10 | type private Newtype = Newtype of int * int 11 | 12 | let private f () = MySome(Newtype(1, 0)) 13 | 14 | let main _ = 15 | match f () with 16 | | MySome _ -> () 17 | | MyNone _ -> assert false 18 | 19 | 0 20 | -------------------------------------------------------------------------------- /tests/primitives/effect_assert/effect_assert.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv); 6 | 7 | int main(int argc, char **argv) { 8 | milone_start(argc, argv); 9 | if (false) milone_assert_error("effect_assert/effect_assert.milone", 3, 2); 10 | printf("pass\n"); 11 | printf("Notice: test \'effect_assert\' intentionally prints an assertion error:\n"); 12 | if (true) milone_assert_error("effect_assert/effect_assert.milone", 7, 2); 13 | printf("not pass\n"); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | 3 | *.milone linguist-language=fsharp 4 | *.c linguist-detectable=false 5 | 6 | *.ps1 text eol=crlf 7 | *.sh text eol=lf 8 | 9 | # 10 | boot/MiloneLang/Records.fs linguist-generated 11 | boot/scripts/**/*.c linguist-generated 12 | boot/tests/**/*.c linguist-generated 13 | MiloneLang/Records.fs linguist-generated 14 | scripts/**/*.c linguist-generated 15 | tests/**/*.c linguist-generated 16 | -------------------------------------------------------------------------------- /tests/errors/pat_or_asymmetric_err/pat_or_asymmetric_err.c: -------------------------------------------------------------------------------- 1 | #error pat_or_asymmetric_err.pat_or_asymmetric_err:6:3 OR pattern including some bindings is unimplemented. 2 | #error pat_or_asymmetric_err.pat_or_asymmetric_err:6:3 OR pattern binds different set of variables 3 | #error pat_or_asymmetric_err.pat_or_asymmetric_err:10:3 OR pattern binds different set of variables 4 | #error pat_or_asymmetric_err.pat_or_asymmetric_err:15:3 OR pattern including some bindings is unimplemented. 5 | #error pat_or_asymmetric_err.pat_or_asymmetric_err:15:3 OR pattern binds different set of variables 6 | -------------------------------------------------------------------------------- /tests/primitives/option_equal/option_equal.fs: -------------------------------------------------------------------------------- 1 | module rec option_equal.Program 2 | 3 | // Option type supports structural equality (=). 4 | 5 | let private testIntOption () = 6 | let some = Some 2 7 | assert (some = Some 2) 8 | assert (some <> Some 3) 9 | assert (some <> None) 10 | 11 | let none: int option = None 12 | assert (none = None) 13 | assert (none <> some) 14 | 15 | let private testPair () = 16 | assert (Some(2, "a") = Some(2, "a")) 17 | assert (Some(2, "a") <> Some(2, "A")) 18 | 19 | let main _ = 20 | testIntOption () 21 | testPair () 22 | 0 23 | -------------------------------------------------------------------------------- /tests/features/fun_pipeline_operator/fun_pipeline_operator.fs: -------------------------------------------------------------------------------- 1 | module rec fun_pipeline_operator.Program 2 | 3 | let inc (x: int) = x + 1 4 | let twice (x: int) = x * x 5 | let sub (x: int) y = x - y 6 | let between l r (x: int) = l <= x && x < r 7 | 8 | let main _ = 9 | let n = 1 |> inc |> twice |> twice 10 | assert (n = 16) 11 | 12 | assert ((100 |> sub) 98 |> (between 2 3)) 13 | 14 | // The fixity of `|>` is between `=` and `::`. 15 | let len (xs: int list) = 16 | match xs with 17 | | [] -> 0 18 | | _ -> 1 19 | 20 | assert (len [ 1 ] <> 0) 21 | 22 | 0 23 | -------------------------------------------------------------------------------- /nursery/install-sqlite3: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Download and compile sqlite3. 3 | 4 | set -eu 5 | 6 | CC=${CC:-gcc} 7 | 8 | mkdir -p vendor 9 | 10 | if test -f vendor/sqlite3/sqlite3.o 11 | then 12 | echo 'warn: sqlite3 already exists. Remove vendor/sqlite3 to force redo or touch sqlite3.o to dismiss this warning.' 13 | exit 14 | fi 15 | 16 | ( 17 | cd vendor 18 | busybox wget 'https://sqlite.org/2021/sqlite-amalgamation-3340100.zip' -O - | busybox unzip - 19 | mv 'sqlite-amalgamation-3340100' sqlite3 20 | 21 | cd sqlite3 22 | $CC -O2 -c sqlite3.c -o sqlite3.o 23 | ) 24 | -------------------------------------------------------------------------------- /src/MiloneCore/README.md: -------------------------------------------------------------------------------- 1 | # MiloneCore 2 | 3 | **MiloneCore** is one of standard library of milone-lang 4 | for modules that are included in "prelude" of F# such as `List`, 5 | which you can use without writing `open` statements. 6 | 7 | This is a subset of such F# libraries. 8 | Provided functions should have compatible behavior with F#. 9 | Some functions are unimplemented yet. 10 | 11 | ## About partial functions 12 | 13 | Partial functions, which could throw exceptions on error such as `List.head`, 14 | are unavailable because milone-lang doesn't support exceptions that you can catch. 15 | -------------------------------------------------------------------------------- /tests/errors/pat_variant_fun_without_payload_err/pat_variant_fun_without_payload_err.fs: -------------------------------------------------------------------------------- 1 | module rec pat_variant_fun_without_payload_err.Program 2 | 3 | // Variant that has payload must be occur as pattern with payload pattern. 4 | 5 | type IntWrapper = IntWrapper of int 6 | 7 | let someString (value: string) = Some value 8 | 9 | let wrapInt (value: int) = IntWrapper value 10 | 11 | let main _ = 12 | match someString with 13 | | Some -> () 14 | | _ -> assert false 15 | 16 | match wrapInt with 17 | | IntWrapper -> () 18 | | _ -> assert false 19 | 20 | assert false 21 | 0 22 | -------------------------------------------------------------------------------- /scripts/SharedObjectTest/app.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // From libsotest.so 4 | extern int SharedObjectTest_initialize(int argc, char **argv); 5 | extern int my_gcd(int x, int y); 6 | extern double my_multiply(int x, double y); 7 | extern int my_static_var(void); 8 | 9 | int main(int argc, char **argv) { 10 | SharedObjectTest_initialize(argc, argv); 11 | 12 | printf("main\n"); 13 | printf("gcd 12 16 = 4? %d\n", my_gcd(12, 16)); 14 | printf("multiply 7 3.14 = 21.98? %lf\n", my_multiply(7, 3.14)); 15 | printf("staticVar = 4? %d\n", my_static_var()); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /scripts/clean: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Delete build caches and outputs. 3 | # 4 | # USAGE: scripts/clean 5 | 6 | set -eu 7 | 8 | rm -f build.ninja 9 | 10 | find -type d \ 11 | -name target \ 12 | -prune \ 13 | -exec rm -rf -- {} \; 14 | 15 | find -type f \ 16 | -name '*.generated.*' \ 17 | -exec rm -f {} \; 18 | 19 | find -type d \ 20 | -and \( \ 21 | -path '*/bin/Debug' \ 22 | -or -path '*/bin/Release' \ 23 | -or -path '*/obj/Debug' \ 24 | -or -path '*/obj/Release' \) \ 25 | -prune \ 26 | -exec dirname {} \; \ 27 | | uniq \ 28 | | xargs rm -rf -- 29 | -------------------------------------------------------------------------------- /nursery/LibPoda/ExCsv.milone: -------------------------------------------------------------------------------- 1 | // Example: Adapt CSV-parser and generater written in C to milone-lang. 2 | 3 | open Std.Block 4 | open Std.Ptr 5 | open Std.StdError 6 | open LibPoda.Poda 7 | open LibPoda.PodaExt 8 | 9 | let private toCStr (s: string) : InPtr = __nativeFun ("string_to_c_str", s) 10 | 11 | module private Csv = 12 | let parse (text: string) : Poda = 13 | __nativeFun ("parse_csv_for_milone", toCStr text) 14 | 15 | let () = 16 | let text = 17 | """id,name 18 | 1,Alice 19 | 2,Bob 20 | 3,Charlotte 21 | """ 22 | 23 | let data = Csv.parse text 24 | printfn "%s" (Poda.debug data) 25 | -------------------------------------------------------------------------------- /tests/errors/int_lit_range_err/int_lit_range_err.fs: -------------------------------------------------------------------------------- 1 | module rec int_lit_range_err.Program 2 | 3 | // Too large or too small int literal is error. 4 | 5 | let invalidLitInPat (value: int) = 6 | match value with 7 | | 2147483648 -> () 8 | | -2147483649 -> () 9 | | _ -> assert false 10 | 11 | let invalidLitInExpr (value: int) = 12 | assert (2147483648 <> value) 13 | assert (-2147483649 <> value) 14 | 15 | let invalidHexLit (value: int) = 16 | assert (0x910001000 <> value) 17 | 18 | let main _ = 19 | invalidLitInPat 0 20 | invalidLitInExpr 0 21 | invalidHexLit 0 22 | assert false 23 | 1 24 | -------------------------------------------------------------------------------- /nursery/LibNursery/Runtime.milone: -------------------------------------------------------------------------------- 1 | module rec LibNursery.Runtime 2 | 3 | open Std.Ptr 4 | 5 | let memAlloc (len: int) (size: int) : voidptr = 6 | __nativeFun ("milone_region_alloc", len, size) 7 | 8 | let memcpy (dest: voidptr) (src: VoidInPtr) (size: int) : voidptr = 9 | __nativeFun ("memcpy", dest, src, unativeint size) 10 | 11 | /// Prints a message to stderr and returns false. 12 | /// 13 | /// Meant to be used like this: 14 | /// `assert (pred || violate "reason")` 15 | let violate (msg: string) : bool = 16 | __nativeStmt ("""fprintf(stderr, "error: %s\n", string_to_c_str({0}));""", msg) 17 | false 18 | -------------------------------------------------------------------------------- /scripts/LinkTest/LinkTest.milone: -------------------------------------------------------------------------------- 1 | module rec LinkTest.Program 2 | 3 | let private printlnInt (n: int) : unit = __nativeFun ("println_int", n) 4 | let private mySqrt (x: float) : float = __nativeFun ("sqrt", x) 5 | 6 | let main _ = 7 | printlnInt 42 8 | printfn "sqrt 5 = %s" (mySqrt 5.0 |> string) 9 | 10 | // trigger address sanitizer (stack-buffer-overflow) 11 | // __nativeStmt "int x1 = 1; int x2 = 2; int *p = &x1; p[1] = 99;" 12 | 13 | // trigger undefined sanitizer (negation of -2147483648 cannot be represented in type 'int') 14 | // printfn "%d" (0x80000000 |> fun (x: int) -> -x) 15 | 16 | 0 17 | -------------------------------------------------------------------------------- /src/JsonEncode/JsonEncode.fs: -------------------------------------------------------------------------------- 1 | // Encodes an input as JSON string. 2 | // Reads from standard input, writes to standard output. 3 | // 4 | // USAGE: 5 | // ... | dotnet fsi src/JsonEncode.fsx 6 | // 7 | // EXAMPLES: 8 | // $ printf 'Hello,\nworld!\n' | dotnet fsi src/JsonEncode.fsx 9 | // "Hello,\nworld\n" 10 | 11 | module JsonEncode.Program 12 | 13 | open System 14 | 15 | [] 16 | let main _ = 17 | let text = stdin.ReadToEnd() 18 | 19 | let json = Utf8Json.JsonSerializer.Serialize(text) 20 | 21 | use stdOut = Console.OpenStandardOutput() 22 | stdOut.Write(json, 0, json.Length) 23 | 0 24 | -------------------------------------------------------------------------------- /tests/edges/unary_op_syntax/unary_op_syntax.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | bool unary_op_syntax_unary_op_syntax_f(int32_t n_, int32_t m_); 6 | 7 | int main(int argc, char **argv); 8 | 9 | bool unary_op_syntax_unary_op_syntax_f(int32_t n_, int32_t m_) { 10 | return (n_ == (m_ + 1)); 11 | } 12 | 13 | int main(int argc, char **argv) { 14 | milone_start(argc, argv); 15 | bool call_; 16 | call_ = unary_op_syntax_unary_op_syntax_f(-1, -2); 17 | if ((!(call_))) milone_assert_error("unary_op_syntax/unary_op_syntax.milone", 5, 2); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /tests/primitives/effect_file_io/effect_file_io.fs: -------------------------------------------------------------------------------- 1 | module rec effect_file_io.Program 2 | 3 | let fileReadAllText (fileName: string) : string = 4 | __nativeFun ("file_read_all_text", fileName) 5 | 6 | let fileWriteAllText (fileName: string) (content: string) : unit = 7 | __nativeFun ("file_write_all_text", fileName, content) 8 | 9 | let main _ = 10 | let content = 11 | fileReadAllText "tests/primitives/effect_file_io/input.txt" 12 | 13 | assert (content = "hello\n") 14 | 15 | let content = content + "world\n" 16 | fileWriteAllText "tests/primitives/effect_file_io/output.txt" content 17 | 18 | 0 19 | -------------------------------------------------------------------------------- /nursery/BenchLoopIter/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | TARGET="$PWD/../target/BenchLoopIter" 6 | APP="$TARGET/x86_64-unknown-linux-gnu-release/BenchLoopIter" 7 | 8 | hyperfine --version 9 | 10 | milone build --release --target-dir "$TARGET" "$PWD" 11 | 12 | ( 13 | # 1e7, 1e8 14 | 15 | PATH="$(dirname $APP):$PATH" \ 16 | hyperfine -i --warmup 1 \ 17 | --export-markdown "$TARGET/bench.md" --show-output \ 18 | -L 'kind' 'native,loop,iter' \ 19 | -L 'count' '10000000,100000000' \ 20 | -- "BenchLoopIter {kind} {count}" 21 | ) 22 | 23 | echo "Exported to $TARGET/bench.md" 24 | -------------------------------------------------------------------------------- /tests/edges/resolved_issues/variant_wrapper_auto_box.fs: -------------------------------------------------------------------------------- 1 | // Fixed. 2 | 3 | // When value-carrying variant is used as a function, 4 | // due to interaction with auto boxing, 5 | // invalid code was generated. 6 | 7 | type private BoxedVariant = A of BoxedVariant option 8 | 9 | let private feedNil (f: BoxedVariant option -> BoxedVariant) : BoxedVariant = f None 10 | 11 | let private test () = 12 | // Variant is here converted to a function object. 13 | // Auto boxing phase doesn't insert `box` for the object unfortunately. 14 | // Generated code is illegal. 15 | let result = feedNil A 16 | () 17 | 18 | test () 19 | -------------------------------------------------------------------------------- /src/MiloneTranslation/TranslationApiTypes.fs: -------------------------------------------------------------------------------- 1 | module rec MiloneTranslation.TranslationApiTypes 2 | 3 | open MiloneShared.SharedTypes 4 | open MiloneTranslation.HirTypes 5 | 6 | /// Name of entrypoint function, typically `main` 7 | type EntrypointName = string 8 | 9 | /// Name of symbol to be exported 10 | type ExportName = string 11 | 12 | type WriteLogFun = string -> unit 13 | type CCode = string 14 | 15 | [] 16 | type TranslationApi = 17 | { CodeGenHir: EntrypointName -> DocIdToModulePath -> WriteLogFun -> HProgram * HirCtx -> (DocId * CCode) list * ExportName list } 18 | -------------------------------------------------------------------------------- /src/MyBuildTool/MyBuildTool.fsproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | --allsigs 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /tests/features/fun_with_fun_arg/fun_with_fun_arg.fs: -------------------------------------------------------------------------------- 1 | module rec fun_with_fun_arg.Program 2 | 3 | // Functions can take functions as arguments. 4 | 5 | let bindInt (f: int -> string -> unit) (x: int) = f x 6 | 7 | // Not capturing. 8 | let printInt value label = printfn "%d: %s" value label 9 | 10 | let main _ = 11 | let print42 = bindInt printInt 42 12 | print42 "The answer" 13 | 14 | let d = "'" 15 | // Capturing `d`. 16 | let rec der (n: int) (f: string) = 17 | if n = 0 then 18 | printfn "%s" f 19 | else 20 | der (n - 1) (f + d) 21 | 22 | let der2 = bindInt der 2 23 | der2 "f" 24 | 25 | 0 26 | -------------------------------------------------------------------------------- /tests/pendings/fun_arity_over/fun_arity_over.fs: -------------------------------------------------------------------------------- 1 | let main _ = 2 | let f: int -> int -> int = 3 | // `add` is 1-arity. 4 | let add (x: int) : int -> int = 5 | let inc () (y: int) : int = x + y 6 | // Return a function object with arity 1. 7 | inc () 8 | 9 | // ISSUE: `f`'s result should be a function object with arity 2, 10 | // however, the actual result is 1-arity for now. 11 | add 12 | 13 | // We need convert `add` to something like this: 14 | // let f x y = 15 | // let inc = add x 16 | // inc y 17 | // f 18 | 19 | // exit 0 20 | 21 | assert (f 2 3 = 5) 22 | 23 | 0 24 | -------------------------------------------------------------------------------- /nursery/LibSpan/SpanMut.milone: -------------------------------------------------------------------------------- 1 | module rec LibSpan.SpanMut 2 | 3 | open LibSpan.Span 4 | 5 | type SpanMut = __nativeType<``struct SpanMut``> 6 | 7 | let ofRawParts (ptr: voidptr) (len: unativeint) : SpanMut = 8 | __nativeStmt ("struct SpanMut span = {{0}, {1}};", ptr, len) 9 | __nativeExpr "span" 10 | 11 | let asPtr (span: SpanMut) : voidptr = 12 | __nativeStmt ("void *ptr = {0}.ptr;", span) 13 | __nativeExpr "ptr" 14 | 15 | let length (span: SpanMut) : unativeint = 16 | __nativeStmt ("size_t len = {0}.len;", span) 17 | __nativeExpr "len" 18 | 19 | let asConst (span: SpanMut) : Span = __nativeFun ("span_mut_as_const", span) 20 | -------------------------------------------------------------------------------- /nursery/LibTextProcess/TinyYamlTests.milone: -------------------------------------------------------------------------------- 1 | open LibTextProcess.TinyYaml 2 | 3 | module S = Std.StdString 4 | 5 | let private dump y = 6 | match y with 7 | | YamlStr s -> "'" + s + "'" 8 | 9 | | YamlTable entries -> 10 | let contents = 11 | entries 12 | |> List.map (fun (key, value) -> key + ":" + dump value) 13 | |> S.concat ", " 14 | 15 | "{" + contents + "}" 16 | 17 | let it = 18 | parseYaml 19 | """ 20 | foo: 21 | a: x 22 | 23 | # comment 24 | bar: 25 | b: 2 26 | c: 3 27 | 28 | baz: zzz 29 | """ 30 | |> dump 31 | 32 | assert (it = "{foo:{a:'x'}, bar:{b:'2', c:'3'}, baz:'zzz'}") 33 | -------------------------------------------------------------------------------- /src/MiloneDll/example: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # USAGE: src/MiloneDll/example 3 | # 4 | # This script assumes working directory is at the workspace root. 5 | 6 | set -eu 7 | 8 | echo 'trace: Building dll' >&2 9 | bin/milone-latest build src/MiloneDll -o target/MiloneDll/MiloneDll.so 10 | 11 | echo 'trace: Building example' >&2 12 | gcc -std=c17 -Wall \ 13 | -I "$PWD/src/libmilonert" \ 14 | $PWD/target/MiloneDll/milone.o \ 15 | $PWD/target/MiloneDll/milone_platform.o \ 16 | src/MiloneDll/example.c \ 17 | -ldl \ 18 | -o target/MiloneDll/example.exe 19 | 20 | echo 'trace: Running example' >&2 21 | target/MiloneDll/example.exe 22 | -------------------------------------------------------------------------------- /nursery/LibSpanTests/build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # FIXME: update 4 | 5 | set -eu 6 | 7 | CC=${CC:-gcc} 8 | MILONE_HOME=${MILONE_HOME:-$HOME/.milone} 9 | TARGET="$PWD/target" 10 | 11 | mkdir -p $TARGET 12 | 13 | { 14 | echo '#include "../LibSpan/lib_span_runtime.h"' 15 | milone compile $PWD 16 | } >$TARGET/lib_span_tests.c 17 | 18 | $CC -std=gnu11 -fsanitize=address,undefined \ 19 | -I$MILONE_HOME/src/libmilonert \ 20 | $MILONE_HOME/src/libmilonert/milone.c \ 21 | $MILONE_HOME/src/libmilonert/milone_platform.c \ 22 | ../LibSpan/lib_span_runtime.c \ 23 | $TARGET/lib_span_tests.c \ 24 | -o $TARGET/lib_span_tests 25 | -------------------------------------------------------------------------------- /tests/features/nav_ty/nav_ty.fs: -------------------------------------------------------------------------------- 1 | module rec nav_ty.Program 2 | 3 | // You can refer to types defined in another module with dot notation (nav). 4 | 5 | open nav_ty.sub 6 | 7 | // Shadow imported symbols. 8 | // let Leaf = () 9 | // let Node = () 10 | 11 | type MyNode = sub.Node 12 | 13 | let main _ = 14 | let leaf n = sub.Leaf n 15 | let node l r = sub.Node(l, r) 16 | 17 | let t = node (leaf 2) (node (leaf 3) (leaf 5)) 18 | 19 | match t with 20 | // abbreviation of union doesn't work as namespace of variants 21 | // | MyNode.Leaf _ -> ... 22 | 23 | | Node (Leaf x, _) -> assert (x = 2) 24 | | _ -> assert false 25 | 26 | 0 27 | -------------------------------------------------------------------------------- /tests/features/record/record.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | struct Point_; 6 | 7 | int main(int argc, char **argv); 8 | 9 | struct Point_ { 10 | int32_t t0; 11 | int32_t t1; 12 | }; 13 | 14 | int main(int argc, char **argv) { 15 | milone_start(argc, argv); 16 | struct Point_ point_; 17 | struct Point_ Point_; 18 | Point_ = (struct Point_){.t0 = 40, .t1 = 2}; 19 | point_ = Point_; 20 | if ((point_.t0 != 40)) milone_assert_error("record/record.milone", 9, 2); 21 | if ((point_.t1 != 2)) milone_assert_error("record/record.milone", 10, 2); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /tests/edges/fun_monomorphization_bug/fun_monomorphization_bug.fs: -------------------------------------------------------------------------------- 1 | module rec fun_monomorphization_bug.Program 2 | 3 | // Fixed. 4 | 5 | // =============================================== 6 | 7 | // During compilation, compiles crashes in unreachable code. 8 | // It seems 'T is not replaced with type argument in monomorphization. 9 | // The reason seems g has monomorphic signature and "forceGeneration" doesn't occur. 10 | 11 | let myFst (pair: 'T * 'U) : obj = 12 | let g (pair: obj) : obj = 13 | let (x, _): 'T * 'U = unbox pair 14 | box x 15 | 16 | g (box pair) 17 | 18 | let main _ = 19 | assert (unbox (myFst (2, 3)) = 2) 20 | 0 21 | -------------------------------------------------------------------------------- /tests/features/fun_lambda/fun_lambda.fs: -------------------------------------------------------------------------------- 1 | module rec fun_lambda.Program 2 | 3 | // Anonymous function expression (so-called "lambda", incorrectly) is supported. 4 | // Syntax is subtle. 5 | 6 | let layoutTest () = 7 | let apply f x = f x 8 | 9 | let a = 10 | 2 11 | |> apply (fun x -> // callee can be deeper than arguments 12 | x + 3) 13 | 14 | assert (a = 5) 15 | 16 | let main _ = 17 | let twice f x = x |> f |> f 18 | 19 | let x = 20 | 40 21 | |> twice (fun x -> 22 | let y = x + 1 23 | y) 24 | 25 | assert (x = 42) 26 | 27 | assert ((fun x y -> x / y + 0) 84 2 = 42) 28 | 29 | layoutTest () 30 | 0 31 | -------------------------------------------------------------------------------- /tests/features/pat_literals/pat_literals.fs: -------------------------------------------------------------------------------- 1 | module rec pat_literals.Program 2 | 3 | // Literal patterns. 4 | 5 | let main _ = 6 | match () with 7 | | () -> () 8 | 9 | match true with 10 | | false -> assert false 11 | | true -> () 12 | 13 | match 1 with 14 | | 0 -> assert false 15 | | 1 -> () 16 | | _ -> assert false 17 | 18 | match -2 with 19 | | 2 -> assert false 20 | | -2 -> () 21 | | _ -> assert false 22 | 23 | match 'a' with 24 | | 'A' -> assert false 25 | | 'a' -> () 26 | | _ -> assert false 27 | 28 | match "a" with 29 | | "an" -> assert false 30 | | "a" -> () 31 | | _ -> assert false 32 | 33 | 0 34 | -------------------------------------------------------------------------------- /src/Std/StdPair.fs: -------------------------------------------------------------------------------- 1 | module rec Std.StdPair 2 | 3 | module Pair = 4 | let equals (equals0: 'T -> 'T -> bool) (equals1: 'U -> 'U -> bool) (l: 'T * 'U) (r: 'T * 'U) : bool = 5 | let l0, l1 = l 6 | let r0, r1 = r 7 | equals0 l0 r0 && equals1 l1 r1 8 | 9 | let compare (compare0: 'T -> 'T -> int) (compare1: 'U -> 'U -> int) (l: 'T * 'U) (r: 'T * 'U) : int = 10 | let l0, l1 = l 11 | let r0, r1 = r 12 | 13 | let c0 = compare0 l0 r0 14 | if c0 <> 0 then c0 else compare1 l1 r1 15 | 16 | let debug (debug0: 'T -> string) (debug1: 'U -> string) (pair: 'T * 'U) : string = 17 | let x0, x1 = pair 18 | "(" + debug0 x0 + ", " + debug1 x1 + ")" 19 | -------------------------------------------------------------------------------- /tests/errors/pat_variant_fun_without_payload_err/pat_variant_fun_without_payload_err.c: -------------------------------------------------------------------------------- 1 | #error pat_variant_fun_without_payload_err.pat_variant_fun_without_payload_err:13:5 Type mismatch: 'string -> option' <> 'option'. 2 | #error pat_variant_fun_without_payload_err.pat_variant_fun_without_payload_err:13:5 Variant with payload must be used in the form of: `Variant pattern`. 3 | #error pat_variant_fun_without_payload_err.pat_variant_fun_without_payload_err:17:5 Type mismatch: 'int -> IntWrapper' <> 'IntWrapper'. 4 | #error pat_variant_fun_without_payload_err.pat_variant_fun_without_payload_err:17:5 Variant with payload must be used in the form of: `Variant pattern`. 5 | -------------------------------------------------------------------------------- /tests/features/records_c_repr/records_c_repr.fs: -------------------------------------------------------------------------------- 1 | module rec records_c_repr.Program 2 | 3 | // Repr(C) attribute on record type prevents from transforming 4 | // such as AutoBoxing. 5 | 6 | [] 7 | type Int32X4 = { N1: int; N2: int; N3: int; N4: int } 8 | 9 | let int32X4Zero: Int32X4 = { N1 = 0; N2 = 0; N3 = 0; N4 = 0 } 10 | 11 | [] 12 | type Int32X32 = 13 | { M1: Int32X4 14 | M2: Int32X4 15 | M3: Int32X4 16 | M4: Int32X4 } 17 | 18 | let int32X32Zero: Int32X32 = 19 | { M1 = int32X4Zero 20 | M2 = int32X4Zero 21 | M3 = int32X4Zero 22 | M4 = int32X4Zero } 23 | 24 | let main _ = 25 | assert (int32X32Zero.M1.N1 = 0) 26 | 0 27 | -------------------------------------------------------------------------------- /tests/features/union_newtype_rec_mutual/union_newtype_rec_mutual.fs: -------------------------------------------------------------------------------- 1 | module rec union_newtype_rec_mutual.Program 2 | 3 | // Mutually recursive newtype variants. 4 | 5 | type Odd = Odd of int * Even option 6 | type Even = Even of string * Odd option 7 | 8 | let main _ = 9 | let one = Odd(1, None) 10 | let two = Even("two", Some one) 11 | let three = Odd(3, Some two) 12 | let four = Even("four", Some three) 13 | 14 | match four with 15 | | Even (s4, Some (Odd (n3, Some (Even (s2, Some (Odd (n1, None))))))) -> 16 | assert (n1 = 1) 17 | assert (s2 = "two") 18 | assert (n3 = 3) 19 | assert (s4 = "four") 20 | 21 | | _ -> assert false 22 | 23 | 0 24 | -------------------------------------------------------------------------------- /tests/features/record_large/record_large.fs: -------------------------------------------------------------------------------- 1 | module rec record_large.Program 2 | 3 | // An example of large record type. 4 | 5 | type GitCommitOptions = 6 | { All: bool 7 | Patch: bool 8 | ReuseMessage: string option 9 | ReeditMessage: string option 10 | Fixup: string option 11 | Squash: string option 12 | ResetAuthor: bool } 13 | // and more... 14 | 15 | let defaultOptions () : GitCommitOptions = 16 | { All = false 17 | Patch = false 18 | ReuseMessage = None 19 | ReeditMessage = None 20 | Fixup = None 21 | Squash = None 22 | ResetAuthor = false } 23 | 24 | let main _ = 25 | let _options = defaultOptions () 26 | 27 | 0 28 | -------------------------------------------------------------------------------- /tests/pendings/never_id_bug/never_id_bug.fs: -------------------------------------------------------------------------------- 1 | module rec never_id_bug.Program 2 | 3 | // Generated code causes a compiler warning 4 | // when a never value is applied to the id function. 5 | 6 | // let private repro () = 7 | // match Some(exit 0: never) with 8 | // | Some n -> id n 9 | // | _ -> () 10 | 11 | // let main _ = 12 | // repro () 13 | // 0 14 | 15 | // Generated code (in MiloneCore_Prelude.c): 16 | 17 | // _Noreturn void MiloneCore_Prelude_NeverNeverFun1_id(char idArg_) { 18 | // } 19 | 20 | // Compiler warning: 21 | 22 | // MiloneCore_Prelude.c:10:1: warning: ‘noreturn’ function does return 23 | // 10 | } 24 | // | ^ 25 | 26 | let main _ = 0 27 | -------------------------------------------------------------------------------- /tests/primitives/list_pat/list_pat.fs: -------------------------------------------------------------------------------- 1 | module rec list_pat.Program 2 | 3 | // Multiline list pattern. 4 | 5 | let main _ = 6 | match [ 1; 2; 3; 4; 5; 6; 7 ] 7 | |> List.map (fun x -> Some(Some(Some(x)))) 8 | with 9 | | [ Some (Some (Some x1)) 10 | Some (Some (Some x2)) 11 | Some (Some (Some x3)) 12 | Some (Some (Some x4)) 13 | Some (Some (Some x5)) 14 | Some (Some (Some x6)) 15 | Some (Some (Some x7)) ] -> 16 | assert (x1 = 1) 17 | assert (x2 = 2) 18 | assert (x3 = 3) 19 | assert (x4 = 4) 20 | assert (x5 = 5) 21 | assert (x6 = 6) 22 | assert (x7 = 7) 23 | 24 | | _ -> assert false 25 | 26 | 0 27 | -------------------------------------------------------------------------------- /nursery/LibHttpServer/dist/main.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | margin: 0; 4 | padding: 0; 5 | height: 100%; 6 | } 7 | 8 | h1, 9 | p { 10 | margin-top: 0; 11 | margin-bottom: 0; 12 | } 13 | 14 | html { 15 | font-size: 62.5%; 16 | } 17 | 18 | body { 19 | color: #212121; 20 | 21 | display: flex; 22 | flex-flow: column nowrap; 23 | align-items: center; 24 | justify-content: center; 25 | gap: 1.6rem; 26 | } 27 | 28 | h1 { 29 | font-size: 6.4rem; 30 | } 31 | 32 | p { 33 | min-width: 30rem; 34 | padding: 2.4rem 1.6rem; 35 | 36 | background-color: #f3f3fc; 37 | border-radius: 0.8rem; 38 | 39 | font-size: 2.4rem; 40 | } 41 | -------------------------------------------------------------------------------- /src/Std/Std.milone: -------------------------------------------------------------------------------- 1 | // Test Std library. 2 | 3 | open Std.ByteVectorTests 4 | open Std.BoxTests 5 | open Std.IO 6 | open Std.FileTests 7 | open Std.PathTests 8 | open Std.StdError 9 | open Std.StdStringTests 10 | open Std.StringBufferTests 11 | open Std.VectorTests 12 | open Std.OsStringTests 13 | open Std.HashMapTests 14 | 15 | // Test is written in tests/primitives/std_block 16 | open Std.Block 17 | 18 | let main _ = 19 | IO.exec (fun (io: IO) -> 20 | testString () 21 | testVector () 22 | testByteVector () 23 | testStringBuffer () 24 | testOsString () 25 | testBox () 26 | testHashMap () 27 | testPath () 28 | testFile () 29 | io) 30 | |> never 31 | -------------------------------------------------------------------------------- /nursery/CmdJsonGet/test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # env: JSON_GET 3 | 4 | set -eu 5 | 6 | INPUT="$PWD/test-input.json" 7 | 8 | { 9 | # Examples in the help. 10 | echo '{"foo": 42}' | $JSON_GET foo 11 | echo '{"greets": {"en": "Hello"}}' | $JSON_GET greets.en 12 | echo '[null, false, true]' | $JSON_GET 1 13 | 14 | cat "$INPUT" | $JSON_GET version 15 | cat "$INPUT" | $JSON_GET entries.length 16 | cat "$INPUT" | $JSON_GET entries.0 17 | cat "$INPUT" | $JSON_GET entries.0.value 18 | cat "$INPUT" | $JSON_GET entries.1 19 | cat "$INPUT" | $JSON_GET entries.1.value 20 | } >test-output.ignored.txt 21 | 22 | diff -q test-expected.txt test-output.ignored.txt 23 | echo OK 24 | -------------------------------------------------------------------------------- /tests/examples/x_algorithm/x_algorithm.fs: -------------------------------------------------------------------------------- 1 | module rec x_algorithm.Program 2 | 3 | let minus (x: int) = 0 - x 4 | 5 | let abs (x: int) = if x >= 0 then x else minus x 6 | 7 | let rec gcd (x: int) (y: int) = if y = 0 then abs x else gcd y (x % y) 8 | 9 | let isPrime (x: int) = 10 | let rec go k = k * k > x || x % k <> 0 && go (k + 1) 11 | x >= 2 && go 2 12 | 13 | let main _ = 14 | assert (abs 0 = 0) 15 | assert (abs 1 = 1) 16 | assert (abs (minus 1) = 1) 17 | 18 | assert (gcd 1 1 = 1) 19 | assert (gcd 12 18 = 6) 20 | assert (gcd 4 (minus 6) = 2) 21 | 22 | assert (isPrime 2) 23 | assert (isPrime 3) 24 | assert (not (isPrime 4)) 25 | assert (isPrime 1000000007) 26 | 0 27 | -------------------------------------------------------------------------------- /tests/features/nav_var/nav_var.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void nav_var_sub_start(void); 6 | 7 | int32_t nav_var_sub_getAnswer(void); 8 | 9 | int main(int argc, char **argv); 10 | 11 | extern int32_t nav_var_sub_answer; 12 | 13 | int main(int argc, char **argv) { 14 | milone_start(argc, argv); 15 | int32_t myAnswer_; 16 | int32_t call_; 17 | nav_var_sub_start(); 18 | if ((nav_var_sub_answer != 42)) milone_assert_error("nav_var/nav_var.milone", 8, 2); 19 | call_ = nav_var_sub_getAnswer(); 20 | if ((call_ != 42)) milone_assert_error("nav_var/nav_var.milone", 11, 2); 21 | myAnswer_ = 42; 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /vscode_ext/Makefile: -------------------------------------------------------------------------------- 1 | default: 2 | : 'EXAMPLES:' 3 | : ' make build' 4 | : ' make install' 5 | : ' make uninstall' 6 | 7 | .PHONY: build clean default install test uninstall 8 | 9 | node_modules/.timestamp: package-lock.json 10 | npm ci 11 | mkdir -p node_modules && touch node_modules/.timestamp 12 | 13 | milone-lang.vsix: node_modules/.timestamp \ 14 | language-configuration.json \ 15 | package.json \ 16 | $(wildcard src/*.ts) \ 17 | syntaxes/milone.json 18 | npm run webpack-prod 19 | npm run vsce-package 20 | 21 | build: milone-lang.vsix 22 | 23 | install: milone-lang.vsix 24 | code --install-extension milone-lang.vsix 25 | 26 | uninstall: 27 | ./uninstall || : 28 | -------------------------------------------------------------------------------- /tests/features/ty_var/ty_var.fs: -------------------------------------------------------------------------------- 1 | module rec ty_var.Program 2 | 3 | // Type variable is available in ascription. 4 | 5 | let pair (_: 'x * 'x) = 2 6 | 7 | let useStringIndexWithoutAscription x = 8 | // This unifies type of x to string. 9 | let _ = pair (x, "") 10 | 11 | // This passes the type check without explicit x: string ascription. 12 | x.[0] 13 | 14 | let useTyVarInBody (x: 'T) = 15 | let xs: 'T list = [] 16 | x, xs 17 | 18 | let main _ = 19 | assert (pair (0, 0) = 2) 20 | assert (pair ("", "") = 2) 21 | 22 | assert (useStringIndexWithoutAscription "a" = 'a') 23 | 24 | match useTyVarInBody "b" with 25 | | _, s :: _ -> assert (s.[0] = 'b') 26 | | _ -> () 27 | 28 | 0 29 | -------------------------------------------------------------------------------- /tests/primitives/native_cast/native_cast.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv); 6 | 7 | int main(int argc, char **argv) { 8 | milone_start(argc, argv); 9 | void *mutNull_; 10 | void const *constNull_; 11 | int32_t const *constIntPtr_; 12 | int32_t *intPtr_; 13 | intptr_t address_; 14 | mutNull_ = NULL; 15 | constNull_ = ((void const *)mutNull_); 16 | constIntPtr_ = ((int32_t const *)constNull_); 17 | intPtr_ = ((int32_t *)constIntPtr_); 18 | address_ = ((intptr_t)intPtr_); 19 | if ((address_ != 0LL)) milone_assert_error("native_cast/native_cast.milone", 14, 2); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /nursery/AppGtk/build-2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | CC=${CC:-gcc} 6 | MILONE_HOME=${MILONE_HOME:-"${HOME}/.milone"} 7 | MILONE_RUNTIME="$MILONE_HOME/src/libmilonert" 8 | 9 | $CC -std=gnu11 -g \ 10 | -fsanitize=undefined \ 11 | -Wall \ 12 | -Wextra \ 13 | -Wno-unused-but-set-parameter \ 14 | -Wno-unused-but-set-variable \ 15 | -Wno-unused-label \ 16 | -Wno-unused-parameter \ 17 | -Wno-unused-variable \ 18 | $(pkg-config --cflags --libs gtk+-3.0) \ 19 | -I$MILONE_RUNTIME \ 20 | "$MILONE_RUNTIME/milone.c" \ 21 | "$MILONE_RUNTIME/milone_platform.c" \ 22 | app_gtk.c \ 23 | target/app_gtk.c \ 24 | -o target/app \ 25 | $(pkg-config --libs gtk+-3.0) 26 | -------------------------------------------------------------------------------- /nursery/LibFileSystemTests/build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | CC=${CC:-gcc} 6 | MILONE_HOME=${MILONE_HOME:-$HOME/.milone} 7 | TARGET="$PWD/target" 8 | 9 | mkdir -p $TARGET 10 | 11 | { 12 | echo '#include "../LibSpan/lib_span_runtime.h"' 13 | # echo '#include "../LibFileSystem/lib_file_system_runtime.h"' 14 | milone compile $PWD 15 | } >$TARGET/lib_file_system_tests.c 16 | 17 | $CC -std=gnu11 -fsanitize=address,undefined \ 18 | -I$MILONE_HOME/src/libmilonert \ 19 | $MILONE_HOME/src/libmilonert/milone.c \ 20 | $MILONE_HOME/src/libmilonert/milone_platform.c \ 21 | ../LibSpan/lib_span_runtime.c \ 22 | $TARGET/lib_file_system_tests.c \ 23 | -o $TARGET/lib_file_system_tests 24 | -------------------------------------------------------------------------------- /tests/examples/x_dyck_lang/x_dyck_lang.fs: -------------------------------------------------------------------------------- 1 | module rec x_dyck_lang.Program 2 | 3 | let main _ = 4 | let rec go (s: string) i d = 5 | if i >= s.Length then 6 | d = 0 7 | else if s.[i] = '(' then 8 | go s (i + 1) (d + 1) 9 | else if d <= 0 then 10 | false 11 | else 12 | go s (i + 1) (d - 1) 13 | 14 | let parse (s: string) = if go s 0 0 then "Accept" else "Reject" 15 | 16 | let case1 = "()" 17 | let case2 = "()((())(()))()" 18 | let case3 = "(()" 19 | let case4 = ")(" 20 | 21 | printfn "case1 (A): %s" (parse case1) 22 | printfn "case2 (A): %s" (parse case2) 23 | printfn "case3 (R): %s" (parse case3) 24 | printfn "case4 (R): %s" (parse case4) 25 | 26 | 0 27 | -------------------------------------------------------------------------------- /tests/errors/token_err/token_err.fs: -------------------------------------------------------------------------------- 1 | // Tokenization errors. 2 | 3 | // undefined operator 4 | 2&&&-3 5 | 6 | // reserved word (F# keyword) 7 | class 8 | 9 | // reserved word (OCaml keyword) 10 | sig 11 | 12 | // reserved word (F# reserved word) 13 | trait 14 | 15 | // invalid characters outside of comments/quotes 16 | こんにちは〜! 17 | 18 | // unknown number suffix 19 | 9mm 20 | 21 | // unknown escape sequence in char literal 22 | '\m' 23 | 24 | // unknown escape sequence in string literal 25 | "\+" 26 | 27 | // invalid hex escape 28 | "\x--" 29 | 30 | // Note 'unclosed... is tokenized as type variable ('T). 31 | '+unclosed char literal 32 | 33 | "unclosed string literal 34 | 35 | """unclosed raw string literal 36 | -------------------------------------------------------------------------------- /tests/primitives/option/option.fs: -------------------------------------------------------------------------------- 1 | module rec option.Program 2 | 3 | // Option types. 4 | 5 | let basicSomeCase () = 6 | match Some 1 with 7 | | None -> assert false 8 | 9 | | Some 1 -> () 10 | 11 | | _ -> assert false 12 | 13 | let basicNoneCase () = 14 | match None with 15 | | Some "a" -> assert false 16 | 17 | | None -> () 18 | 19 | | _ -> assert false 20 | 21 | // Just testing MIR's match-to-switch conversion, 22 | // which is temporary necessary until pattern matching compilation is done. 23 | let basicMatchCase () = 24 | match Some() with 25 | | None -> assert false 26 | | _ -> () 27 | 28 | let main _ = 29 | basicSomeCase () 30 | basicNoneCase () 31 | basicMatchCase () 32 | 0 33 | -------------------------------------------------------------------------------- /tests/features/module_prelude/module_prelude.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | bool MiloneCore_Prelude_BoolBoolFun1_id(bool); 6 | 7 | int32_t MiloneCore_Prelude_Int32Int32Fun1_id(int32_t); 8 | 9 | int main(int argc, char **argv); 10 | 11 | int main(int argc, char **argv) { 12 | milone_start(argc, argv); 13 | bool call_; 14 | int32_t call_1; 15 | call_ = MiloneCore_Prelude_BoolBoolFun1_id(true); 16 | if ((!(call_))) milone_assert_error("module_prelude/module_prelude.milone", 6, 2); 17 | call_1 = MiloneCore_Prelude_Int32Int32Fun1_id(42); 18 | if ((call_1 != 42)) milone_assert_error("module_prelude/module_prelude.milone", 7, 2); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /tests/features/pat_discard/pat_discard.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | struct UnitUnitTuple2_; 6 | 7 | void pat_discard_pat_discard_main_f(void); 8 | 9 | int main(int argc, char **argv); 10 | 11 | struct UnitUnitTuple2_ { 12 | char t0; 13 | char t1; 14 | }; 15 | 16 | void pat_discard_pat_discard_main_f(void) { 17 | printf("hello\n"); 18 | return; 19 | } 20 | 21 | int main(int argc, char **argv) { 22 | milone_start(argc, argv); 23 | struct UnitUnitTuple2_ UnitUnitTuple2_; 24 | pat_discard_pat_discard_main_f(); 25 | pat_discard_pat_discard_main_f(); 26 | UnitUnitTuple2_ = (struct UnitUnitTuple2_){.t0 = 0, .t1 = 0}; 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /scripts/prof: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # See also internals/profiling.md 3 | 4 | set -eux 5 | 6 | MILONE_CMD='target/MiloneCli/bin/milone' 7 | 8 | # build compiler 9 | make worktree && test -f "$MILONE_CMD" 10 | 11 | # build the optimized compiler with instrumentation enabled (-pg flag) 12 | CC='gcc -pg' MILONE_HOME=$PWD "$MILONE_CMD" build --release src/MiloneCli --target-dir target/MiloneProf -o target/milone-prof 13 | 14 | # run the compiler for profiling 15 | MILONE_HOME=$PWD target/milone-prof check src/MiloneCli && \ 16 | test -f gmon.out && \ 17 | mv gmon.out target/gmon.out 18 | 19 | gprof target/milone-prof target/gmon.out | \ 20 | tee target/prof.txt | \ 21 | gprof2dot | \ 22 | dot -Tpng -o target/prof.png 23 | -------------------------------------------------------------------------------- /src/MiloneShared/MiloneShared.fsproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | --allsigs 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /tests/features/record_unordered/record_unordered.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | struct Person_; 6 | 7 | int main(int argc, char **argv); 8 | 9 | struct Person_ { 10 | struct String t0; 11 | int32_t t1; 12 | }; 13 | 14 | int main(int argc, char **argv) { 15 | milone_start(argc, argv); 16 | struct Person_ _john; 17 | struct Person_ _jane; 18 | struct Person_ Person_; 19 | struct Person_ Person_1; 20 | Person_ = (struct Person_){.t0 = (struct String){.ptr = "John Doe", .len = 8}, .t1 = 16}; 21 | _john = Person_; 22 | Person_1 = (struct Person_){.t0 = (struct String){.ptr = "Jane Doe", .len = 8}, .t1 = 18}; 23 | _jane = Person_1; 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /tests/features/pat_shadowing/pat_shadowing.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv); 6 | 7 | int main(int argc, char **argv) { 8 | milone_start(argc, argv); 9 | int32_t x_; 10 | int32_t x_1; 11 | char case1_; 12 | int32_t x_2; 13 | int32_t x_3; 14 | char case2_; 15 | x_ = 1; 16 | x_1 = 0; 17 | if ((x_1 != 0)) milone_assert_error("pat_shadowing/pat_shadowing.milone", 8, 4); 18 | case1_ = 0; 19 | x_2 = 0; 20 | x_3 = 1; 21 | if ((x_3 != 1)) milone_assert_error("pat_shadowing/pat_shadowing.milone", 14, 5); 22 | if ((x_2 != 0)) milone_assert_error("pat_shadowing/pat_shadowing.milone", 16, 4); 23 | case2_ = 0; 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /src/MyBuildTool/assets/uninstall.ps1: -------------------------------------------------------------------------------- 1 | #!/bin/pwsh 2 | # Uninstall milone command from your home directory. 3 | 4 | # **IMPORTANT** 5 | # The script must be sync with documentation: binary_package.md, INSTALL.md 6 | 7 | $ErrorActionPreference = 'Stop' 8 | 9 | $MILONE_CMD = $env:MILONE_CMD 10 | if (!$MILONE_CMD) { 11 | $MILONE_CMD = "$env:USERPROFILE\.local\bin\milone.exe" 12 | } 13 | 14 | $MILONE_HOME = $env:MILONE_HOME 15 | if (!$MILONE_HOME) { 16 | $MILONE_HOME = "$env:USERPROFILE\.local\share\milone" 17 | } 18 | 19 | $MILONE_CMD_DIR = [System.IO.Path]::GetDirectoryName($MILONE_CMD) 20 | 21 | Remove-Item -Force $MILONE_CMD -ErrorAction SilentlyContinue 22 | Remove-Item -Recurse -Force $MILONE_HOME 23 | echo 'Uninstalled successfully!' 24 | -------------------------------------------------------------------------------- /tests/primitives/list_equal/list_equal.fs: -------------------------------------------------------------------------------- 1 | module rec list_equal.Program 2 | 3 | // List type supports structural equality (=). 4 | 5 | // it's necessary to open a library manually for now. 6 | module StdEqual = Std.Equal 7 | 8 | let private testIntList () = 9 | assert ([ 2; 2; 3; 5 ] = [ 2; 2; 3; 5 ]) 10 | 11 | let nil: int list = [] 12 | assert (nil = []) 13 | assert (nil <> [ 0 ]) 14 | 15 | // Ordering differs. 16 | assert ([ 2; 2; 3; 5 ] <> [ 2; 3; 2; 5 ]) 17 | // Prefix. 18 | assert ([ 2; 2; 3 ] <> [ 2; 2; 3; 5 ]) 19 | // Suffix. 20 | assert ([ 2; 3; 5 ] <> [ 2; 2; 3; 5 ]) 21 | 22 | let private testPairList () = 23 | assert ([ 1, "a"; 2, "b" ] = [ 1, "a"; 2, "b" ]) 24 | 25 | let main _ = 26 | testIntList () 27 | testPairList () 28 | 0 29 | -------------------------------------------------------------------------------- /src/MiloneLspServer/run-highlight: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # TODO: update 3 | 4 | set -eu 5 | 6 | MILONE_LANG_DIR="$(dirname $PWD)/MiloneLang" 7 | 8 | { 9 | ./req <err.generated.txt 35 | -------------------------------------------------------------------------------- /src/MyBuildTool/Util.fs: -------------------------------------------------------------------------------- 1 | module internal MyBuildTool.Util 2 | 3 | open System 4 | 5 | module internal StringExt = 6 | let split (sep: string) (s: string) = s.Split(sep) |> Array.toList 7 | let trim (s: string) = s.Trim() 8 | 9 | module internal IO = 10 | open System.IO 11 | 12 | // let join (s: string) (t: string) = Path.Combine(s, t) 13 | let basename (s: string) = Path.GetFileName(s) 14 | // let dirname (s: string) = Path.GetDirectoryName(s) 15 | // let extname (s: string) = Path.GetExtension(s) 16 | 17 | module internal Sha256 = 18 | open System.Security.Cryptography 19 | 20 | let compute (bytes: byte[]) : string = 21 | use h = SHA256.Create() 22 | let hash = h.ComputeHash(bytes) 23 | BitConverter.ToString(hash).Replace("-", "").ToLower() 24 | -------------------------------------------------------------------------------- /tests/features/ty_synonym/ty_synonym.fs: -------------------------------------------------------------------------------- 1 | module rec ty_synonym.Program 2 | 3 | // Type synonyms should work. 4 | 5 | type ExitCode = int 6 | type ExitCodeList = ExitCode list 7 | 8 | type Condition = bool 9 | 10 | let baseCase () = 11 | let success: ExitCode = 0 12 | let failure: ExitCode = 1 13 | let codes: ExitCodeList = [ success; failure ] 14 | assert (success = 0) 15 | 16 | // int = ExitCode should be unifiable. 17 | let yodaCase (exitCode: ExitCode) = assert (0 = exitCode) 18 | 19 | let private proj (cond: Condition) body alt = if cond then body else alt 20 | 21 | let polymorphicFunCase () = 22 | assert (proj true 1 0 = 1) 23 | assert (proj false "T" "F" = "F") 24 | 25 | let main _ = 26 | baseCase () 27 | yodaCase 0 28 | polymorphicFunCase () 29 | 0 30 | -------------------------------------------------------------------------------- /tests/edges/recursive_ty_error_by_synonym/recursive_ty_error_by_synonym.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int32_t recursive_ty_error_by_synonym_recursive_ty_error_by_synonym_Int32Int32Fun1_just(int32_t value_); 6 | 7 | int main(int argc, char **argv); 8 | 9 | int32_t recursive_ty_error_by_synonym_recursive_ty_error_by_synonym_Int32Int32Fun1_just(int32_t value_) { 10 | return value_; 11 | } 12 | 13 | int main(int argc, char **argv) { 14 | milone_start(argc, argv); 15 | int32_t call_; 16 | call_ = recursive_ty_error_by_synonym_recursive_ty_error_by_synonym_Int32Int32Fun1_just(2); 17 | if ((call_ != 2)) milone_assert_error("recursive_ty_error_by_synonym/recursive_ty_error_by_synonym.milone", 7, 2); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /tests/errors/not_equatable_err/not_equatable_err.c: -------------------------------------------------------------------------------- 1 | #error not_equatable_err.not_equatable_err:7:40 Operator (=) is not supported for the type: obj 2 | #error not_equatable_err.not_equatable_err:9:36 Operator (=) is not supported for the type: unit -> int 3 | #error not_equatable_err.not_equatable_err:11:54 Operator (=) is not supported for the type: (obj * int) 4 | #error not_equatable_err.not_equatable_err:15:54 Operator (=) is not supported for the type: UnionWithFun 5 | #error not_equatable_err.not_equatable_err:19:48 Operator (=) is not supported for the type: GU int> 6 | #error not_equatable_err.not_equatable_err:23:66 Operator (=) is not supported for the type: MyNode int> 7 | #error not_equatable_err.not_equatable_err:29:13 Operator (=) is not supported for the type: RecordWithFun 8 | -------------------------------------------------------------------------------- /nursery/LibHttpServer/req: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | SERVER="$PWD/../target/LibHttpServer/httpd --stdio" 5 | 6 | ./build 7 | 8 | cat < 8 | // char const *. not null, null-terminated, scoped, encoded in UTF-8 9 | type CStr = InPtr 10 | 11 | module private CStr = 12 | // allocates on region 13 | let ofString (s: string): CStr = 14 | __nativeFun("string_to_c_str", s) 15 | 16 | // allocates on region 17 | let toString (cs: CStr): string = 18 | __nativeFun("string_of_c_str", cs) 19 | 20 | [] 21 | let milone_parse (text: CStr): CStr = 22 | let host = miloneCliHost () 23 | let sApi = newSyntaxApi () 24 | 25 | let output, _errors = sApi.DumpSyntax (CStr.toString text) 26 | CStr.ofString output 27 | -------------------------------------------------------------------------------- /tests/edges/fun_forward_use/fun_forward_use.fs: -------------------------------------------------------------------------------- 1 | // Fixed. 2 | 3 | // In module rec, functions can be used before declaration. 4 | // That makes type inference ~slightly tricky~ broken for now. 5 | 6 | // Here, `g` is not declared and it has provisional type. 7 | // Type of `f` is inferred to `unit -> 'a`, too generic. 8 | let private f () = g () 9 | 10 | // Here, type of `g` is concluded to `unit -> int`. 11 | // And then provisional type used above is unified to the actual type: 12 | // unit -> 'a 13 | // vs. unit -> int 14 | // This unification should fail since 'a is already quantified. 15 | let private g () = 0 16 | 17 | let private test () = 18 | assert (f () = 0) 19 | 20 | // Since f is inferred too generic, f can return any type. 21 | assert (f () = "") 22 | () 23 | 24 | test () 25 | --------------------------------------------------------------------------------