Shooting your self in the foot with Haskell

There's the well known "How to shoot your self in the foot" list which I have it printed and taped on my desk at work. http://www-users.cs.york.ac.uk/susan/joke/foot.htm I had a co-worker ask me how you'd shoot your self in the foot with Haskell. Here's the best I could do: "You shoot the gun, but the bullet gets trapped in the IO monad." I fully realize how un-clever this is. Some one please give me something more worth of the original list. :) -- /jve

Hi, Am Mittwoch, den 01.10.2008, 16:46 -0400 schrieb John Van Enk:
There's the well known "How to shoot your self in the foot" list which I have it printed and taped on my desk at work.
http://www-users.cs.york.ac.uk/susan/joke/foot.htm
I had a co-worker ask me how you'd shoot your self in the foot with Haskell. Here's the best I could do:
"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. Greetings, Joachim -- Joachim "nomeata" Breitner mail: mail@joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C JID: nomeata@joachim-breitner.de | http://www.joachim-breitner.de/ Debian Developer: nomeata@debian.org

On Wed, Oct 1, 2008 at 3:42 PM, Jake McArthur
John Van Enk wrote:
I had a co-worker ask me how you'd shoot your self in the foot with Haskell. [...] Some one please give me something more worth of the original list.
Couldn't match expected type 'Deer' against inferred type 'Foot'
This one is my favorite! Luke

G'day all.
On Wed, Oct 1, 2008 at 3:42 PM, Jake McArthur
Couldn't match expected type 'Deer' against inferred type 'Foot'
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 Cheers, Andrew Bromage

On 10/1/08, John Van Enk
There's the well known "How to shoot your self in the foot" list which I have it printed and taped on my desk at work.
http://www-users.cs.york.ac.uk/susan/joke/foot.htm
I had a co-worker ask me how you'd shoot your self in the foot with Haskell. Here's the best I could do:
"You shoot the gun, but the bullet gets trapped in the IO monad."
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. or After trying to decipher the type errors from the compiler, your head explodes. or 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. :-)

On Wed, Oct 1, 2008 at 3:27 PM, Simon Brenner
On 10/1/08, John Van Enk
wrote: There's the well known "How to shoot your self in the foot" list which I have it printed and taped on my desk at work.
http://www-users.cs.york.ac.uk/susan/joke/foot.htm
I had a co-worker ask me how you'd shoot your self in the foot with Haskell. Here's the best I could do:
"You shoot the gun, but the bullet gets trapped in the IO monad."
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.
or
After trying to decipher the type errors from the compiler, your head explodes.
Or as GHC says: My brain just exploded. And of course it says that because: I can't handle pattern bindings for existentially-quantified constructors. Instead, use a case-expression, or do-notation, to unpack the constructor. But, telling people that part takes the fun out of :)
or
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.
Heh. Nice. Oleg has earned himself the Haskell equivalent of a Chuck Norris reputation. Except that Oleg has really earned the respect he gets from our teasing. BTW, is there an Oleg Facts website? Jason

On Wed, Oct 1, 2008 at 6:38 PM, Jason Dagit
Heh. Nice. Oleg has earned himself the Haskell equivalent of a Chuck Norris reputation. Except that Oleg has really earned the respect he gets from our teasing. BTW, is there an Oleg Facts website?
Jason
Not that I know of, but there is a Stallman Facts website: Originated here: http://www.reddit.com/r/programming/comments/675jj/richard_stallman_is_the_n... URLed here: http://www.stallmanfacts.com/ -- /jve

On 2008.10.01 15:38:08 -0700, Jason Dagit
Heh. Nice. Oleg has earned himself the Haskell equivalent of a Chuck Norris reputation. Except that Oleg has really earned the respect he gets from our teasing. BTW, is there an Oleg Facts website?
Jason
Lambdabot has/had a number of OlegFacts in its quote database. @quote as usual, or if you want to look at the whole list of quotes, gunzip State/quote. -- gwern Trade UXO Consul Golf genetic import JOTS DCSS Flame lead

On Wed, Oct 1, 2008 at 3:39 PM, Bill
On Wed, 2008-10-01 at 16:46 -0400, John Van Enk wrote: . . .
I fully realize how un-clever this is. Some one please give me something more worth of the original list. :)
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.

On Wed, Oct 1, 2008 at 3:39 PM, Bill
On Wed, 2008-10-01 at 16:46 -0400, John Van Enk wrote: . . .
I fully realize how un-clever this is. Some one please give me something more worth of the original list. :)
You shoot the gun but nothing happens (Haskell is pure, after all).
putting the unsafe in unsafePerformIO! martin

On Thu, Oct 2, 2008 at 00:39, Bill
On Wed, 2008-10-01 at 16:46 -0400, John Van Enk wrote: . . .
I fully realize how un-clever this is. Some one please give me something more worth of the original list. :)
You shoot the gun but nothing happens (Haskell is pure, after all).
Realizing that I pressed "reply" instead of "reply to all" yesterday, here's my message again (sorry Bill). A little refinement: 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. Alternatively: You shoot yorself in the foot, but you are perfectly fine as long you just don't evaluate the foot. Same, but more subtle: You shoot yourself in the foot, but nothing happens unless you start walking. cheers, Arnar

On Oct 1, 2008, at 1:46 PM, John Van Enk wrote:
"You shoot the gun, but the bullet gets trapped in the IO monad."
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. or foreign import ccall "shootparts.h shootfoot" shoot_foot :: Gun -> Programmer -> IO () -johnnnnnnn

Don't forget about memory consumption! If you don't look, the bullet causes heap overflow. If you look, the bullet causes stack overflow.

John Van Enk wrote:
There's the well known "How to shoot your self in the foot" list which I have it printed and taped on my desk at work.
http://www-users.cs.york.ac.uk/susan/joke/foot.htm
I had a co-worker ask me how you'd shoot your self in the foot with Haskell.
The interesting thing about Haskell is: 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...)

John Van Enk wrote:
"You shoot the gun, but the bullet gets trapped in the IO monad."
The community points you at the paper "Bang-bang-patterns: expressing lethal weaponry in the Haskell typesystem". Your head explodes. BTW, these could go on the wiki. -- src/ -XIncomprehensibleTypes Equivalent to all of: -fallow-inconvinient-types, -XOmnipotentInstances, -XFunkyFunctors, -XSuperTuringTypes, -XErraticTypeClasses, -XCoAntiRetroHyperArrows

http://haskell.org/haskellwiki/Shooting_your_self_in_the_foot
This needs to be cleaned up a little (lots of dups, though they are all
great).
On Sun, Oct 5, 2008 at 11:21 PM, John Van Enk
I'll see about putting them there. :)
On Sun, Oct 5, 2008 at 6:22 PM, Simon Richard Clarkstone < simon.clarkstone@gmail.com> wrote:
BTW, these could go on the wiki.
-- /jve
-- /jve

John Van Enk wrote:
On Sun, Oct 5, 2008 at 11:21 PM, John Van Enk
mailto:vanenkj@gmail.com> wrote: On Sun, Oct 5, 2008 at 6:22 PM, Simon Richard Clarkstone
mailto:simon.clarkstone@gmail.com> wrote: BTW, these could go on the wiki. I'll see about putting them there. :)
http://haskell.org/haskellwiki/Shooting_your_self_in_the_foot
This needs to be cleaned up a little (lots of dups, though they are all great).
You missed my one, though I think the "ballistics algebra" one is better. ISTR that the point of the original list was originally to show that, though you can screw up with C, with every other language you can screw up in far more complicated and inscrutable ways. Ballistics algebra is indeed a way to screw up that is not possible in C. (Darnit Thunderbird, why don't you DWIM when I hit reply or reply-all?) -- src/

On 10/1/08, John Van Enk
There's the well known "How to shoot your self in the foot" list which I have it printed and taped on my desk at work.
http://www-users.cs.york.ac.uk/susan/joke/foot.htm
I had a co-worker ask me how you'd shoot your self in the foot with Haskell.
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.
participants (18)
-
ajb@spamcop.net
-
Albert Y. C. Lai
-
Andrew Coppin
-
Arnar Birgisson
-
Bill
-
Evan Laforge
-
Gwern Branwen
-
Ilmari Heikkinen
-
Jake McArthur
-
Jason Dagit
-
Joachim Breitner
-
Joe Buehler
-
John Melesky
-
John Van Enk
-
Luke Palmer
-
Martin DeMello
-
Simon Brenner
-
Simon Richard Clarkstone