Help

Keith Wansbrough Keith.Wansbrough@cl.cam.ac.uk
Mon, 25 Feb 2002 18:01:59 +0000


> 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.