Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Curried data constructors (feature wish) #2353

Closed
vicuna opened this issue Mar 17, 2004 · 1 comment
Closed

Curried data constructors (feature wish) #2353

vicuna opened this issue Mar 17, 2004 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Mar 17, 2004

Original bug ID: 2353
Reporter: administrator
Status: closed (set by @xavierleroy on 2013-08-31T10:46:17Z)
Resolution: won't fix
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Fermin Reig
Version: 3.07
OS: linux
Submission from: franc.cs.nott.ac.uk (128.243.21.224)

Hello,

I would like to have curried data constructors, a la Haskell. Xavier Leroy has
already stated (http://caml.inria.fr/archives/200108/msg00022.html) that this
will not be made the default behaviour in Caml. What I would like to have is the
option of having curried constructors. This would be a backwards-compatible
extension, which would have no impact on programs that don't use it.

A possible syntax is:

type t = Curried of int int | ...

The underlying representation of this in terms of the current syntax would be:

Curried of int, int

That is, the arity is 2 in both cases. Each ocurrence of 'Curried' in an
expression can be desugared to (fun x y -> Curried x, y). A similar translation
is done in patterns. I believe this needs be done before type-checking. In
addition, for exported types, the fact that a constructor is curried should be
present in .cmi files, so that desugaring is done in client modules.

Thanks,
Fermin Reig

@vicuna
Copy link
Author

vicuna commented Jan 30, 2012

Comment author: @damiendoligez

Camlp4 and the revised syntax provide some amount of support for curried constructors. We do not think it would make a good addition to the traditional syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant