opam-version: "2.0" synopsis: "4.02.3+curried-constr" description: """ Variant constructors as functions ================================== Suppose we have: ```ocaml type t = Foo of int * float ``` Then ```ocaml Foo ``` is equal to `fun (x,y) -> Foo (x,y)`. And, ```ocaml (Foo ..) (* This is not valid in the vanilla OCaml *) ``` and ``` !Foo (* If you keep the vanilla syntax *) ``` are equal to `fun x y -> Foo (x,y)`. It works for list cons constructor too: ```ocaml (::) : ('a * 'a list) -> 'a list (:: ..) : 'a -> 'a list -> 'a list !(::) : 'a -> 'a list -> 'a list ``` Polymorphic variants as functions --------------------------------------------- ```ocaml (`Foo ..) (* This is not valid in the vanilla OCaml *) !`Foo ``` are equivalent to ```ocaml fun x -> `Foo x ``` Note that ``(`Foo ..)`` always take only one argument: the arity of the polymorphic variant constructors is at most one and it is determined purely syntactically. ```ocaml (`Foo..) (1,2,3) (* `Foo (1,2,3) *) (`Foo..) 1 2 3 (* (`Foo 1) 2 3 which ends in a type error *) ``` Code ``(`Foo)`` has no special meaning. It is just equivalent to `` `Foo``. Samples --------------------------------------------- You can try examples at `testsuite/curried_constr/test.ml`.""" maintainer: "David Allsopp " depends: [ "ocaml" {= "4.02.3" & post} "base-unix" {post} "base-bigarray" {post} "base-threads" {post} "base-ocamlbuild" {post} ] conflict-class: "ocaml-core-compiler" flags: compiler setenv: CAML_LD_LIBRARY_PATH = "%{lib}%/stublibs" build: [ [ "sed" "-ib" "-e" "s/opts=\"\"/opts=\"-Wno-implicit-function-declaration\"/" "config/auto-aux/hasgot" ] {os = "macos"} ["./configure" "-prefix" prefix "-with-debug-runtime"] {os != "openbsd" & os != "freebsd" & os != "macos"} [ "./configure" "-prefix" prefix "-with-debug-runtime" "-cc" "cc" "-aspp" "cc -c" ] {os = "openbsd" | os = "freebsd" | os = "macos"} [make "world.opt"] ] install: [make "install"] url { src: "https://github.com/camlspotter/ocaml/archive/4.02.3+curried-constr.tar.gz" checksum: [ "sha256=53f5420416e6f9dbd8abb790dd4d2e1cf62c04e042a320a02086c4cdc5a1cd48" "md5=754cb6ef120d90273610ab5f860b99e7" ] } patches: ["fix-gcc10.patch" "gpr1330.patch" "alt-signal-stack.patch"] available: !(os = "macos" & arch = "arm64") license: "LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception" authors: [ "Xavier Leroy" "Damien Doligez" "Alain Frisch" "Jacques Garrigue" "Didier Rémy" "Jérôme Vouillon" ] bug-reports: "https://github.com/ocaml/opam-repository/issues" homepage: "https://ocaml.org" dev-repo: "git+https://github.com/ocaml/ocaml.git#4.02" extra-source "alt-signal-stack.patch" { src: "https://github.com/ocaml/ocaml/commit/9de2b77472aee18a94b41cff70caee27fb901225.patch?full_index=1" checksum: "sha256=91841447cc2d11ebe67a078ace677a18f06432ebf15c4c6d5a09e04b67dd041a" } extra-source "gpr1330.patch" { src: "https://github.com/ocaml/ocaml/commit/bcc7a767279ff70518b3f4219cc0b9bffec7dd43.patch?full_index=1" checksum: "sha256=594d4dd6c192fe77e9fc025674b51e3de74d70326b2e750a249a09eeded68716" } extra-source "fix-gcc10.patch" { src: "https://raw.githubusercontent.com/ocaml/opam-source-archives/main/patches/ocaml-base-compiler/fix-gcc10.patch.4.02.3" checksum: [ "sha256=7f66fe8a08dbb4f63f927b864576d15ab6062787d19ffe6dfa5c36b733c9e330" "md5=4516183897da9033f49dd291fa198b8c" ] }