Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Caml-list] deriving

19 views
Skip to first unread message

Matej Košík

unread,
Jan 27, 2012, 11:51:59 AM1/27/12
to caml...@inria.fr
Hi,

I would like to play with / evaluate the "deriving" library:
http://code.google.com/p/deriving/wiki/Introduction

How can I:
- create a Ocaml top-level where I can play with it?
- compile programs which take advantage of this library?

I am on Fedora 16.

What I have tried is this:

$ sudo yum install ocaml-deriving-devel
$ rlwrap ocaml
# #use "topfind";;
# #require "deriving";;
No such package: %{camlp4} - Required by `deriving'

I am not sure how to proceed.

------------------------------------------------

Concerning linking against this library, I have tried this:

$ cat Main.ml

let s = Show.show<int> 3

$ ocamlc -I +deriving -pp "camlp4of -I `ocamlc -where`/deriving
nums.cma deriving.cma" deriving.cma Main.ml -o main

File "ghost-location", line 7, characters 8--144:
Error: Unbound value Show.show
make: *** [main] Error 2

where "Main.ml" is supposed to be a program that uses syntactic sugar
provided by "deriving" library.

What is the proper way to get things compiled? I have failed to find any
examples.

Thanks in advance for the help.

--
Caml-list mailing list. Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Richard Stoerzer

unread,
Jan 27, 2012, 6:37:04 PM1/27/12
to caml...@inria.fr
On Fri, 27 Jan 2012 16:51:35 +0000
Matej Košík <5764c029b688c1c...@gmail.com> wrote:

> $ ocamlc -I +deriving -pp "camlp4of -I `ocamlc -where`/deriving
> nums.cma deriving.cma" deriving.cma Main.ml -o main

Just take a look at the examples under "./test".
deriving ships with an own preprocessor:
e.g:
ocamlc -pp "deriving" -I $DERIVING_DIR deriving.cma mail.ml -o main

Or use the version, that is provided by the ocsigen team
( http://ocsigen.org/download/ )
This one is findlib friendly and supports the toplevel without hassle.

Lin

unread,
Jan 29, 2012, 8:09:29 AM1/29/12
to caml...@inria.fr
I have no Fedora machine at hand, but from the error message it seems to
have something to do with camlp4. Do you have it installed correctly?
Check if you have the camlp4 command by `which camlp4`.

Matej Košík

unread,
Jan 29, 2012, 1:12:15 PM1/29/12
to Lin, caml...@inria.fr
On 01/29/2012 01:10 PM, Lin wrote:
> I have no Fedora machine at hand, but from the error message it seems to
> have something to do with camlp4. Do you have it installed correctly?
> Check if you have the camlp4 command by `which camlp4`.

I am not sure what caused the problem but camlp4 was not missing.

After some experimentation I was able to get "godi-deriving-ocsigen"
working. Why Fedora package did not work for me, I do not know. Maybe I
did some other error... I am not very familiar with Ocaml libraries.

Thanks for the tip.

Adrien

unread,
Jan 29, 2012, 1:16:20 PM1/29/12
to Matej Košík, caml...@inria.fr
Hi,

Could you show the content of the META file for deriving on your
fedora installation?

On my computer (I'm not using fedora), a command like this one points
to a proper file:
% find /opt/ocaml -name META | grep -i deriving
/opt/ocaml/lib/ocaml/pkg-lib/deriving-ocsigen/META

Regards,
Adrien Nader

Matej Košík

unread,
Jan 29, 2012, 1:26:03 PM1/29/12
to Adrien, caml...@inria.fr
On 01/29/2012 06:15 PM, Adrien wrote:
> Hi,
>
> Could you show the content of the META file for deriving on your
> fedora installation?
>
> On my computer (I'm not using fedora), a command like this one points
> to a proper file:
> % find /opt/ocaml -name META | grep -i deriving
> /opt/ocaml/lib/ocaml/pkg-lib/deriving-ocsigen/META

Here it is:

mkosik@desktop:~$ cat /usr/lib64/ocaml/deriving/META
name="deriving"
version="0.1.1a"
requires="%{camlp4}"
description="%{description}"
# need a syntax here XXX

Richard W.M. Jones

unread,
Jan 29, 2012, 2:34:59 PM1/29/12
to Matej Košík, caml...@inria.fr
On Fri, Jan 27, 2012 at 04:51:35PM +0000, Matej Košík wrote:
> Hi,
>
> I would like to play with / evaluate the "deriving" library:
> http://code.google.com/p/deriving/wiki/Introduction
>
> How can I:
> - create a Ocaml top-level where I can play with it?
> - compile programs which take advantage of this library?
>
> I am on Fedora 16.
>
> What I have tried is this:
>
> $ sudo yum install ocaml-deriving-devel
> $ rlwrap ocaml
> # #use "topfind";;
> # #require "deriving";;
> No such package: %{camlp4} - Required by `deriving'

This is a bug in the Fedora package:

$ cat /usr/lib64/ocaml/deriving/META
name="deriving"
version="0.1.1a"
requires="%{camlp4}"
description="%{description}"

Obviously those %... sequences are RPM macros which should have been
replaced. Please file a bug at http://bugzilla.redhat.com

Rich.

--
Richard Jones
Red Hat
0 new messages