* [Caml-list] A weird typing error [not found] <CANcqPu6B1DAOQ184U5t+wDwwQX=vFguQn0ipTGwvrZ18Hf3r3g@mail.gmail.com> @ 2012-05-24 17:55 ` bob zhang 2012-05-24 22:17 ` Philippe Wang 0 siblings, 1 reply; 3+ messages in thread From: bob zhang @ 2012-05-24 17:55 UTC (permalink / raw) To: Caml List [-- Attachment #1.1: Type: text/plain, Size: 228 bytes --] Hi, list I came across a weird type error. The error message is "Error: The implementation type_error_ppo.ml does not match the interface (inferred signature):" I attached the file Many thanks -- -- Bob [-- Attachment #1.2: Type: text/html, Size: 415 bytes --] [-- Attachment #2: type_error_ppo.ml --] [-- Type: application/octet-stream, Size: 1324 bytes --] type 'a m_list = | M_nil | M_cons of 'a * 'a m_list type 'a twice = 'a type 'a tree = | Leaf | Node of ('a tree) m_list * (('a tree) m_list) twice * 'a class base = object method int : int -> int = fun x -> x method float : float -> float = fun x -> x method string : string -> string = fun x -> x end module EQ = struct class map = object ((self : 'self_type)) inherit base method unknown : 'a. 'a -> 'a = fun x -> x method tree : 'a0 'b0. ('self_type -> 'a0 -> 'b0) -> 'a0 tree -> 'b0 tree = fun mf_a -> function | Leaf -> Leaf | Node (a0, a1, a2) -> Node ((self#m_list (fun self -> self#tree mf_a) a0), (self#twice (fun self -> self#m_list (fun self -> self#tree mf_a)) a1), (mf_a self a2)) method twice : 'a0 'b0. ('self_type -> 'a0 -> 'b0) -> 'a0 twice -> 'b0 twice = fun mf_a -> mf_a self method m_list : 'a0 'b0. ('self_type -> 'a0 -> 'b0) -> 'a0 m_list -> 'b0 m_list = fun mf_a -> function | M_nil -> M_nil | M_cons (a0, a1) -> M_cons ((mf_a self a0), (self#m_list mf_a a1)) end end ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] A weird typing error 2012-05-24 17:55 ` [Caml-list] A weird typing error bob zhang @ 2012-05-24 22:17 ` Philippe Wang 2012-05-25 5:47 ` Jonathan Protzenko 0 siblings, 1 reply; 3+ messages in thread From: Philippe Wang @ 2012-05-24 22:17 UTC (permalink / raw) To: bob zhang; +Cc: Caml List Hi, I re-wrote your program, twice. First time: The actual problem was submerged... so I removed the irrelevant code. It became: type 'a twice = 'a class map = object ((self : 'self_type)) method twice : 'a0 'b0. ('self_type -> 'a0 -> 'b0) -> 'a0 twice -> 'b0 twice = fun mf_a -> mf_a self end => ocamlc points a surprising error at line 1. I don't quite understand... Second time: well, line 1 seems fine to me. I added some missing parameters. It became: type 'a twice = 'a class map = object ((self : 's)) method twice : 'a0 'b0. ('s -> 'a0 -> 'b0) -> 'a0 twice -> 'b0 twice = fun mf_a x -> mf_a (self : 's) (x: 'a0 twice) end => ocamlc points the same error, but at line 5, which is a lot better, much less weird... Well, kind of same error: the weird (buggy) part of the message is removed, the important part is kept. And now... I just don't know why it doesn't type-check. All I have left to say is that I hate encoding data into type names. It's fun when it works. It's hell otherwise. I'm curious to understand the solution of this weird problem, if someone unravels it. Cheers. Philippe Wang On Thu, May 24, 2012 at 7:55 PM, bob zhang <bobzhang1988@gmail.com> wrote: > > Hi, list > I came across a weird type error. > The error message is "Error: The implementation type_error_ppo.ml > does not match the interface (inferred signature):" > I attached the file > Many thanks > > -- > -- Bob ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] A weird typing error 2012-05-24 22:17 ` Philippe Wang @ 2012-05-25 5:47 ` Jonathan Protzenko 0 siblings, 0 replies; 3+ messages in thread From: Jonathan Protzenko @ 2012-05-25 5:47 UTC (permalink / raw) To: Philippe Wang; +Cc: Caml List, bob zhang FWIW it type-checks on a recent trunk build. jonathan On Fri 25 May 2012 12:17:33 AM CEST, Philippe Wang wrote: > Hi, > > I re-wrote your program, twice. > > First time: The actual problem was submerged... so I removed the > irrelevant code. > It became: > > type 'a twice = 'a > class map = object ((self : 'self_type)) > method twice : 'a0 'b0. ('self_type -> 'a0 -> 'b0) -> 'a0 twice -> 'b0 twice = > fun mf_a -> mf_a self > end > > => ocamlc points a surprising error at line 1. I don't quite understand... > > Second time: well, line 1 seems fine to me. I added some missing parameters. > It became: > > type 'a twice = 'a > class map = > object ((self : 's)) > method twice : 'a0 'b0. ('s -> 'a0 -> 'b0) -> 'a0 twice -> 'b0 twice = > fun mf_a x -> mf_a (self : 's) (x: 'a0 twice) > end > > => ocamlc points the same error, but at line 5, which is a lot better, > much less weird... > Well, kind of same error: the weird (buggy) part of the message is > removed, the important part is kept. > > > And now... I just don't know why it doesn't type-check. All I have > left to say is that I hate encoding data into type names. It's fun > when it works. It's hell otherwise. > > I'm curious to understand the solution of this weird problem, if > someone unravels it. > > Cheers. > Philippe Wang > > > > On Thu, May 24, 2012 at 7:55 PM, bob zhang <bobzhang1988@gmail.com> wrote: >> >> Hi, list >> I came across a weird type error. >> The error message is "Error: The implementation type_error_ppo.ml >> does not match the interface (inferred signature):" >> I attached the file >> Many thanks >> >> -- >> -- Bob > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-05-25 5:47 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <CANcqPu6B1DAOQ184U5t+wDwwQX=vFguQn0ipTGwvrZ18Hf3r3g@mail.gmail.com> 2012-05-24 17:55 ` [Caml-list] A weird typing error bob zhang 2012-05-24 22:17 ` Philippe Wang 2012-05-25 5:47 ` Jonathan Protzenko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox