Skip to main content

Posts

Showing posts with the label haskell

The ultimate programming language ?

After many years of thought and many years of using many languages, I am now more and more convinced that the “perfect” combination, if such a thing exists, is going to be a mix of Haskell, LISP and Prolog. Exactly what “combination” means in terms of the different programming paradigms each presents is completely unknown to me at this point! Haskell is functional, Prolog is logical and LISP is everything. LISP First of all, the uniform s-expression shape of LISP is so absolutely pure, clean and simple that I feel it’s the true shape of expressing thoughts as code. If you work in LISP long enough you don’t even see the parens any more. Really. And the implied return value being the last thing you did is also useful. Haskell Haskell is incredibly clean in its form. The use of a space character as the argument separator is cool. The functional aspect is also very very nice. What I don’t like about Haskell is the IO / monad thing, Sometimes it feels incredibly hard work to do th...

Curried Functions, my favourite!

I have understood the concept of "currying" for quite some time now but it wasn't until last night that I really understood how useful it (currying) can be when you want to use a standard library function but pass it something slightly different... I was playing with reading a file using the "withFile" function, withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r Thing is, the function I wanted to write, as part of its duties, needed to print the filename to the console output before doing its thing... I knew that it could be done and for once I was going to think it through and make it happen! My function had the same type, (Handle -> IO r) , but now I wanted to add in the String that would be the filename and the penny dropped... by using partial application I could "part-bake" a call to my function and leave it in such a state that it would "fit" the required type... read on... got: Handle -> IO r...

Haskell, GHC and --hash-size=31

A few nights back I decided to return to an on-going self-education project in Haskell and much to my dismay, when I issued the "ghc --make ..." utterance it failed to complete and instead gave me the error: $ ghc --make hwtest.hs Linking hwtest ... /usr/bin/ld: --hash-size=31: unknown option usr/bin/ld: use the --help option for usage information collect2: error: ld returned 1 exit status WTF? When did my linker system or GHC break when I wasn't looking? After two unsuccessful postings to the Haskell beginners newsgroup (unsuccessful as in they appeared not to have made it through the inter-web) I gave up and dug a little harder and turned up this post on the web: http://www.haskell.org/pipermail/cvs-ghc/2011-November/068562.html Bingo. I remedied the situation by performing this from the command line: sudo apt-get remove binutils-gold I didn't even know I had this package but then I suddenly remembered that a few nights previous and had foun...

PHP and Maybe miserable Monads

I decided recently, while starting a new project, that it would be interesting to try and take some of my new found paradigms from Haskell back into the relative slums of PHP. As much as I like the fact that PHP just works, the more I get into Haskell the more I resent having to type reams and reams of code in PHP just to get things done. That's just me and I won't change! One of the things that I am really starting to miss now that I understand Monads (at least enough to write them and use them, my own and the libraries) is the ability to be able to have "Maybe". It is such a lovely way of handling data when there really isn't anything and it sure as hell kicks ass over using "NULL" as a return type. PHP is riddled with functions that return FALSE to mean they didn't actually work or some other value if they did which makes a whole mockery of its so called "types". Case in point, when using PDO for example (I could be w...