* (old) camlp4 question @ 2007-04-11 10:59 Pietro Abate 2007-04-11 11:43 ` [Caml-list] " Nicolas Pouillard 0 siblings, 1 reply; 4+ messages in thread From: Pietro Abate @ 2007-04-11 10:59 UTC (permalink / raw) To: ocaml ml Hi all, I want to write a type like this in camlp4 : type ('a,'b) b = [ `T of 'b ] type a = ('b,int) b as 'b Suppose I have a list of ctyp [<:ctyp< 'b >>;<:ctyp< int >>; ... ] How can I write the type ('b,int) b as 'b ?? I've tried with <:ctyp< type a = b ($list:l$) as 'b >> but the result is incorrect ... what is the right syntax ? pietro -- ++ Blog: http://blog.rsise.anu.edu.au/?q=pietro ++ ++ "All great truths begin as blasphemies." -George Bernard Shaw ++ Please avoid sending me Word or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] (old) camlp4 question 2007-04-11 10:59 (old) camlp4 question Pietro Abate @ 2007-04-11 11:43 ` Nicolas Pouillard 2007-04-12 1:20 ` Pietro Abate 0 siblings, 1 reply; 4+ messages in thread From: Nicolas Pouillard @ 2007-04-11 11:43 UTC (permalink / raw) To: Pietro Abate, ocaml ml On 4/11/07, Pietro Abate <Pietro.Abate@anu.edu.au> wrote: > Hi all, > I want to write a type like this in camlp4 : > type ('a,'b) b = [ `T of 'b ] > type a = ('b,int) b as 'b > > Suppose I have a list of ctyp [<:ctyp< 'b >>;<:ctyp< int >>; ... ] > How can I write the type ('b,int) b as 'b ?? > > I've tried with <:ctyp< type a = b ($list:l$) as 'b >> but the result > is incorrect ... what is the right syntax ? > Two things: The `as' must be surrounded by parentheses (('b,int) b as 'b). And a type declaration is not a type, you can use a str_item or a sig_item. Here we go: <:str_item< type a = (b ($list:l$) as 'b) >>;; -- Nicolas Pouillard ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] (old) camlp4 question 2007-04-11 11:43 ` [Caml-list] " Nicolas Pouillard @ 2007-04-12 1:20 ` Pietro Abate 2007-04-12 7:06 ` Nicolas Pouillard 0 siblings, 1 reply; 4+ messages in thread From: Pietro Abate @ 2007-04-12 1:20 UTC (permalink / raw) To: ocaml ml On Wed, Apr 11, 2007 at 01:43:48PM +0200, Nicolas Pouillard wrote: > Two things: > The `as' must be surrounded by parentheses (('b,int) b as 'b). > And a type declaration is not a type, you can use a str_item or a sig_item. > Here we go: <:str_item< type a = (b ($list:l$) as 'b) >>;; Doesn't quite work for me... This is my usage pattern. I've a toplevel <:str_item< type $list:l$ >> where l is a list of ((_loc * string),(string * (bool * bool)) list, ctyp ,?? list) and ?? list is a list of something that I haven't figure out yet (the manual says <:str_item< type $list:sslt$ >>: type declaration). to write type a = (b ($list:l$) as 'b) , I've to give a list l of one element as ((_loc,"a"),[], <:ctyp< (b ($list:[<:ctyp< 'b >>,<:ctyp< int >>]$) as 'b) >>, []) My problem is to write the type (('b,int) b as 'b) as a ctyp . I want to write it in this way as both l and the list of type variables in (('b,int) b as 'b) are not fixed. Moreover types in <:str_item< type $list:l$ >> can be mutually recursive. thanks :) p -- ++ Blog: http://blog.rsise.anu.edu.au/?q=pietro ++ ++ "All great truths begin as blasphemies." -George Bernard Shaw ++ Please avoid sending me Word or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] (old) camlp4 question 2007-04-12 1:20 ` Pietro Abate @ 2007-04-12 7:06 ` Nicolas Pouillard 0 siblings, 0 replies; 4+ messages in thread From: Nicolas Pouillard @ 2007-04-12 7:06 UTC (permalink / raw) To: Pietro Abate, ocaml ml On 4/12/07, Pietro Abate <Pietro.Abate@anu.edu.au> wrote: > On Wed, Apr 11, 2007 at 01:43:48PM +0200, Nicolas Pouillard wrote: > > Two things: > > The `as' must be surrounded by parentheses (('b,int) b as 'b). > > And a type declaration is not a type, you can use a str_item or a sig_item. > > Here we go: <:str_item< type a = (b ($list:l$) as 'b) >>;; > > Doesn't quite work for me... This is my usage pattern. > > I've a toplevel <:str_item< type $list:l$ >> where l is a list of > ((_loc * string),(string * (bool * bool)) list, ctyp ,?? list) > and ?? list is a list of something that I haven't figure out yet (the > manual says <:str_item< type $list:sslt$ >>: type declaration). ?? is for constraints on type parameters (you can leave it empty) > to write type a = (b ($list:l$) as 'b) , I've to give a list l > of one element as > ((_loc,"a"),[], <:ctyp< (b ($list:[<:ctyp< 'b >>,<:ctyp< int >>]$) as 'b) >>, []) > > My problem is to write the type (('b,int) b as 'b) as a ctyp . Hum I see it's the type application that is like any other application in revised. int list -> list int (string, int) table -> table string int <:ctyp< (b 'b int as 'b) >> Regards, -- Nicolas Pouillard ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-04-12 7:06 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2007-04-11 10:59 (old) camlp4 question Pietro Abate 2007-04-11 11:43 ` [Caml-list] " Nicolas Pouillard 2007-04-12 1:20 ` Pietro Abate 2007-04-12 7:06 ` Nicolas Pouillard
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox