I'm trying to make a simple function to return a centered string of text in Haskell, but I'm having trouble just finding how much padding to insert either side. I have this:
center padLength string = round ((padLength - (length string)) / 2)
Which gives the following error:
No instance for (Fractional Int)
arising from a use of '/'
Possible fix: add an instance declaration for (Fractional Int)
In the first argument of 'round', namely
'((padLength - (length string)) / 2)'
In the expression: round ((padLength - (length string)) / 2)
In an equation for `center':
center padLength string = round ((padLength - (length string)) / 2)
How can I (basically) convert from an Double (I think) to an Int?