I am trying to make a simple function to return a centered line of text in Haskell, but I am having trouble finding how many indents to insert in either direction. I have it:
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 (mostly) convert from Double (I think) to Int?
source
share