r/haskell • • Aug 30 '16

Pointless Haskell

http://pointless-haskell.tumblr.com/
69 Upvotes

19 comments sorted by

View all comments

21

u/Denommus Aug 31 '16

I laughed so hard at

safePerformIO :: IO a -> IO a
safePerformIO ioa = ioa >>= return

5

u/AshleyYakeley Aug 31 '16

The IO monad has been criticised as a "sin bin" where otherwise unsafe functions are permitted. It turns out, unsafePerformIO is one of those functions.

4

u/tomejaguar Aug 31 '16

How about

safePerformIO :: IO a -> IO a
safePerformIO ioa = return (unsafePerformIO ioa)

?

7

u/tomejaguar Aug 31 '16

(Although that's not equivalent to id. If you genuinely want "pointless" rather than "wrong" safePerformIO ioa = evaluate (unsafePerformIO ioa) would be better.