| Chris Smith 2006-06-27, 9:59 pm |
| Neelakantan Krishnaswami <neelk@cs.cmu.edu> wrote:
> For example, if I write the fold left function, and forget to pass it
> the tail of the list in the recursive call, it typechecks:
>
> let rec foldl f init list =
> match list with
> | [] -> init
> | x :: xs -> foldl (f x init) (* missing xs argument *)
>
> val fold : ('b -> ('c -> 'b list -> 'c as 'c) -> 'a as 'a) -> 'c
>
> I'd really prefer this to be a type error, because there actually is
> an error in this program!
Fortunately, though, type checking is done on whole programs rather than
individual routines, so that when you try to use the value from this,
you will get an error later. Yes, you would need to examine the type
inference for library routines, in order to prevent the unfortunate
occurrence that the "later" when you discover the error is after the
library has been shipped to your clients. :)
--
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation
|