Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Hugo Ferreira <hmf@inescporto.pt>
To: Paolo Donadeo <p.donadeo@gmail.com>
Cc: caml-list caml-list <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Escaped string in sexplib
Date: Tue, 08 Jun 2010 20:10:28 +0100	[thread overview]
Message-ID: <4C0E95A4.1050103@inescporto.pt> (raw)
In-Reply-To: <AANLkTikXhoT3Ifmgr6Njd2UCQ4ssCOeoCLKAMq7YwLHN@mail.gmail.com>

Hi Paolo,

Paolo Donadeo wrote:
> I'm using Sexplib to store and retrieve the sessions of a web
> application into a data base. A "session" has this signature:
> 
> module type SESSION_DATA =
>   sig
>     type t
>     val default : t
>     val string_of_t : t -> string (* Is this what you want? *)
>     val t_of_string : string -> t (* Is this what you want? *)
>   end
> 
> and the concrete session, which is a blog session, is:
> 
> module Blog_session =
>   struct
>     type user =
>       {
>         email : string;
>         passwd : string;
>         first_name : string option;
>         last_name : string option;
>         displ_name : string option;
>         website : string option
>       } with sexp
> 
>     type t =
>       | Anonymous
>       | Logged of user
>         with sexp
> 
>     let default = Anonymous
> 
>     let string_of_t = sexp_of_t |- Sexplib.Sexp.to_string_hum |- hex_encode
> 
>     let t_of_string s =
>       try s |> hex_decode |> Sexplib.Sexp.of_string |> t_of_sexp
>       with Sexplib.Conv.Of_sexp_error (_, _) -> default
>   end
> 

My be a solution. Going to see if I can find an alternate
implementation of hex encoding so as not to require another
library.

Thanks,
Hugo F.


> Functions "hex_encode" and "hex_decode" are trivially implemented
> using Cryptokit:
> 
> let hex_encode = Cryptokit.transform_string (Cryptokit.Hexa.encode ())
> let hex_decode = Cryptokit.transform_string (Cryptokit.Hexa.decode ())
> 
> The operators (|-) and (|>) are defined as always:
> 
> http://thelema.github.com/batteries-included/hdoc/BatPervasives.html#6_Fundamentalfunctionsandoperators
> 
> 
> Hope this helps,
> 
> 


  reply	other threads:[~2010-06-08 19:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-08 15:44 Hugo Ferreira
2010-06-08 16:23 ` [Caml-list] " Paolo Donadeo
2010-06-08 19:10   ` Hugo Ferreira [this message]
2010-06-08 16:52 ` Markus Mottl
2010-06-08 18:52   ` Hugo Ferreira
2010-06-08 19:30     ` Hugo Ferreira
2010-06-09  7:39       ` Paolo Donadeo
2010-06-09  8:02         ` Hugo Ferreira
2010-06-08 19:36     ` Markus Mottl
2010-06-08 19:40       ` Hugo Ferreira
2010-06-08 19:42     ` Török Edwin
2010-06-09  6:40       ` Hugo Ferreira

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=4C0E95A4.1050103@inescporto.pt \
    --to=hmf@inescporto.pt \
    --cc=caml-list@yquem.inria.fr \
    --cc=p.donadeo@gmail.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
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