background preloader


Hoogle is a Haskell API search engine, which allows you to search many standard Haskell libraries by either function name, or by approximate type signature. Example searches: map (a -> b) -> [a] -> [b] Ord a => [a] -> [a] Data.Map.insert Enter your own search at the top of the page. The Hoogle manual contains more details, including further details on search queries, how to install Hoogle as a command line application and how to integrate Hoogle with Firefox/Emacs/Vim etc. I am very interested in any feedback you may have. Related:  Haskell

Why the world needs Haskell - Devalot This is a technical review of Haskell and why software developers should care about functional programming. For a non-technical review of why your company should be using Haskell you might want to watch this introduction to Haskell video by FP Complete. TL;DR: Writing high-quality, bug-free software isn’t easy. Haskell (and similar languages) provide the programmer with the tools necessary to get closer than ever before. By removing entire categories of bugs (such as those caused by null pointers and nil objects, type coercions, accidental mutation, etc.) and introducing a powerful type system, programmers can write better code in the same amount of time (and often less) than more traditional languages. Null Pointers and Undefined Values The code we write eventually executes in the real world and things don’t always go as we would like. These are exceptional situations that we don’t have much control over and which we have to deal with gracefully. getUserByName :: String -> Maybe User

Jailbreaking the NeoTV Today we’ll be jailbreaking the Netgear NTV300 set top box…with a TV remote. The Netgear NeoTV 300 Negear’s NeoTV set top boxes are designed to compete with the popular Roku, and can stream video from all the usual sources (Netflix, HuluPlus, Youtube, etc). The NTV300 is one of the least expensive NeoTV models, and while a GPL release is available, it contains only copies of the various standard open source utilities used by the NTV300. Inside the NTV300 we find a Mediatek ARM SoC, a 128MB NAND flash chip and 256MB of RAM: Inside the NTV300 The four pin header in the top right corner of the PCB is a serial port (115200 baud 8N1), and while it provides access to the U-Boot boot loader, it does not provide a root shell. Luckily, the firmware updates for the NTV300 aren’t encrypted. While the firmware update does not appear to contain a complete file system, most of the interesting stuff appears to be in the first SquashFS image. Printf’s reveal original function names How not to stat a file

Math.Statistics modes :: Ord a => [a] -> [(Int, a)]Source Modes returns a sorted list of modes in descending order quantile :: (Fractional b, Ord b) => Double -> [b] -> bSource Sample variance Interquartile range Arbitrary quantile q of an unsorted list. linreg :: Floating b => [(b, b)] -> (b, b, b)Source Least-squares linear regression of y against x for a |collection of (x, y) data, in the form of (b0, b1, r) |where the regression is y = b0 + b1 * x with Pearson |coefficient r devsq :: Floating a => [a] -> aSource Returns the sum of square deviations from their sample mean. VsHaskell See also [LanguageComparisons]. Haskell Haskell is a modern functional language (like lisp). It's not commonly used but the language is used for some "real" projects (not just an experimental language) and is becoming more common in industry. For example, the darcs version control system is written in Haskell. More information can be found at Haskell and Python are a somewhat odd pair to compare, because they are so different in many ways. Functional vs Procedural: Haskell is a lazy (evaluate by need), so-called pure functional (no assignments or side-effects) language. Compiled vs Interpreted: Python's primary implementation is an interpreter. The pythonic philosophy of dropping into C for critical sections applies equally well to haskell. Static vs Dynamic Typing: Both Haskell and Python have strong (not weak) typing, meaning instances of a type cannot be cast into another type. a = 5 The fact that it's an integer is inferred by the Haskell compiler. Learning Curve:

My vi/vim cheatsheet Cursor movement h - move leftj - move downk - move upl - move rightw - jump by start of words (punctuation considered words)W - jump by words (spaces separate words)e - jump to end of words (punctuation considered words)E - jump to end of words (no punctuation)b - jump backward by words (punctuation considered words)B - jump backward by words (no punctuation)0 - (zero) start of line^ - first non-blank character of line$ - end of lineG - Go To command (prefix with number - 5G goes to line 5) Note: Prefix a cursor movement command with a number to repeat it. For example, 4j moves down 4 lines. Insert Mode - Inserting/Appending text i - start insert mode at cursorI - insert at the beginning of the linea - append after the cursorA - append at the end of the lineo - open (append) blank line below current line (no need to press return)O - open blank line above current lineea - append at end of wordEsc - exit insert mode Editing Marking text (visual mode) Visual commands Cut and Paste Exiting

Data.ByteString.Char8 O(n) The unfoldrN function is analogous to the List 'unfoldr'. unfoldrN builds a ByteString from a seed value. The function takes the element and returns Nothing if it is done producing the ByteString or returns Just (a,b), in which case, a is a prepending to the ByteString and b is used as the next element in a recursive call. To preven unfoldrN having O(n^2) complexity (as prepending a character to a ByteString is O(n), this unfoldr requires a maximum final size of the ByteString as an argument. cons can then be implemented in O(1) (i.e. a poke), and the unfoldr itself has linear complexity. The depth of the recursion is limited to this size, but may be less. For lazy, infinite unfoldr, use unfoldr (from List). Examples: unfoldrN 10 (\x -> Just (x, chr (ord x + 1))) '0' == "0123456789" The following equation connects the depth-limited unfoldr to the List unfoldr: unfoldrN n == take n $ List.unfoldr

How to read Haskell like Python tl;dr — Save this page for future reference. Have you ever been in the situation where you need to quickly understand what a piece of code in some unfamiliar language does? If the language looks a lot like what you’re comfortable with, you can usually guess what large amounts of the code does; even if you may not be completely familiar how all the language features work. For Haskell, this is a little more difficult, since Haskell syntax looks very different from traditional languages. But there's no really deep difference here; you just have to squint at it just right. Here is a fast, mostly incorrect, and hopefully useful guide for interpreting Haskell code like a Pythonista. Types. Arguments. f a b c translates into f(a, b, c). Dollar sign. In some code, you may see a variant of $: <$> (with angled brackets). Backticks. x `f` y translates into f(x,y). Equals sign. doThisThing a b c = ... ==> def doThisThing(a, b, c): ... let a = b + c in ... ==> a = b + c ... Left arrow. Right arrow.

What every computer science major should know Portfolio versus resume Having emerged from engineering and mathematics, computer science programs take a resume-based approach to hiring off their graduates. A resume says nothing of a programmer's ability. Every computer science major should build a portfolio. A portfolio could be as simple as a personal blog, with a post for each project or accomplishment. Contributions to open source should be linked and documented. A code portfolio allows employers to directly judge ability. GPAs and resumes do not. Professors should design course projects to impress on portfolios, and students, at the conclusion of each course, should take time to update them. Examples Technical communication Lone wolves in computer science are an endangered species. Modern computer scientists must practice persuasively and clearly communicating their ideas to non-programmers. Unfortunately, this is not something fixed with the addition of a single class (although a solid course in technical communication doesn't hurt). Java

Data.Map An efficient implementation of maps from keys to values (dictionaries). Since many function names (but not the type name) clash with Prelude names, this module is usually imported qualified, e.g. import Data.Map (Map) import qualified Data.Map as Map The implementation of Map is based on size balanced binary trees (or trees of bounded balance) as described by: Stephen Adams, "Efficient sets: a balancing act", Journal of Functional Programming 3(4):553-562, October 1993, Note that the implementation is left-biased -- the elements of a first argument are always preferred to the second, for example in union or insert. Operation comments contain the operation time complexity in the Big-O notation Is Haskell the Cure? - Mathias Biilmann Ted Dziuba's well executed trolling, Node.js is Cancer has been sucessful in getting people all riled up, benchmarking fibonacci servers in all the popular scripting languages. Both Joshua Kehn and Brian Beck reaches the conclusion that Node is more than fast enough through their benchmarks of Ruby, PHP and Python versions of the Node fibonacci example. My goto tool for writing fast, concurrent web services is Haskell. So I thought I would see how a direct translation of the fibonacci service would fare with the Snap Framework. Here's the implementation in 11 lines of Haskell: So how does it fare? Well, turns out Haskell is just too clever for this benchmark. Is Meassuring Fibonacci Relevant? While benchmarking fibonacci is fun, it might not be terribly relevant when evaluating solutions to concurrent programming. I think a lot of people missed the main point of Dziuba's troll. From a language point of view node brings nothing to the table. Haskell is incredible in this regard.

Project Euler Data.Map Note: You should use Data.Map.Strict instead of this module if: You will eventually need all the values stored.The stored values don't represent large virtual data structures to be lazily computed. An efficient implementation of ordered maps from keys to values (dictionaries). These modules are intended to be imported qualified, to avoid name clashes with Prelude functions, e.g. import qualified Data.Map as Map The implementation of Map is based on size balanced binary trees (or trees of bounded balance) as described by: Stephen Adams, "Efficient sets: a balancing act", Journal of Functional Programming 3(4):553-562, October 1993, Note that the implementation is left-biased -- the elements of a first argument are always preferred to the second, for example in union or insert. Operation comments contain the operation time complexity in the Big-O notation (

Notes on Haskell