Author: Eiko

Time: 2024-10-14 22:02:56 - 2024-10-14 22:04:03 (UTC)

There are some magical identity functions in the GHC.Magic module.

inline

inline will tell the compiler try to inline the function, but its definition need to be visible to the compiler (in the same module or have INLINE or INLINABLE pragma).

noinline

does the reverse to inline.

lazy

I don’t quite understand this function.

oneShot

It will tell the compiler the function will only be used at most once.

  • might be useful for improving the performance of code in continuation passing style.

  • It can cause the code that would otherwise be shared to be re-evaluated everytime they are used, otherwise safe.

  • This feature might be useful as well (although for some dirty purposes) use with unsafePerformIO to get random numbers in pure functions, and prevent sharing.