English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    
Browse thread
[Caml-list] Weird typing problem
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Ching-Tsun Chou <ctchou@m...>
Subject: [Caml-list] Weird typing problem

Consider a file "zzz.ml" that contains only two lines:

let (<<) f g x = f (g (x))
let list_last = List.hd << List.rev

Now, if I load the file interactively, I get:

<unix> ocaml
        Objective Caml version 3.04

# #use "zzz.ml" ;;
val ( << ) : ('a -> 'b) -> ('c -> 'a) -> 'c -> 'b = <fun>
val list_last : '_a list -> '_a = <fun>
# 

However, if I try to compile it, I get:

<unix> ocamlc -c zzz.ml
File "zzz.ml", line 2, characters 16-35:
The type of this expression, '_a list -> '_a,
contains type variables that cannot be generalized


Why so?

- Ching Tsun
-------------------
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