
On Mar 29, 2021, at 3:36 AM, Antonio Regidor Garcia
wrote: succ n is n+1 but faster than the function (+).
Because 'succ' typically does bounds checks, while (+) (for Int) just does the underlying CPU instruction, that's not particularly plausible. Indeed running a test (100 million increments) suggests that (+) is noticeably cheaper: (1 +): MUT time 0.035s ( 0.035s elapsed) (succ): MUT time 0.134s ( 0.134s elapsed) The succ function is however safer against uncaught overflow: λ> succ False True λ> succ True *** Exception: Prelude.Enum.Bool.succ: bad argument If the datatype in question is not bounded (Double, Integer, ...) then succ performance is closer to that of (+). I see identical speeds for Double, but (GHC 8.10 on X86_64) succ seems slightly slower for Integer. -- Viktor.