caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Christoph Höger" <christoph.hoeger@tu-berlin.de>
To: caml users <caml-list@inria.fr>
Subject: [Caml-list] recursive values of abstract types, aka Batteries ParserCo
Date: Wed, 20 Aug 2014 14:59:26 +0200	[thread overview]
Message-ID: <53F49BAE.40901@tu-berlin.de> (raw)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

I wanted to parse a small lambda-calculus in OCaml and had batteries
already as a dependency. Batteries comes with ParserCo, a small parser
combinator library. Since I did not want to complicate things further,
I decided to stick with it and avoid any parser generator. Using a
monadic combinator library for a scannerless parser should be a
relatively simple exercise, right?

Unfortunately, it seems that ParserCo only exposes an abstract type:

type ('a, 'b, 'c) t

which is, of course, a function:

type ('a, 'b, 'c) t = ('a, 'c) Source.t -> ('a, 'b, 'c) result

This prevents me from defining any recursive parsers, since OCaml
won't let me let-rec a value of an abstract function type. I cannot do
eta-expansion, because the type is abstract, and I also do not have a
type constructor at hand.

How does one handle such cases in OCaml? Does this really mean, you
cannot have recursive values of abstract function types?

thanks,

Christoph



- -- 
Christoph Höger

Technische Universität Berlin
Fakultät IV - Elektrotechnik und Informatik
Übersetzerbau und Programmiersprachen

Sekr. TEL12-2, Ernst-Reuter-Platz 7, 10587 Berlin

Tel.: +49 (30) 314-24890
E-Mail: christoph.hoeger@tu-berlin.de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iEYEARECAAYFAlP0m64ACgkQhMBO4cVSGS+FcACdF2eqj5eN80oeRTghSnKDd9E+
80MAoL1DpqKfx5+UxJoLnUyZwpXQCibH
=Rw4X
-----END PGP SIGNATURE-----

             reply	other threads:[~2014-08-20 12:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-20 12:59 Christoph Höger [this message]
2014-08-24 15:48 ` Leo White

Reply instructions:

You may reply publicly 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=53F49BAE.40901@tu-berlin.de \
    --to=christoph.hoeger@tu-berlin.de \
    --cc=caml-list@inria.fr \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).