* empty type
@ 2007-02-19 13:47 Fernando Alegre
2007-02-19 14:14 ` [Caml-list] " skaller
2007-02-19 22:36 ` Richard Jones
0 siblings, 2 replies; 7+ messages in thread
From: Fernando Alegre @ 2007-02-19 13:47 UTC (permalink / raw)
To: caml-list
Hi,
I think this is a bug, but I'm not sure. I mistakenly defined type e using
Haskell notation, and it was accepted. However, it shadowed the unit type.
Can someone confirm whether this should be acceptable or not?
Thanks.
Objective Caml version 3.09.2
# type e = ();;
type e = ()
# type t = A of e | B of unit;;
type t = A of e | B of unit
# A();;
- : t = A ()
# B();;
This expression has type e but is here used with type unit
Fernando
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] empty type
2007-02-19 13:47 empty type Fernando Alegre
@ 2007-02-19 14:14 ` skaller
2007-02-19 14:23 ` RE : " Mathias Kende
2007-02-19 22:36 ` Richard Jones
1 sibling, 1 reply; 7+ messages in thread
From: skaller @ 2007-02-19 14:14 UTC (permalink / raw)
To: Fernando Alegre; +Cc: caml-list
On Mon, 2007-02-19 at 08:47 -0500, Fernando Alegre wrote:
> Hi,
>
> I think this is a bug, but I'm not sure. I mistakenly defined type e using
> Haskell notation, and it was accepted. However, it shadowed the unit type.
> Can someone confirm whether this should be acceptable or not?
>
> Thanks.
>
> Objective Caml version 3.09.2
>
> # type e = ();;
What? That sure looks like a bug. () is a value of type unit ..
it isn't a type.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE : [Caml-list] empty type
2007-02-19 14:14 ` [Caml-list] " skaller
@ 2007-02-19 14:23 ` Mathias Kende
2007-02-19 16:03 ` Andrej Bauer
0 siblings, 1 reply; 7+ messages in thread
From: Mathias Kende @ 2007-02-19 14:23 UTC (permalink / raw)
Cc: caml-list
>What? That sure looks like a bug. () is a value of type unit ..
>it isn't a type.
It's not a type, but just a valid name for a constructor that can be
redefined if necessary (although one surely does not want to do so).
Mathias Kende
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: RE : [Caml-list] empty type
2007-02-19 14:23 ` RE : " Mathias Kende
@ 2007-02-19 16:03 ` Andrej Bauer
2007-02-19 20:51 ` Fernando Alegre
2007-02-20 9:05 ` Bruno De Fraine
0 siblings, 2 replies; 7+ messages in thread
From: Andrej Bauer @ 2007-02-19 16:03 UTC (permalink / raw)
To: caml-list
Mathias Kende wrote:
> It's not a type, but just a valid name for a constructor that can be
> redefined if necessary (although one surely does not want to do so).
Way cool:
# type t = () of int * int ;;
type t = () of int * int
# () (3, 4) ;;
- : t = () (3, 4)
Andrej
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: RE : [Caml-list] empty type
2007-02-19 16:03 ` Andrej Bauer
@ 2007-02-19 20:51 ` Fernando Alegre
2007-02-20 9:05 ` Bruno De Fraine
1 sibling, 0 replies; 7+ messages in thread
From: Fernando Alegre @ 2007-02-19 20:51 UTC (permalink / raw)
To: Andrej.Bauer; +Cc: caml-list
How about this:
# type t = () of int;;
type t = () of int
# begin end;;
The constructor () expects 1 argument(s),
but is here applied to 0 argument(s)
Fernando
On Mon, Feb 19, 2007 at 05:03:58PM +0100, Andrej Bauer wrote:
> Mathias Kende wrote:
> >It's not a type, but just a valid name for a constructor that can be
> >redefined if necessary (although one surely does not want to do so).
>
> Way cool:
>
> # type t = () of int * int ;;
> type t = () of int * int
> # () (3, 4) ;;
> - : t = () (3, 4)
>
> Andrej
>
> _______________________________________________
> 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: RE : [Caml-list] empty type
2007-02-19 16:03 ` Andrej Bauer
2007-02-19 20:51 ` Fernando Alegre
@ 2007-02-20 9:05 ` Bruno De Fraine
1 sibling, 0 replies; 7+ messages in thread
From: Bruno De Fraine @ 2007-02-20 9:05 UTC (permalink / raw)
To: ocaml ml
On 19 Feb 2007, at 17:03, Andrej Bauer wrote:
> Mathias Kende wrote:
>> It's not a type, but just a valid name for a constructor that can be
>> redefined if necessary (although one surely does not want to do so).
>
> Way cool:
>
> # type t = () of int * int ;;
> type t = () of int * int
> # () (3, 4) ;;
> - : t = () (3, 4)
If you redefine :: you get an infix constructor:
# type expr = Num of int | :: of expr * expr ;;
type expr = Num of int | :: of expr * expr
# Num 1 :: Num 2 :: Num 3 ;;
- : expr = :: (Num 1, :: (Num 2, Num 3))
# :: (Num 2, Num 3) ;;
Syntax error
# let a :: b = Num 1 :: Num 2 :: Num 3 ;;
Warning P: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
Num _
val a : expr = Num 1
val b : expr = :: (Num 2, Num 3)
Bruno
--
Bruno De Fraine
Vrije Universiteit Brussel
Faculty of Applied Sciences, INFO - SSEL
Room 4K208, Pleinlaan 2, B-1050 Brussels
tel: +32 (0)2 629 29 75
fax: +32 (0)2 629 28 70
e-mail: Bruno.De.Fraine@vub.ac.be
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] empty type
2007-02-19 13:47 empty type Fernando Alegre
2007-02-19 14:14 ` [Caml-list] " skaller
@ 2007-02-19 22:36 ` Richard Jones
1 sibling, 0 replies; 7+ messages in thread
From: Richard Jones @ 2007-02-19 22:36 UTC (permalink / raw)
To: Fernando Alegre; +Cc: caml-list
On Mon, Feb 19, 2007 at 08:47:38AM -0500, Fernando Alegre wrote:
>
> Hi,
>
> I think this is a bug, but I'm not sure. I mistakenly defined type e using
> Haskell notation, and it was accepted. However, it shadowed the unit type.
> Can someone confirm whether this should be acceptable or not?
It tripped us up before:
http://caml.inria.fr/pub/ml-archives/caml-list/2005/06/e1a4be2ebe9ced1cbdc06979a7e8ae17.en.html
Rich.
--
Richard Jones
Red Hat UK Limited
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-02-20 9:05 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-19 13:47 empty type Fernando Alegre
2007-02-19 14:14 ` [Caml-list] " skaller
2007-02-19 14:23 ` RE : " Mathias Kende
2007-02-19 16:03 ` Andrej Bauer
2007-02-19 20:51 ` Fernando Alegre
2007-02-20 9:05 ` Bruno De Fraine
2007-02-19 22:36 ` Richard Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox