Personal tools

Shooting your self in the foot

From HaskellWiki

Revision as of 03:33, 6 October 2008 by Sw17ch (Talk | contribs)

Jump to: navigation, search

The following list was proposed by members of Haskell-Cafe.

The original thread can be found here.

How to Shoot Your Self in the Foot With Haskell: Putting the unsafe in unsafePerformIO!

  • You shoot the gun, but the bullet gets trapped in the IO monad.
  • You shoot the gun, but nobody notices because no-one evaluates the target.
  • Couldn't match expected type 'Deer' against inferred type 'Foot'.
  • While compiling your program the compiler produces a type error long enough to overflow a kernel buffer, overwrite the trigger control register and shoot you in the foot.
  • After trying to decipher the type errors from the compiler, your head explodes.
  • After you've finally found a way to circumvent the type system and shoot yourself in the foot, Oleg appears out of nothing and shoots you in the foot for coming up with it before him.
  • You shoot the gun but nothing happens (Haskell is pure, after all).
  • Your foot is fine, until you try to walk on it, at which point it becomes mangled.
  • You have a shootFoot function which you've proven correct. QuickCheck validates it for arbitrary you-like values. It will be evaluated only when you end up at the hospital. You hope this doesn't come to pass, as it actually returns a bullet-ridden copy of yourself and you don't want to be garbage-collected.
  • foreign import ccall "shootparts.h shootfoot" shoot_foot :: Gun -> Programmer -> IO ()
  • No instance for (Target Foot)
    arising from use of `shoot' at SelfInflictedInjury.hs:1:0
    Possible fix: add an instance declaration for (Target Foot)
    In the expression: shoot foot
  • You go to shoot yourself in the foot but the bullet is in the ST monad and the gun is in the IO monad, so you can't.
  • You ask Haskell to shoot you in the foot but by the rules of lazy evaluation you don't need the result yet so it doesn't happen.
  • You decide to shoot yourself in the foot but get distracted devising a ballistics algebra and wondering if you can do the calculations in the type system.
  • You want to shoot yourself in the foot but realize there is no Gun datatype so use Arrows instead.
  • You shoot in the direction of your foot, but since you are inside the STM monad you can just retry until you figure out what to do.
  • You shoot yorself in the foot, but you are perfectly fine as long you just don't evaluate the foot.
  • You shoot yourself in the foot, but nothing happens unless you start walking.
  • Don't forget about memory consumption! If you don't look, the bullet causes heap overflow. If you look, the bullet causes stack overflow.
  • You *appear* to have deliberately shot yourself in the foot, and yet your program actually runs perfectly OK due to lazy evaluation. (So long as you remember to not look at your foot...)
  • You aim the gun at your foot, pull the trigger and remove the clip. When you look at your undamaged foot, the hammer clicks on an empty barrel.