Sto cercando di fare una semplice funzione per restituire una stringa di testo centrata in Haskell, ma sto avendo problemi a trovare solo quanto padding inserire da entrambi i lati. Ho questo:Conversione tra i tipi in Haskell
center padLength string = round ((padLength - (length string))/2)
che dà il seguente errore:
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)
Come posso (in pratica) la conversione da una doppia (credo) a un Int?
Perché è necessario il '? Sono un po 'nuovo per Haskell –
Ho aggiunto questa informazione alla mia risposta :) – ehird