caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Dario Teixeira <darioteixeira@yahoo.com>
To: Jacques Carette <carette@mcmaster.ca>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Phantom types: transparency vs rogue unification
Date: Wed, 25 Jun 2008 09:29:48 -0700 (PDT)	[thread overview]
Message-ID: <522359.38196.qm@web54605.mail.re2.yahoo.com> (raw)
In-Reply-To: <48625DED.7080704@mcmaster.ca>

> Note that I would personally implement Stringies_IO a
> Functor over 
> Stringies rather than having explicit dependencies.
> 

Hi,

Indeed!  In the meantime I've also thought of a functor-based solution,
which does the job even though it looks rather contrived:

_________________________________________________________
module type PARSER =
sig
	val parse: string -> float
end

module type STRINGIES =
sig
	type 'a t
	val make: float -> string t
	val add: string t -> string t -> string t
	val parse: string -> string t
end

module Stringies (Parser : PARSER): STRINGIES =
struct
	type 'a t = float
	let make x = x
	let add a b = a +. b
	let parse = Parser.parse
end

module Myparser : PARSER =
struct
	let parse = float_of_string
end

module Mystringies = Stringies (Myparser)

open Mystringies

let ola = add (make 1.0) (make 2.0);;
let ola = add (make 1.0) 2.0;; (* Error *)
_________________________________________________________


Thanks for your time!
Cheers,
Dario Teixeira




      __________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html


  reply	other threads:[~2008-06-25 16:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-25 14:26 Dario Teixeira
2008-06-25 15:02 ` [Caml-list] " Jacques Carette
2008-06-25 16:29   ` Dario Teixeira [this message]
2008-06-26 21:41     ` Dario Teixeira
2008-06-27 20:35       ` Dario Teixeira

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=522359.38196.qm@web54605.mail.re2.yahoo.com \
    --to=darioteixeira@yahoo.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=carette@mcmaster.ca \
    /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).