background preloader

Haskell

Facebook Twitter

The Haskell Cheatsheet. Reference card. 1 General Syntax {- A multiline comment which can continue for many lines -} -- a single line comment 1.2 Conditionals 1.2.1 if if conditional then truePart else falsePart if a == 12 then 14 else 22 1.2.2 case case exp of Pattern1 -> action1 Pattern2 -> action2 _ -> else_action case x of [] -> 0 [x] -> 1 _ -> -1 1.2.3 Function pattern matching f [ ] = 0 f [x] = 1 f _ = -1 1.2.4 Function conditionals (guards) f x | x == [] = 1 | length x == 12 = 15 | otherwise = -1 1.3 Saving work 1.3.1 where f x = i * i where i = g x 1.3.2 let in f x = let i = g x in i * i 1.4 Declaring types 1.4.1 data data List = Cons Int List | Nil deriving (Eq, Show, Ord) 1.4.2 type (type synonymns)

Reference card

Tutorial for C Programmers. Haskell Tutorial for C Programmers, by Eric Etheridge version 3.0 - please increment with major updates original author: Eric Etheridge last major update by the original author: August 28, 2011 year of original release (on old haskell.org site): 2005 1 Introduction 1.1 Abstract Many people are accustomed to imperative languagues, which include C, C++, Java, Python, and Pascal.

Tutorial for C Programmers

For computer science students, Haskell is weird and obtuse. I write this assuming that you have checked out the Gentle Introduction to Haskell, but still don't understand what's going on. Haskell is not 'a little different,' and will not 'take a little time.' I am going to put many pauses in this tutorial because learning Haskell hurt a lot, at least for me. Haskell has both more flexibility and more control than most languages. I wrote this tutorial because Haskell was very hard for me to learn, but now I love it.

This abstract was pieced together by Mark Evans, here, from my own work. Haskell. Haskell is a functional programming language.

Haskell

If you've programmed before and would like to see a little bit of how Haskell works and is different from other programming languages, see the overview. Haskell is unique in two ways. First, it is a pure functional programming language. If you have a function and you call it twice in two different places with the same arguments then it will return exactly the same value both times. Second, Haskell provides a very modern type system which incorporates features like typeclasses and generalized algebraic data types.

So, why do Haskellers like their language? In this book we aim to introduce you both to the Haskell language, from the very basics to the most advanced features, and to computer programming in general. Overview[edit] The book is divided into three sections: the Beginner's Track, the Advanced Track, and Haskell in Practice, which is designed to cover the more day-to-day issues, and is readable with knowledge of the Beginner's Track. Cookbook. Meta-tutorial. HaskellWiki. Newest 'haskell' Questions. Haskell. Hoogle. 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.

Hoogle

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. Please email me, or add an entry to my bug tracker. Hayoo! - Haskell API Search.

Books