Wed 4 Oct 2006
I read an interesting article about Haskell today, so I tried to learn a little Haskell. It’s a very interesting language. I installed hugs and started. On haskell.org you can read that Haskell means no core dumps. I got a core dump relatively fast. Here’s how:
- Install hugs
- Create an empty file foo.hs
- start hugs
markus@katerina2:~/src/haskell$ touch foo.hs markus@katerina2:~/src/haskell$ hugs __ __ __ __ ____ ___ _________________________________________ || || || || || || ||__ Hugs 98: Based on the Haskell 98 standard ||___|| ||__|| ||__|| __|| Copyright (c) 1994-2005 ||---|| ___|| World Wide Web: http://haskell.org/hugs || || Report bugs to: hugs-bugs@haskell.org || || Version: 20050308 _________________________________________ Haskell 98 mode: Restart with command line option -98 to enable extensions Type :? for help Hugs.Base> :load foo.hs Main> :edit
:edit calls the editor with the last loaded file – here foo.hs. Put the following in the file:
times 1 x = x times n x = times (n-1) x ++ x
This defines a function times which takes two arguments: one from which 1 can be subtracted and another one that can be concatenated with itself. Haskell infers this from how you use the parameters in the function. times concatenates its second argument n times with itself.
Main> times 2 [3] [3,3] Main> times 2 [42] [42,42]
Now in order to produce the seg fault (or core dump) in hugs, you have to call times with a nonpositive number of times:
Main> times 0 [42] Segmentation fault
Nothing earth-shattering, but I find it interesting to have found a possibility to crash Haskell in half an hour after reading about its core dump immunity.
This is meant humoristically, not as a rant. Take it with a grain of salt :)