Re: type error: converting input channel to string list

From: Pierre Weis (Pierre.Weis@inria.fr)
Date: Fri Mar 14 1997 - 19:20:16 MET


From: Pierre Weis <Pierre.Weis@inria.fr>
Message-Id: <199703141820.TAA04438@pauillac.inria.fr>
Subject: Re: type error: converting input channel to string list
In-Reply-To: <199703140125.TAA15399@kimbark.uchicago.edu> from Lyn A Headley at "Mar 13, 97 07:25:22 pm"
To: laheadle@midway.uchicago.edu (Lyn A Headley)
Date: Fri, 14 Mar 1997 19:20:16 +0100 (MET)

> let string_list_of_chann chann =
> let rec slof_aux (ch: in_channel) (l: string list) =
> try
> let readstr = input_line ch in
> slof_aux ch readstr::l
> with End_of_file -> l
> in slof_aux chann []
>
> and the error is:
>
> File "query.ml", line 11, characters 19-155:
> This expression has type in_channel -> string list -> string list
> but is here used with type in_channel -> string -> string
> make: *** [all] Error 2
>
>
> Is this a problem with relying on an exception to type a function?

No, your problem is just parsing: you should write

 slof_aux ch (readstr::l) instead of slof_aux ch readstr::l

since in Caml, function application binds tighter than operations,
that is, for all binary infix operator op

f x op z means (f x) op z

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:09 MET