5 ms·
> In Haskell, this type of integer can't get bigger than 2^31... It's platform-dependent h> finiteBitSize (0 :: Int) 64 > We could have used the type Int
by lelf 13y ago
> In Haskell, this type of integer can't get bigger than 2^31...
It's platform-dependent
h> finiteBitSize (0 :: Int)
64
> We could have used the type Integer instead- This type of integer grows "magically" and can hold any sized integer, no matter how big... but it's slower, so we used Int instead, since our numbers will never get that big.
Premature optimisation at its best.
- pogden 13y agoIn Haskell you can also use the Integral typeclass to make functions polymorphic to Int and Integer.
- lelf 13y agoAnd why would you do this in simple tutorial program? Anyway, you'd need Num.
- dfeltey 13y agoI don't know why anyone would use the Integral typeclass over just Int or Integer in a simple program like this, but you wouldn't need Num in addition to Integral, every instance of Integral must also be an instance of Real, and instances of Real must be instances of Num.
- deleted 13y ago[deleted]