
Hi beginners. Is there a way to get the prelude functions to use Integer by default rather than Int? I often have issues with Ints silently overflowing silently, but don't often have speed issues. Somehow I don't think that this is possible, but... Maybe?

Hello Lyndon,
it seems to me that Integer /is/ the default. Probably you're unifying
with some Int, for example when using functions like 'take' or 'length':
length :: [a] -> Int
take :: Int -> [a] -> [a]
Greets,
Ertugrul
Lyndon Maydwell
Hi beginners.
Is there a way to get the prelude functions to use Integer by default rather than Int?
I often have issues with Ints silently overflowing silently, but don't often have speed issues.
Somehow I don't think that this is possible, but... Maybe?
-- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/

And for those functions there are often generic counterparts defined in the
List module eg genericLength that take Integral types.
On 23 June 2010 15:52, Ertugrul Soeylemez
Hello Lyndon,
it seems to me that Integer /is/ the default. Probably you're unifying with some Int, for example when using functions like 'take' or 'length':
length :: [a] -> Int take :: Int -> [a] -> [a]
Greets, Ertugrul
Lyndon Maydwell
wrote: Hi beginners.
Is there a way to get the prelude functions to use Integer by default rather than Int?
I often have issues with Ints silently overflowing silently, but don't often have speed issues.
Somehow I don't think that this is possible, but... Maybe?
-- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Ah, that's probably it. I suppose there's no way of making the overflow throw an exception without sacrificing significant performance.

"Ertugrul" == Ertugrul Soeylemez
writes:
Ertugrul> -- nightmare = unsafePerformIO (getWrongWife >>= sex) I can't work out the signature for nightmare (in your signature). :-) -- Colin Adams Preston Lancashire () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments

On Wednesday 23 June 2010 18:08:18, Colin Paul Adams wrote:
"Ertugrul" == Ertugrul Soeylemez
writes: Ertugrul> -- nightmare = unsafePerformIO (getWrongWife >>= sex)
I can't work out the signature for nightmare (in your signature).
:-)
My guess: getWrongWife :: IO Partner sex :: Partner -> IO Offspring

"Daniel" == Daniel Fischer
writes:
Daniel> On Wednesday 23 June 2010 18:08:18, Colin Paul Adams wrote:
>> >>>>> "Ertugrul" == Ertugrul Soeylemez

On Wed, Jun 23, 2010 at 05:20:16PM +0100, Colin Paul Adams wrote:
"Daniel" == Daniel Fischer
writes: Daniel> On Wednesday 23 June 2010 18:08:18, Colin Paul Adams wrote: >> >>>>> "Ertugrul" == Ertugrul Soeylemez
writes: >> Ertugrul> -- nightmare = unsafePerformIO (getWrongWife >>= sex) >> >> I can't work out the signature for nightmare (in your signature). >> >> :-) Daniel> My guess:
Daniel> getWrongWife :: IO Partner sex :: Partner -> IO Offspring
So
nightmare :: Offspring ?
I guess it would be better to have sex :: Partner -> IO (Maybe Offspring) or, if you are lucky/unlucky: sex :: Partner -> IO [Offspring] -- Felipe.

"Patrick" == Patrick LeBoutillier
writes:
>>> >>> So >>> >>> nightmare :: Offspring ? >> If you make Patrick> sex :: Partner -> IO [STD] Patrick> then perhaps Patrick> nightmare :: [STD] Patrick> becomes more universal... What's an STD? -- Colin Adams Preston Lancashire () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments

On Wednesday 23 June 2010 19:01:21, Colin Paul Adams wrote:
"Patrick" == Patrick LeBoutillier
writes: >>> So >>> >>> nightmare :: Offspring ? If you make
Patrick> sex :: Partner -> IO [STD]
Patrick> then perhaps
Patrick> nightmare :: [STD]
Patrick> becomes more universal...
What's an STD?
Sexually transmitted disease

Daniel Fischer
On Wednesday 23 June 2010 19:01:21, Colin Paul Adams wrote:
> "Patrick" == Patrick LeBoutillier
writes: >>> So >>> >>> nightmare :: Offspring ? If you make
Patrick> sex :: Partner -> IO [STD]
Patrick> then perhaps
Patrick> nightmare :: [STD]
Patrick> becomes more universal...
What's an STD?
Sexually transmitted disease
Anyway, don't perform IO unsafely. You might regret it. Sex is another form of -- well -- input and output. Here are the types: getWrongWife :: IO BadWife sex :: F___able a => a -> IO (MVar Offspring, Set Disease) Of course you don't get offspring, if you don't "take" it. Greets, Ertugrul -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/

On Wed, Jun 23, 2010 at 09:38:24PM +0800, Lyndon Maydwell wrote:
Is there a way to get the prelude functions to use Integer by default rather than Int?
In general, I think it is cleaner to use explicit type signatures instead of defaulting. Running GHC with -Wall will warn you whenever you default to something. Cheers, -- Felipe.

On Wed, 2010-06-23 at 11:51 -0300, Felipe Lessa wrote:
On Wed, Jun 23, 2010 at 09:38:24PM +0800, Lyndon Maydwell wrote:
Is there a way to get the prelude functions to use Integer by default rather than Int?
In general, I think it is cleaner to use explicit type signatures instead of defaulting. Running GHC with -Wall will warn you whenever you default to something.
Cheers,
-- Felipe.
Also it helps a lot tracking type errors (and other errors are nearly non-existing in Haskell ;) ). Regards
participants (8)
-
Benjamin Edwards
-
Colin Paul Adams
-
Daniel Fischer
-
Ertugrul Soeylemez
-
Felipe Lessa
-
Lyndon Maydwell
-
Maciej Piechotka
-
Patrick LeBoutillier