#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2010
    Posts
    51
    Rep Power
    5

    Unhappy Displaying result of a function using haskell


    I have to do an assignment using the IO function in haskell which takes 2 float values and 1 boolean value. The boolean value is then used to decide upon a 3rd float value and the 3 float values are then entered into a function which needs to be output to the screen. I have the result as a float.
    Right now, im using the GHCi environment and it doesn't want to compile the following line:

    Code:
    print ("The price of your pizza is: " ++ pizzaPrice);
    giving me the compiler error message shown in the attached picture



    Can anyone give me a fix for this line or even suggest a better way of displaying the result of our function!!
  2. #2
  3. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,008
    Rep Power
    2791
    Post the rest of the code, please.
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2010
    Posts
    51
    Rep Power
    5
    Originally Posted by Winters
    Post the rest of the code, please.
    it doesn't matter now, but if you could still help me, i need to round the result of my function to 2 decimal places....I've tried looking for roundTo but it doesn't seem to want to do it.
  6. #4
  7. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,008
    Rep Power
    2791
    Haskell does not consider that to be rounding but converting from a float to a double. There is a discussion and solution here: http://www.cse.unsw.edu.au/~dons/has.../msg06700.html
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.

IMN logo majestic logo threadwatch logo seochat tools logo