package ocaml-variants
- Overview
- No Docs
You can search for identifiers within the package.
in-package search v0.2.0
 sectionYPositions = computeSectionYPositions($el), 10)"
  x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
  >
  
  
On This Page
  
  
  4.02.3+curried-constr
Install
    
    dune-project
 Dependency
Authors
Maintainers
Sources
  
    
      4.02.3+curried-constr.tar.gz
    
    
        
    
  
  
  
    
  
  
    
  
        sha256=53f5420416e6f9dbd8abb790dd4d2e1cf62c04e042a320a02086c4cdc5a1cd48
    
    
  md5=754cb6ef120d90273610ab5f860b99e7
    
    
  Description
Variant constructors as functions
Suppose we have:
type t = Foo of int * float
Then
Foo
is equal to fun (x,y) -> Foo (x,y). And,
(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:
(::)    : ('a * 'a list) -> 'a list
(:: ..) : 'a -> 'a list -> 'a list
!(::)   : 'a -> 'a list -> 'a list
Polymorphic variants as functions
(`Foo ..)         (* This is not valid in the vanilla OCaml *)
!`Foo
are equivalent to
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.
(`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.
Published: 28 Mar 2018
Dependencies (5)
- 
  
    base-ocamlbuild
  
  
    post
- 
  
    base-threads
  
  
    post
- 
  
    base-bigarray
  
  
    post
- 
  
    base-unix
  
  
    post
- 
  
    ocaml
  
  
    = "4.02.3" & post
Dev Dependencies
None
Used by (3)
- 
  
    ocaml
  
  
    = "4.02.3"
- 
  
    ocaml-config
  
  
    = "1" | >= "3"
- 
  
    ocaml-options-only-no-flat-float-array
  
  
    < "1+bytecode-only"
Conflicts
None
 sectionYPositions = computeSectionYPositions($el), 10)"
  x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
  >
  
  
  On This Page