Help

Juan M. Duran juan@inf.ufpr.br
Tue, 26 Feb 2002 11:51:15 -0300 (BRT)


The problem is fixed.

I fixed it using the do notation as Rijk said, it worked perfectly.
Now I got two more problems:
1) Should I use the do notation in order to write this result (type IO
[[Float]]) to a file? How?
2) The Glasglow compiler doesn let me compile one library because I use
the function readFloat (declare in the Prelude of Hugs 98), but Hugs lets
me, why?

Thanks


On Mon, 25 Feb 2002, Keith Wansbrough wrote:

> > I thing that wont works, look:
> >  contents :: IO [Char]
> > 
> >  parser :: Integral a => [Char] -> [a]
> > 
> >  control :: [Float] -> [[Float]]
> > 
> >  The two problems are:
> >        1) The input of parser. Doesnt match with the type of input
> >        2) The input of control (or the output of parser). Doesn match
> >  with the type of the next function.
> 
> The "do" notation used by Rijk fixes the first problem; you should try it.
> 
> For the second problem, you want to convert an Integral to a Float - but are you sure?  Integers aren't floating point numbers!
> 
> If you are sure, then do something like
> 
>  main =
>       do {
>           contents <- input "twoboxes.dat"
>           return (control (map fromInteger (parser contents)))
>       }
> 
> fromInteger has the type Num a => Integer -> a, and since Num Float and Integral Integer, all your type constraints will be satisfied.
> 
> HTH.
> 
> --KW 8-)
> -- 
> Keith Wansbrough <kw217@cl.cam.ac.uk>
> http://www.cl.cam.ac.uk/users/kw217/
> University of Cambridge Computer Laboratory.
> 
>