Shooting your self in the foot with Haskell

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
25 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Shooting your self in the foot with Haskell

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."

I fully realize how un-clever this is. Some one please give me something more worth of the original list. :)

--
/jve

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

Joachim Breitner-2
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: [hidden email] | ICQ# 74513189 | GPG-Key: 4743206C
  JID: [hidden email] | http://www.joachim-breitner.de/
  Debian Developer: [hidden email]

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe

signature.asc (204 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

Martin DeMello
2008/10/1 Joachim Breitner <[hidden email]>:
>
> You shoot the gun, but nobody notices because no-one evaluates the
> target.

Who'd've thunk it!

m.
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

Jake Mcarthur-2
In reply to this post by John Van Enk
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'

- Jake
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

Simon Brenner
In reply to this post by John Van Enk
On 10/1/08, John Van Enk <[hidden email]> 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

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.

:-)
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

Jason Dagit-2


On Wed, Oct 1, 2008 at 3:27 PM, Simon Brenner <[hidden email]> wrote:
On 10/1/08, John Van Enk <[hidden email]> 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


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

Bill Wood-3
In reply to this post by John Van Enk
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).

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

John Van Enk
In reply to this post by Jason Dagit-2


On Wed, Oct 1, 2008 at 6:38 PM, Jason Dagit <[hidden email]> wrote:


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_new_chuck_norris
URLed here: http://www.stallmanfacts.com/

--
/jve

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

Evan Laforge
In reply to this post by Bill Wood-3
On Wed, Oct 1, 2008 at 3:39 PM, Bill <[hidden email]> wrote:
> 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.
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

John Melesky
In reply to this post by John Van Enk
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

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

Martin DeMello
In reply to this post by Bill Wood-3
On Wed, Oct 1, 2008 at 3:39 PM, Bill <[hidden email]> wrote:
> 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
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

Gwern Branwen
In reply to this post by Jason Dagit-2
On 2008.10.01 15:38:08 -0700, Jason Dagit <[hidden email]> scribbled 4.3K characters:
>    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

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe

signature.asc (204 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

Luke Palmer-2
In reply to this post by Jake Mcarthur-2
On Wed, Oct 1, 2008 at 3:42 PM, Jake McArthur <[hidden email]> wrote:
> 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
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

ajb@spamcop.net
G'day all.

On Wed, Oct 1, 2008 at 3:42 PM, Jake McArthur <[hidden email]> wrote:

> 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
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

Arnar Birgisson
In reply to this post by Bill Wood-3
On Thu, Oct 2, 2008 at 00:39, Bill <[hidden email]> wrote:
> 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
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

Albert Y. C. Lai
In reply to this post by John Van Enk
Don't forget about memory consumption!

If you don't look, the bullet causes heap overflow. If you look, the
bullet causes stack overflow.
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

Arnar Birgisson
On Thu, Oct 2, 2008 at 17:11, Albert Y. C. Lai <[hidden email]> wrote:
> Don't forget about memory consumption!
>
> If you don't look, the bullet causes heap overflow. If you look, the bullet
> causes stack overflow.

So it is a Heisenberg-bullet?

Arnar
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

Joseph H. Buehler
Arnar Birgisson wrote:

> So it is a Heisenberg-bullet?

I'm uncertain.
--
Joe Buehler

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

Andrew Coppin
In reply to this post by John Van Enk
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...)

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Shooting your self in the foot with Haskell

Simon Richard Clarkstone-2
In reply to this post by John Van Enk
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
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
12