caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* type t = ()
@ 2005-06-09 21:22 Richard Jones
  2005-06-09 22:05 ` Vincenzo Ciancia
  2005-06-09 23:43 ` [Caml-list] " Jonathan Bryant
  0 siblings, 2 replies; 7+ messages in thread
From: Richard Jones @ 2005-06-09 21:22 UTC (permalink / raw)
  To: caml-list

I had a program where a type was accidentally defined as (), and the
error messages confused me for ages until I worked out what was going
on ...

$ ocaml
        Objective Caml version 3.08.3

# type dummy = ();;
type dummy = ()
# let () = Printf.printf "hello";;
This expression has type unit but is here used with type dummy

Rich.

-- 
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: type t = ()
  2005-06-09 21:22 type t = () Richard Jones
@ 2005-06-09 22:05 ` Vincenzo Ciancia
  2005-06-10 12:56   ` [Caml-list] " Wolfgang Lux
  2005-06-09 23:43 ` [Caml-list] " Jonathan Bryant
  1 sibling, 1 reply; 7+ messages in thread
From: Vincenzo Ciancia @ 2005-06-09 22:05 UTC (permalink / raw)
  To: caml-list

Richard Jones wrote:

> # type dummy = ();;
> type dummy = ()
> # let () = Printf.printf "hello";;
> This expression has type unit but is here used with type dummy
> 

It seems that the compiler accepted "()" as a type constructor, so now every
instance of "()" is the only constructor of type "dummy" e.g.

# type d = () of int;;
type d = () of int
# () 3;;
- : d = () 3

V.

-- 
Please note that I do not read the e-mail address used in the from field but
I read vincenzo_ml at yahoo dot it
Attenzione: non leggo l'indirizzo di posta usato nel campo from, ma leggo
vincenzo_ml at yahoo dot it



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] type t = ()
  2005-06-09 21:22 type t = () Richard Jones
  2005-06-09 22:05 ` Vincenzo Ciancia
@ 2005-06-09 23:43 ` Jonathan Bryant
  2005-06-10  7:55   ` Richard Jones
  1 sibling, 1 reply; 7+ messages in thread
From: Jonathan Bryant @ 2005-06-09 23:43 UTC (permalink / raw)
  To: caml-list

Is this a question or a brief rant...? :)

On Thu, 2005-06-09 at 17:22, Richard Jones wrote:
> I had a program where a type was accidentally defined as (), and the
> error messages confused me for ages until I worked out what was going
> on ...
> 
> $ ocaml
>         Objective Caml version 3.08.3
> 
> # type dummy = ();;
> type dummy = ()
> # let () = Printf.printf "hello";;
> This expression has type unit but is here used with type dummy
> 
> Rich.
> 
> -- 
> Richard Jones, CTO Merjis Ltd.
> Merjis - web marketing and technology - http://merjis.com
> Team Notepad - intranets and extranets for business - http://team-notepad.com
> 
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] type t = ()
  2005-06-09 23:43 ` [Caml-list] " Jonathan Bryant
@ 2005-06-10  7:55   ` Richard Jones
  2005-06-10 13:02     ` Florian Hars
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Jones @ 2005-06-10  7:55 UTC (permalink / raw)
  To: Jonathan Bryant; +Cc: caml-list

On Thu, Jun 09, 2005 at 07:43:44PM -0400, Jonathan Bryant wrote:
> Is this a question or a brief rant...? :)

Sort of a brief rant combined with a bug report :-)

Rich.

-- 
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Re: type t = ()
  2005-06-09 22:05 ` Vincenzo Ciancia
@ 2005-06-10 12:56   ` Wolfgang Lux
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Lux @ 2005-06-10 12:56 UTC (permalink / raw)
  To: Vincenzo Ciancia; +Cc: caml-list

Vincenzo Ciancia wrote:

> Richard Jones wrote:
>
>> # type dummy = ();;
>> type dummy = ()
>> # let () = Printf.printf "hello";;
>> This expression has type unit but is here used with type dummy
>>
>
> It seems that the compiler accepted "()" as a type constructor, so now 
> every
> instance of "()" is the only constructor of type "dummy" e.g.

Sorry for nitpicking, but in this case () is a *data* constructor.
I guess, Rich would have been more happy if OCaml did recognize ()
as a type constructor in this example.

However, I guess one cannot do much about this in OCaml since () is
a legitimate data constructor name. The problem really is that the
(O)Caml designers chose to overload the type keyword for defining
algebraic data types as well as type abbreviations. Compare with SML
and Haskell where different keywords are used.

Regards
Wolfgang


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] type t = ()
  2005-06-10  7:55   ` Richard Jones
@ 2005-06-10 13:02     ` Florian Hars
  2005-06-10 22:12       ` Jon Harrop
  0 siblings, 1 reply; 7+ messages in thread
From: Florian Hars @ 2005-06-10 13:02 UTC (permalink / raw)
  To: Richard Jones; +Cc: Jonathan Bryant, caml-list

Richard Jones wrote:
> Sort of a brief rant combined with a bug report :-)

But the bug is in the same class as:

# let (-) = ( * );;
val ( - ) : int -> int -> int = <fun>
# 1 + 2 - 3;;
- : int = 9

No?

Yours, Florian.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] type t = ()
  2005-06-10 13:02     ` Florian Hars
@ 2005-06-10 22:12       ` Jon Harrop
  0 siblings, 0 replies; 7+ messages in thread
From: Jon Harrop @ 2005-06-10 22:12 UTC (permalink / raw)
  To: caml-list

On Friday 10 June 2005 14:02, Florian Hars wrote:
> But the bug is in the same class as:
>
> # let (-) = ( * );;
> val ( - ) : int -> int -> int = <fun>
> # 1 + 2 - 3;;
> - : int = 9
>
> No?

Isn't that exactly what you'd expect?

  (1 + 2) * 3 = 9

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-06-10 22:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-09 21:22 type t = () Richard Jones
2005-06-09 22:05 ` Vincenzo Ciancia
2005-06-10 12:56   ` [Caml-list] " Wolfgang Lux
2005-06-09 23:43 ` [Caml-list] " Jonathan Bryant
2005-06-10  7:55   ` Richard Jones
2005-06-10 13:02     ` Florian Hars
2005-06-10 22:12       ` Jon Harrop

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).