* [Caml-list] [Q] explicit typing again
@ 2004-03-29 9:33 fis
2004-03-29 9:50 ` Jacques Garrigue
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: fis @ 2004-03-29 9:33 UTC (permalink / raw)
To: caml-list
hi,
sorry, but i am really enthusiastic about explicit typing. i will
probably start to annotate expressions like "3" soon... (-:
could anybody tell me how i get this one straight?
# let (a: int, b) = (1, 3) in a;;
# let (a, b) : int * int = (1, 3) in a;;
thanks a lot,
matthias
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] [Q] explicit typing again
2004-03-29 9:33 [Caml-list] [Q] explicit typing again fis
@ 2004-03-29 9:50 ` Jacques Garrigue
2004-03-29 9:51 ` Remi Vanicat
2004-03-29 9:53 ` Martin Jambon
2 siblings, 0 replies; 5+ messages in thread
From: Jacques Garrigue @ 2004-03-29 9:50 UTC (permalink / raw)
To: fis; +Cc: caml-list
From: fis@wiwi.hu-berlin.de
> could anybody tell me how i get this one straight?
>
> # let (a: int, b) = (1, 3) in a;;
> # let (a, b) : int * int = (1, 3) in a;;
# let (a : int), b = (1,3) in a;;
# let (a, b : int * int) = (1,3) in a;;
Pairs do not need parentheses.
Type annotations do (except when defining a single value).
Jacques Garrigue
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] [Q] explicit typing again
2004-03-29 9:33 [Caml-list] [Q] explicit typing again fis
2004-03-29 9:50 ` Jacques Garrigue
@ 2004-03-29 9:51 ` Remi Vanicat
2004-03-29 9:53 ` Martin Jambon
2 siblings, 0 replies; 5+ messages in thread
From: Remi Vanicat @ 2004-03-29 9:51 UTC (permalink / raw)
To: caml-list
fis@wiwi.hu-berlin.de writes:
> hi,
>
> sorry, but i am really enthusiastic about explicit typing. i will
> probably start to annotate expressions like "3" soon... (-:
>
> could anybody tell me how i get this one straight?
>
> # let (a: int, b) = (1, 3) in a;;
it is :
let ((a:int),b) = (1, 3) in a;;
> # let (a, b) : int * int = (1, 3) in a;;
there it is :
let ((a, b) : int * int) = (1, 3) in a;;
In fact, often it is enough to add some parenthesis around the
"value : type" to make the parser happy.
--
Rémi Vanicat
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] [Q] explicit typing again
2004-03-29 9:33 [Caml-list] [Q] explicit typing again fis
2004-03-29 9:50 ` Jacques Garrigue
2004-03-29 9:51 ` Remi Vanicat
@ 2004-03-29 9:53 ` Martin Jambon
2004-03-29 13:07 ` [Caml-list] Polymorphic Variant Error message (CVS version) skaller
2 siblings, 1 reply; 5+ messages in thread
From: Martin Jambon @ 2004-03-29 9:53 UTC (permalink / raw)
To: fis; +Cc: caml-list
On Mon, 29 Mar 2004 fis@wiwi.hu-berlin.de wrote:
> hi,
>
> sorry, but i am really enthusiastic about explicit typing. i will
> probably start to annotate expressions like "3" soon... (-:
>
> could anybody tell me how i get this one straight?
>
> # let (a: int, b) = (1, 3) in a;;
> # let (a, b) : int * int = (1, 3) in a;;
# let (a : int), b = 1, 2;;
val a : int = 1
val b : int = 2
# let (a, b : int * int) = 1, 2;;
val a : int = 1
val b : int = 2
You can add more ( ) around tuples, but here you don't really define
tuples.
In theory, you could find all this information here:
http://caml.inria.fr/ocaml/htmlman/manual008.html
Martin
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Caml-list] Polymorphic Variant Error message (CVS version)
2004-03-29 9:53 ` Martin Jambon
@ 2004-03-29 13:07 ` skaller
0 siblings, 0 replies; 5+ messages in thread
From: skaller @ 2004-03-29 13:07 UTC (permalink / raw)
To: caml-list
Consider:
--------------------------------------
# type t = [`A of t]
let rec f (x:t) = match x with
| `A y -> f y
| `B y -> f y
;;
Warning: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
`AnyExtraTag
Warning: this match case is unused.
type t = [ `A of t ]
val f : t -> 'a = <fun>
------------------------------------------
The first error message is a bit confusing.
There is indeed an extra tag `B in the match.
I think this kind of message only occurs where there
is a covariant type.
The confusion is: it says the pattern matching
is not exhaustive, but from the developers viewpoint
the opposite is true: the match is overconstrained,
rather than underconstrained. I guess the problem arises
becase the type of x is deduced from the match first,
before the annotation restricts it to type t.
Anyhow just curious exactly how this error arises.
--
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850,
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-03-29 13:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-29 9:33 [Caml-list] [Q] explicit typing again fis
2004-03-29 9:50 ` Jacques Garrigue
2004-03-29 9:51 ` Remi Vanicat
2004-03-29 9:53 ` Martin Jambon
2004-03-29 13:07 ` [Caml-list] Polymorphic Variant Error message (CVS version) skaller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox