caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: [Caml-list] Coccinelle and the Dumper module
       [not found] <20160223095607.GA10534@pl-59055.rocqadm.inria.fr>
@ 2016-02-23 10:33 ` Richard W.M. Jones
  2016-02-23 11:05   ` Sébastien Hinderer
  0 siblings, 1 reply; 5+ messages in thread
From: Richard W.M. Jones @ 2016-02-23 10:33 UTC (permalink / raw)
  To: Sébastien Hinderer; +Cc: caml-list

On Tue, Feb 23, 2016 at 10:56:07AM +0100, Sébastien Hinderer wrote:
> Dear Richard,
> 
> With Coccinelle we distribute your Dumper module.
>
> I just noticed that the version we have is quite old and produces
> warnings when compiled.
>
> Is it okay if we distribute a modified version of the code to fix those
> warnings?

Yes.  I'm not sure if it was ever licensed properly, but I'm willing
now to (re?)license it under a liberal 3 clause, no advertising
requirement, BSD license:

  https://fedoraproject.org/wiki/Licensing:BSD?rd=Licensing/BSD#New_BSD_.28no_advertising.2C_3_clause.29

This is pretty close to "do what you like with it".  I'm CC-ing this
to caml-list to put this in the public record.

> Is there a more recent version of the code available?

Not as far as I know, but if you search for "dumper.mli" you will see
many copies in different places, so I suppose you'll have to go check
if people have added useful features that you want.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Coccinelle and the Dumper module
  2016-02-23 10:33 ` [Caml-list] Coccinelle and the Dumper module Richard W.M. Jones
@ 2016-02-23 11:05   ` Sébastien Hinderer
  2016-02-23 11:46     ` Gabriel Scherer
  0 siblings, 1 reply; 5+ messages in thread
From: Sébastien Hinderer @ 2016-02-23 11:05 UTC (permalink / raw)
  To: Richard W.M. Jones; +Cc: caml-list

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

Dear Richard,

Thanks a lot for your prompt, positive and helpful respnse!

> Yes.  I'm not sure if it was ever licensed properly, but I'm willing
> now to (re?)license it under a liberal 3 clause, no advertising
> requirement, BSD license:
> 
>   https://fedoraproject.org/wiki/Licensing:BSD?rd=Licensing/BSD#New_BSD_.28no_advertising.2C_3_clause.29
> 
> This is pretty close to "do what you like with it".  I'm CC-ing this
> to caml-list to put this in the public record.

Great! Thanks!

> > Is there a more recent version of the code available?
> 
> Not as far as I know, but if you search for "dumper.mli" you will see
> many copies in different places, so I suppose you'll have to go check
> if people have added useful features that you want.

Okay. I think we are fine with what we have, at the moment.

So there were two warnings, one about an unused "open Printf" and one
about an unused variable.

The attached version of the module fixes them.

I may also get rid of the "open Obj" statement and qualify all the
references to this module as I fnd this style more clear.

Cheers,
Sébastien.

[-- Attachment #2: dumper.mli --]
[-- Type: text/plain, Size: 169 bytes --]

(* Dump an OCaml value into a printable string.
 * By Richard W.M. Jones (rich@annexia.org).
 * dumper.mli 1.1 2005/02/03 23:07:47 rich Exp
 *)

val dump : 'a -> string

[-- Attachment #3: dumper.ml --]
[-- Type: text/plain, Size: 2599 bytes --]

(* Dump an OCaml value into a printable string.
 * By Richard W.M. Jones (rich@annexia.org).
 * dumper.ml 1.2 2005/02/06 12:38:21 rich Exp
 *)

open Obj

let rec dump r =
  if is_int r then
    string_of_int (magic r : int)
  else (				(* Block. *)
    let rec get_fields acc = function
      | 0 -> acc
      | n -> let n = n-1 in get_fields (field r n :: acc) n
    in
    let rec is_list r =
      if is_int r then (
	if (magic r : int) = 0 then true (* [] *)
	else false
      ) else (
	let s = size r and t = tag r in
	if t = 0 && s = 2 then is_list (field r 1) (* h :: t *)
	else false
      )
    in
    let rec get_list r =
      if is_int r then []
      else let h = field r 0 and t = get_list (field r 1) in h :: t
    in
    let opaque name =
      (* XXX In future, print the address of value 'r'.  Not possible in
       * pure OCaml at the moment.
       *)
      "<" ^ name ^ ">"
    in

    let s = size r and t = tag r in

    (* From the tag, determine the type of block. *)
    if is_list r then ( (* List. *)
      let fields = get_list r in
      "[" ^ String.concat "; " (List.map dump fields) ^ "]"
    )
    else if t = 0 then (		(* Tuple, array, record. *)
      let fields = get_fields [] s in
      "(" ^ String.concat ", " (List.map dump fields) ^ ")"
    )

      (* Note that [lazy_tag .. forward_tag] are < no_scan_tag.  Not
       * clear if very large constructed values could have the same
       * tag. XXX *)
    else if t = lazy_tag then opaque "lazy"
    else if t = closure_tag then opaque "closure"
    else if t = object_tag then (	(* Object. *)
      let fields = get_fields [] s in
      let _, id, slots =
	match fields with h::h'::t -> h, h', t | _ -> assert false in
      (* No information on decoding the class (first field).  So just print
       * out the ID and the slots.
       *)
      "Object #" ^ dump id ^
      " (" ^ String.concat ", " (List.map dump slots) ^ ")"
    )
    else if t = infix_tag then opaque "infix"
    else if t = forward_tag then opaque "forward"

    else if t < no_scan_tag then (	(* Constructed value. *)
      let fields = get_fields [] s in
      "Tag" ^ string_of_int t ^
      " (" ^ String.concat ", " (List.map dump fields) ^ ")"
    )
    else if t = string_tag then (
      "\"" ^ String.escaped (magic r : string) ^ "\""
    )
    else if t = double_tag then (
      string_of_float (magic r : float)
    )
    else if t = abstract_tag then opaque "abstract"
    else if t = custom_tag then opaque "custom"
    else failwith ("dump: impossible tag (" ^ string_of_int t ^ ")")
  )

let dump v = dump (repr v)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Coccinelle and the Dumper module
  2016-02-23 11:05   ` Sébastien Hinderer
@ 2016-02-23 11:46     ` Gabriel Scherer
  2016-02-23 12:02       ` Richard W.M. Jones
  2016-02-23 13:10       ` Sébastien Hinderer
  0 siblings, 2 replies; 5+ messages in thread
From: Gabriel Scherer @ 2016-02-23 11:46 UTC (permalink / raw)
  To: Sébastien Hinderer, Richard W.M. Jones, caml users

This "dump" code has lived on in Extlib (to which Richard
participated, I believe), and is also part of Batteries. I know that
ygrek, Extlib's current maintainers, has done some fixes to it (I
think we ported them into Batteries), so you may want to look there.

On Tue, Feb 23, 2016 at 6:05 AM, Sébastien Hinderer
<Sebastien.Hinderer@inria.fr> wrote:
> Dear Richard,
>
> Thanks a lot for your prompt, positive and helpful respnse!
>
>> Yes.  I'm not sure if it was ever licensed properly, but I'm willing
>> now to (re?)license it under a liberal 3 clause, no advertising
>> requirement, BSD license:
>>
>>   https://fedoraproject.org/wiki/Licensing:BSD?rd=Licensing/BSD#New_BSD_.28no_advertising.2C_3_clause.29
>>
>> This is pretty close to "do what you like with it".  I'm CC-ing this
>> to caml-list to put this in the public record.
>
> Great! Thanks!
>
>> > Is there a more recent version of the code available?
>>
>> Not as far as I know, but if you search for "dumper.mli" you will see
>> many copies in different places, so I suppose you'll have to go check
>> if people have added useful features that you want.
>
> Okay. I think we are fine with what we have, at the moment.
>
> So there were two warnings, one about an unused "open Printf" and one
> about an unused variable.
>
> The attached version of the module fixes them.
>
> I may also get rid of the "open Obj" statement and qualify all the
> references to this module as I fnd this style more clear.
>
> Cheers,
> Sébastien.
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Coccinelle and the Dumper module
  2016-02-23 11:46     ` Gabriel Scherer
@ 2016-02-23 12:02       ` Richard W.M. Jones
  2016-02-23 13:10       ` Sébastien Hinderer
  1 sibling, 0 replies; 5+ messages in thread
From: Richard W.M. Jones @ 2016-02-23 12:02 UTC (permalink / raw)
  To: Gabriel Scherer; +Cc: Sébastien Hinderer, caml users

On Tue, Feb 23, 2016 at 06:46:23AM -0500, Gabriel Scherer wrote:
> This "dump" code has lived on in Extlib (to which Richard
> participated, I believe), and is also part of Batteries. I know that
> ygrek, Extlib's current maintainers, has done some fixes to it (I
> think we ported them into Batteries), so you may want to look there.

Ah I see you are right.  I actually checked extlib before posting
that, but forgot that it was not a standalone module but added to the
'Std' module, here:

https://github.com/ygrek/ocaml-extlib/blob/master/src/std.ml

What I said about the licensing of my contributions still applies
(also 3 clause BSD & LGPL are compatible, so that's fine).

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Coccinelle and the Dumper module
  2016-02-23 11:46     ` Gabriel Scherer
  2016-02-23 12:02       ` Richard W.M. Jones
@ 2016-02-23 13:10       ` Sébastien Hinderer
  1 sibling, 0 replies; 5+ messages in thread
From: Sébastien Hinderer @ 2016-02-23 13:10 UTC (permalink / raw)
  To: Gabriel Scherer; +Cc: Richard W.M. Jones, caml users

Thanks a lot for your feedback, Gabriel!

Sébastien.

Gabriel Scherer (2016/02/23 06:46 -0500):
> This "dump" code has lived on in Extlib (to which Richard
> participated, I believe), and is also part of Batteries. I know that
> ygrek, Extlib's current maintainers, has done some fixes to it (I
> think we ported them into Batteries), so you may want to look there.
> 
> On Tue, Feb 23, 2016 at 6:05 AM, Sébastien Hinderer
> <Sebastien.Hinderer@inria.fr> wrote:
> > Dear Richard,
> >
> > Thanks a lot for your prompt, positive and helpful respnse!
> >
> >> Yes.  I'm not sure if it was ever licensed properly, but I'm willing
> >> now to (re?)license it under a liberal 3 clause, no advertising
> >> requirement, BSD license:
> >>
> >>   https://fedoraproject.org/wiki/Licensing:BSD?rd=Licensing/BSD#New_BSD_.28no_advertising.2C_3_clause.29
> >>
> >> This is pretty close to "do what you like with it".  I'm CC-ing this
> >> to caml-list to put this in the public record.
> >
> > Great! Thanks!
> >
> >> > Is there a more recent version of the code available?
> >>
> >> Not as far as I know, but if you search for "dumper.mli" you will see
> >> many copies in different places, so I suppose you'll have to go check
> >> if people have added useful features that you want.
> >
> > Okay. I think we are fine with what we have, at the moment.
> >
> > So there were two warnings, one about an unused "open Printf" and one
> > about an unused variable.
> >
> > The attached version of the module fixes them.
> >
> > I may also get rid of the "open Obj" statement and qualify all the
> > references to this module as I fnd this style more clear.
> >
> > Cheers,
> > Sébastien.
> >

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-02-23 13:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20160223095607.GA10534@pl-59055.rocqadm.inria.fr>
2016-02-23 10:33 ` [Caml-list] Coccinelle and the Dumper module Richard W.M. Jones
2016-02-23 11:05   ` Sébastien Hinderer
2016-02-23 11:46     ` Gabriel Scherer
2016-02-23 12:02       ` Richard W.M. Jones
2016-02-23 13:10       ` Sébastien Hinderer

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).