There is no such thing as a null function. A function in Haskell has exactly one argument and is always of type ... -> ... sayHello - value - a Int - but not a function. See this article for more details.
Warranty: No, you do not have any warranty. The Haskell report states that Haskell is not strict - so you know what value will ultimately lead to a decrease, but not to any specific evaluation strategy. The GHC pricing strategy usually uses lazy pricing , that is, a lax pricing with sharing, but it doesnβt give any serious guarantees about this - the optimizer can shuffle your code so that things are priced more than once.
There are also various exceptions - for example, foo :: Num a => a is polymorphic, so it probably won't be shared (it is compiled for the actual function). Sometimes a pure value can be evaluated by more than one thread at a time (this will not happen in this case, because unsafePerformIO explicitly uses noDuplicate to avoid this). Therefore, when you program, you can usually expect laziness, but if you need any guarantees, you need to be very careful. The report itself will not give you anything about how your program is rated.
unsafePerformIO gives you even less options for guarantees, of course. There is a reason that he called "unsafe."
shachaf
source share