
On Wed, 20 Jun 2007, Brent Yorgey wrote:
That's a good idea too, perhaps I will do that. This would be a good thing to have on the wiki since it's clearly an issue that people learning Haskell struggle with (I certainly did). I also want to make clear, though, that I certainly appreciate the reasons for strongly typed numbers. I am not trying to make Haskell closer to Perl in general (God forbid!), or in any way advocate for doing away with strongly typed numbers, but only to create a library for working more conveniently with numeric types in small programs where the typing is not as important. To give a couple quick examples, based on what I have already implemented:
*EasyNum> 1 / 3 0.3333333333333333 *EasyNum> 1 / 3 :: EasyNum 1/3 *EasyNum> 1 / floor pi
<interactive>:1:4: Ambiguous type variable `t' in the constraints: `Integral t' arising from use of `floor' at <interactive>:1:4-11 `Fractional t' arising from use of `/' at <interactive>:1:0-11 Probable fix: add a type signature that fixes these type variable(s) *EasyNum> 1 / floor pi :: EasyNum 1/3
How about 1 % floor pi ? Already two examples for the Wiki which I used to start the Wiki article: http://www.haskell.org/haskellwiki/Generic_numeric_type