caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Walter Cazzola <cazzola@dico.unimi.it>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Subject: Re: [Caml-list] still silly issues on polymorphic types
Date: Thu, 29 Sep 2011 12:27:13 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LFD.2.00.1109291220120.4431@surtur.dico.unimi.it> (raw)
In-Reply-To: <266E7048-C3BB-4B9E-9760-9D52993A1C86@math.nagoya-u.ac.jp>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1444 bytes --]

Hi all,

On Wed, 28 Sep 2011, Jacques Garrigue wrote:

> On 2011/09/28, at 5:22, Walter Cazzola wrote:
>
>> I still have one problem: how can I assign to a the type 'a list? by
>> using «type a= 'a list» I get
>>
>>  Error: Unbound type parameter 'a
>
> Same thing: you need to make explicit the contents of the list.
> So this can be type a = int list.
> On the other hand if you are trying to refine the signature, you
> can also write
>  type t
>  type a = t list
> keeping t abstract.

thanks for the explanation but I'm still unable to match the 2 types (I
have attached the code again). I get this message:
     # module M0 = Continuation(StringConcat);;
     Error: Signature mismatch:
            Modules do not match:
              sig
                type t = StringConcat.t
                type a = t list
                and b = t
                and c = t list
                val op : 'a -> 'a list -> 'a list
                val init : 'a list
              end
            is not included in
              OpVarADT.OpVarADT
            Values do not match:
              val op : 'a -> 'a list -> 'a list
            is not included in
              val op : a -> b -> c

I have also tried to set the abstract type t to string butwithout any
luck.

     # module M0 = Continuation(StringConcat with StringConcat.t = string) ;;
     Error: Syntax error

I feel myself quite dumb but I can't figure out how to fix it.

Walter

-- 

[-- Attachment #2: Type: TEXT/PLAIN, Size: 182 bytes --]

module Continuation (OP : OpVarADT.OpVarADT) = 
  struct
    let arg x = fun y continuation -> continuation (OP.op x y) ;;
    let stop x = x;;
    let f g = g OP.init;;
  end

[-- Attachment #3: Type: TEXT/PLAIN, Size: 101 bytes --]

module type OpVarADT = 
 sig
   type a and b and c
   val op: a -> b -> c
   val init : c
 end

[-- Attachment #4: Type: TEXT/PLAIN, Size: 137 bytes --]

module StringConcat = struct
  type t
  type a=t list and b=t and c=t list
  let op = fun x y -> y @ [x] ;;
  let init = [] ;;
end

      parent reply	other threads:[~2011-09-29 10:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-27 11:46 Walter Cazzola
2011-09-27 12:57 ` Christophe Papazian
2011-09-27 13:49   ` Walter Cazzola
2011-09-27 15:26     ` Christophe Papazian
2011-09-27 18:43       ` Walter Cazzola
2011-09-27 19:25         ` Thibault Suzanne
2011-09-27 13:16 ` Jacques Garrigue
2011-09-27 13:58   ` Walter Cazzola
2011-09-27 19:45     ` Pierre Chopin
2011-09-27 20:22       ` Walter Cazzola
2011-09-27 23:58         ` Jacques Garrigue
     [not found]         ` <266E7048-C3BB-4B9E-9760-9D52993A1C86@math.nagoya-u.ac.jp>
2011-09-29 10:27           ` Walter Cazzola [this message]

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=alpine.LFD.2.00.1109291220120.4431@surtur.dico.unimi.it \
    --to=cazzola@dico.unimi.it \
    --cc=garrigue@math.nagoya-u.ac.jp \
    /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).