caml-list - the Caml user's mailing list
 help / Atom feed
From: Ashish Agarwal <agarwal1975@gmail.com>
To: "Soegtrop, Michael" <michael.soegtrop@intel.com>
Cc: Gabriel Scherer <gabriel.scherer@gmail.com>, "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] Newbie comment on constructor syntax
Date: Fri, 6 Nov 2015 09:10:28 -0500
Message-ID: <CAMu2m2J177ix0c-E61_-1Z8Gp6hrwjJWAXcnLa9VjmW_5d0O=g@mail.gmail.com> (raw)
In-Reply-To: <0F7D3B1B3C4B894D824F5B822E3E5A172CE3E156@IRSMSX102.ger.corp.intel.com>

[-- Attachment #1: Type: text/plain, Size: 4018 bytes --]

You might be interested in:
https://github.com/janestreet/ppx_variants_conv

Example:

$ utop
utop # #require "ppx_deriving";;
utop # #require "ppx_variants_conv";;
utop # #require "variantslib";;

type t = A of int | C of int * int [@@deriving variants];;
type t = A of int | C of int * int
val c : int -> int -> t = <fun>
val a : int -> t = <fun>

module Variants :
  sig
    val c : (int -> int -> t) Variantslib.Variant.t
    val a : (int -> t) Variantslib.Variant.t
    val fold :
      init:'a ->
      a:('a -> (int -> t) Variantslib.Variant.t -> 'b) ->
      c:('b -> (int -> int -> t) Variantslib.Variant.t -> 'c) -> 'c
    val iter :
      a:((int -> t) Variantslib.Variant.t -> 'a) ->
      c:((int -> int -> t) Variantslib.Variant.t -> 'b) -> 'b
    val map :
      t ->
      a:((int -> t) Variantslib.Variant.t -> int -> 'a) ->
      c:((int -> int -> t) Variantslib.Variant.t -> int -> int -> 'a) -> 'a
    val descriptions : (string * int) list
  end

(I'm not quite sure why you have to do three #require statements manually.
Related to this <https://github.com/janestreet/ppx_sexp_conv/issues/1>.)


> Does everybody use camlp4/p5/ppx to customize the syntax to his liking

Note that the community is moving to ppx based syntax extensions, and away
from camlp4/5.

> 200k of code

Where do you see that much code? I only see 6000 lines of code.



On Fri, Nov 6, 2015 at 8:09 AM, Soegtrop, Michael <
michael.soegtrop@intel.com> wrote:

> Dear Gabriel,
>
>
>
> thanks for the link, an interesting idea and discussion! And I see that
> maybe I should come over to Paris to participate ;-) I would agree with
> Alain Frisch’s final comment that whenever a pattern synonym is used in the
> RHS, there should be an explicit binder. This would either solve the
> “trouble” case or make the similarity to (x, x) obvious.
>
>
>
> Best regards,
>
>
>
> Michael
>
>
>
> *From:* caml-list-request@inria.fr [mailto:caml-list-request@inria.fr] *On
> Behalf Of *Gabriel Scherer
> *Sent:* Friday, November 06, 2015 1:34 PM
> *To:* Soegtrop, Michael
> *Cc:* Francois Berenger; caml-list@inria.fr
> *Subject:* Re: [Caml-list] Newbie comment on constructor syntax
>
>
>
> The use of camlp{4,5} to change OCaml syntax has always had extremely low
> adoption, with some very specific exceptions (notably the lwt-support
> syntax of the Ocsigen project). I suspect that this is due to the fact that
> integrating a new syntax extension to your project has historically caused
> more build-system and deployment trouble than people were willing to
> tolerate.
>
> ppx extensions are not designed to allow extending the OCaml syntax, and
> in particular I think they are not a good fit for what you are looking for.
> It is a large part of their appeal: by being less flexible, they are
> simpler and more robust.
>
> I personally believe that currified constructor syntax would be a better
> choice, and that using non-currified constructors is a historical mistake
> of SML/Caml. But I am also not convinced that efforts to change it today
> are worth the trouble, and prefer to concentrate on improving other parts
> of the OCaml ecosystem.
>
> Another thing that was touched by your comments is the usefulness of
> user-defined patterns (pattern synonyms). I have conflicted opinions on the
> question of whether adding pattern synonyms would be a good thing, but
> described one aspect of a proposal that I like (but also highlights that
> the feature can be a source of implementation complexity) in
>   http://gallium.inria.fr/blog/pattern-synonyms-as-expressions/
>
> Intel Deutschland GmbH
> Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
> Tel: +49 89 99 8853-0, www.intel.de
> Managing Directors: Christin Eisenschmid, Christian Lamprechter
> Chairperson of the Supervisory Board: Nicole Lau
> Registered Office: Munich
> Commercial Register: Amtsgericht Muenchen HRB 186928
>

[-- Attachment #2: Type: text/html, Size: 7948 bytes --]

  reply index

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-06  9:33 Soegtrop, Michael
2015-11-06 10:04 ` Nicolas Ojeda Bar
2015-11-06 10:31 ` Francois Berenger
2015-11-06 12:20   ` Soegtrop, Michael
2015-11-06 12:34     ` Gabriel Scherer
2015-11-06 13:09       ` Soegtrop, Michael
2015-11-06 14:10         ` Ashish Agarwal [this message]
2015-11-06 15:19           ` Soegtrop, Michael
2015-11-06 15:22             ` Ashish Agarwal
2015-11-21 17:24       ` [Caml-list] Notation for currying Hendrik Boom
2015-11-21 17:42         ` Gabriel Scherer
2015-11-21 18:06         ` David Rajchenbach-Teller
2015-11-21 18:56           ` Gabriel Scherer
2015-11-06 12:29 ` [Caml-list] Newbie comment on constructor syntax Jonas Jensen
2015-11-06 12:46   ` Soegtrop, Michael
2015-11-06 12:55     ` Gabriel Scherer
2015-11-08 21:17 ` Florian Weimer
2015-11-08 22:51   ` Norman Hardy
2015-11-09  6:27     ` Florian Weimer
2015-11-09 13:27       ` Stefan Monnier
2015-11-09  8:10     ` Soegtrop, Michael
2015-11-09 10:00       ` Hendrik Boom
2015-11-09 10:17       ` Alain Frisch
2015-11-09 10:35         ` Andreas Rossberg
2015-11-09 12:28           ` Alain Frisch
2015-11-09 17:33           ` Alain Frisch
2015-11-09 18:09             ` Gabriel Scherer
2015-11-09 18:16               ` Andreas Rossberg
2015-11-09 21:12                 ` Gabriel Scherer
2015-11-09 22:06                   ` Alain Frisch
2015-11-09 22:27                   ` Andreas Rossberg
2015-11-09 22:57                     ` Jeremy Yallop
2015-11-10  0:11                   ` Hendrik Boom
2015-11-10  8:27                   ` Soegtrop, Michael
2015-11-10 10:26                     ` Romain Bardou
2015-11-10 10:44                       ` Alain Frisch
2015-11-10 10:55                         ` Romain Bardou
2015-11-10 13:17                           ` Alain Frisch
2015-11-10 13:41                             ` Romain Bardou
2015-11-10 14:01                               ` Alain Frisch
2015-11-13 15:36                           ` Romain Bardou
2015-11-10 11:17                         ` Soegtrop, Michael
2015-11-10 14:11                     ` Hendrik Boom
2015-11-10 14:40                       ` immanuel litzroth
2015-11-10 15:30                       ` Soegtrop, Michael
2015-11-10 17:28                         ` Gerd Stolpmann
2015-11-09 20:32               ` Alain Frisch

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMu2m2J177ix0c-E61_-1Z8Gp6hrwjJWAXcnLa9VjmW_5d0O=g@mail.gmail.com' \
    --to=agarwal1975@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=gabriel.scherer@gmail.com \
    --cc=michael.soegtrop@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

caml-list - the Caml user's mailing list

Archives are clonable: git clone --mirror https://inbox.ocaml.org/caml-list

AGPL code for this site: git clone https://public-inbox.org/ public-inbox