Why Does Integer Arithmetic in Haskell Seem Inconsistent?

AI Thread Summary
The discussion revolves around the interpretation of expressions in Haskell's Hugs environment, specifically in Haskell98 mode. The expression "div -6 4" results in an error due to type inference issues, indicating that Hugs cannot determine the appropriate numeric instance for the expression. In contrast, "div (-6) 4" correctly evaluates to -2, while the expression "-6 `div` 4" evaluates to -1. The key takeaway is that the operator `div` is right-associative, leading to the interpretation of "-6 `div` 4" as "-(6 `div` 4)", which clarifies the discrepancies in results.
gnome
Messages
1,031
Reaction score
1
Can anybody explain what appear to be discrepancies in the way the following expressions are interpreted by Hugs (Haskell98 mode) ?

Code:
Main> div -6 4
ERROR - Cannot infer instance
*** Instance   : Num (b -> a -> a -> a)
*** Expression : div - fromInt 6 4

Main> div (-6) 4
-2
Main> -6 `div` 4
-1
Main> (-6) `div` 4
-2
 
Computer science news on Phys.org
Never mind.

I guess it must be right-associative, so -6 `div` 4 is interpreted as -(6 `div` 4).
 
This week, I saw a documentary done by the French called Les sacrifiés de l'IA, which was presented by a Canadian show Enquête. If you understand French I recommend it. Very eye-opening. I found a similar documentary in English called The Human Cost of AI: Data workers in the Global South. There is also an interview with Milagros Miceli (appearing in both documentaries) on Youtube: I also found a powerpoint presentation by the economist Uma Rani (appearing in the French documentary), AI...
Thread 'Urgent: Physically repair - or bypass - power button on Asus laptop'
Asus Vivobook S14 flip. The power button is wrecked. Unable to turn it on AT ALL. We can get into how and why it got wrecked later, but suffice to say a kitchen knife was involved: These buttons do want to NOT come off, not like other lappies, where they can snap in and out. And they sure don't go back on. So, in the absence of a longer-term solution that might involve a replacement, is there any way I can activate the power button, like with a paperclip or wire or something? It looks...
Back
Top