私は定義しようとしています:変換整数
square :: Integer -> Integer
square = round . (** 2)
を、私は取得しています:
<interactive>:9:9: error:
• No instance for (RealFrac Integer) arising from a use of ‘round’
• In the first argument of ‘(.)’, namely ‘round’
In the expression: round . (** 2)
In an equation for ‘square’: square = round . (** 2)
<interactive>:9:18: error:
• No instance for (Floating Integer)
arising from an operator section
• In the second argument of ‘(.)’, namely ‘(** 2)’
In the expression: round . (** 2)
In an equation for ‘square’: square = round . (** 2)
が、私はまだこの言語で新しいですし、私はのインスタンスを変換することができないように見えます整数に浮動する。誰も私がそうする方法を知っていますか?
ことがありますluquiの答えがAlecの答えに対するコメントに凝縮されていたかどうかは議論の余地がありますが、これは確かにluquiの答えに対するコメントであった可能性があります。 – chepner