background preloader

Learn Haskell Fast and Hard

Learn Haskell Fast and Hard
I really believe all developers should learn Haskell. I don’t think everyone needs to be super Haskell ninjas, but they should at least discover what Haskell has to offer. Learning Haskell opens your mind. Mainstream languages share the same foundations: variablesloopspointersdata structures, objects and classes (for most) Haskell is very different. But learning Haskell can be hard. This article will certainly be hard to follow. The conventional method to learning Haskell is to read two books. In contrast, this article is a very brief and dense overview of all major aspects of Haskell. The article contains five parts: Introduction: a short example to show Haskell can be friendly.Basic Haskell: Haskell syntax, and some essential notions.Hard Difficulty Part: Functional style; a progressive example, from imperative to functional styleTypes; types and a standard binary tree exampleInfinite Structure; manipulate an infinite binary tree! 01_basic/10_Introduction/00_hello_world.lhs Introduction ou

A Gentle Introduction to Haskell, Version 98 This is the master HTML version of the Gentle Introduction To Haskell, version 98. Revised June, 2000 by Reuben Thomas. You may download the following: Brief Table of Contents. All code in this tutorial, with additional commentary, is found in the code directory packaged with this tutorial. Premission is granted to correct, improve, or enhance this document. Copyright (C) 1999 Paul Hudak, John Peterson and Joseph Fasel Permission is hereby granted, free of charge, to any person obtaining a copy of "A Gentle Introduction to Haskell" (the Text), to deal in the Text without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Text, and to permit persons to whom the Text is furnished to do so, subject to the following condition: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Text.

Monad Transformers Step by Step Information Martin Grabmüller: Monad Transformers Step by Step, draft paper, October 2006. 12 pages, A4 format, English. Abstract In this tutorial, we describe how to use monad transformers in order to incrementally add functionality to Haskell programs. Download This article is available electronically: [ PDF ] The source code of this article, in the form of a Literate Haskell script, is also available: [ Transformers.lhs ] BibTeX Entry @Unpublished{Grabmueller2006MonadTransformers, author = {Martin Grabm{\"u}ller}, title = {{Monad Transformers Step by Step}}, note = {Draft paper}, month = {October}, year = 2006, abstract = {In this tutorial, we describe how to use monad transformers in order to incrementally add functionality to Haskell programs. Copyright (C) 2003-2008 Martin Grabmüller Verbatim copying and distribution of this entire web page is permitted in any medium, provided this notice is preserved.

Haskell Lectures - CS 1501 Lecture 1 Outlines class structure, syllabus, grading policies, and reference text. Introduces the origin and theory behind Haskell. Lecture 2 Introduces Lists and Tuples, the most important data structures in Haskell. Lecture 3 Explores Haskell's strong Type system and Typeclasses. Lecture 4 Covers proper syntax in writing longer Haskell code. Lecture 5 Shows how to create your own data types to customize Haskell for you needs. Lecture 6 Investigates higher order functions such as maps, filters, folds, and a whole lot more.

Haskell: The Confusing Parts If you’re used to the C family of languages, or the closely related family of “scripting languages,” Haskell’s syntax (mainly) is a bit baffling at first. For some people, it can even seem like it’s sneaking out from under you every time you think you understand it. This is sort of a FAQ for people who are new to Haskell, or scared away by its syntax. Use this as a cheat sheet, not a textbook. Misc. Quick review, because if you’ve heard of Haskell, you should also have heard of most of this. foo :: Bar baz -> Bar quux is a type signature for the function foo, where Bar baz is the type of argument it takes, and Bar quux is the type of the return value. There’s no null and no void. Haskell’s syntax is indirectly based on ML, so if you stop reading here and go learn OCaml instead, some of this information will still be kinda useful. Type Names and Constructors There are two completely separate namespaces in any Haskell source file: The value namespace, and the type namespace. Statements vs.

sol/doctest-haskell Haskell from C: Where are the for Loops? | FP Complete If you're coming from a language like C, Haskell can take some getting used to. It's typical for a new language to feel a little different, but in Haskell the differences are more dramatic, and more fundamental. In particular... Where are the for loops? In most imperative languages, for loops are all over the place, and are used for a wide variety of different things. Whether you're squaring every value of an array or finding its sum, you're probably using a for loop. In Haskell, control structures are more expressive. Consider the simple example of computing the norm of a vector. Conceptually, there are three stages to this computation: mapSq: Square each elementsum: Compute the sumsqrt: Compute the square root We can think of the first step as building (at least abstractly) a new array whose ith element is y[i] = x[i] * x[i]. Putting everything in terms of functions, we can write this (in Haskell-like pseudocode) as norm(x) = sqrt(sum(mapSq(x))) , norm(x) = (sqrt ○ sum ○ mapSq)(x) , or just

Gentle introduction to Haskell This is the master HTML version of the Gentle Introduction To Haskell, version 98. Revised June, 2000 by Reuben Thomas. You may download the following: Brief Table of Contents. All code in this tutorial, with additional commentary, is found in the code directory packaged with this tutorial. Premission is granted to correct, improve, or enhance this document. Copyright (C) 1999 Paul Hudak, John Peterson and Joseph Fasel Permission is hereby granted, free of charge, to any person obtaining a copy of "A Gentle Introduction to Haskell" (the Text), to deal in the Text without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Text, and to permit persons to whom the Text is furnished to do so, subject to the following condition: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Text.

Some interesting features of Haskell’s type system « Wolfgang Jeltsch One of the most important ingredients of Haskell is its type system. Standard Haskell already provides a lot of useful mechanisms for having things checked at compile time, and the language extensions provided by the Glasgow Haskell Compiler (GHC) improve heavily on this. In this article, I will present several of Haskell’s type system features. This whole article was written as a literate Haskell file with ordinary text written in Markdown. Prerequisites We first enable some language extensions that we will use in this article: {-# LANGUAGE MultiParamTypeClasses, TypeFamilies #-} We will reimplement some bits of the Prelude for illustration purposes, and we will use functions from other modules whose names clash with those of certain Prelude functions. import Prelude hiding (Eq (..), Functor (..), lookup, (!!)) Furthermore, we need some additional modules for example code: These imports require the packages Stream, natural-numbers, and containers to be installed. Kinds Type classes Like this:

Raincat | 2D Puzzle Game 2D puzzle game featuring a fuzzy little cat "Watching the cat walk is so soothing." "He's so cute! Download to play Raincat! Written in Haskell Get the Source! what fans have said "Raincat is amazing. how the cat sauntering in the rain came to be The project proved to be an excellent learning experience for the programmers. It's always raining in Pittsburgh, which makes for gray days while cats are just adorable—perfect for brightening up such days. Your goal is simple: guide the fuzzy cat safe and dry to the end of each level. Become our fan on Facebook! As students who make games for fun, we understand that our product isn't perfect. Finally, we'd like to mention that Project Raincat placed first in GCS Gold during the following spring semester release party. made by people who like cats maybe a little too much Team on the GCS Project Page for your kitty watching pleasure Thanks for visiting Project Raincat!

untitled The Haskell Phrasebook is a free quick-start Haskell guide comprised of a sequence of small annotated programs. It provides a cursory overview of selected Haskell features, jumping-off points for further reading, and recommendations to help get you writing programs as soon as possible. Source code To follow along and run the code examples, get the source files from github.com/typeclasses/haskell-phrasebook. We welcome requests and contributions, and we’re grateful to all who have submitted example code. The code may be modified and redistributed for any non-commercial purpose with attribution. Libraries Here is the complete list of libraries utilized by the example programs: Related work The style of the Phrasebook and many of its examples are inspired by Go by Example and Rust by Example.

Haskell's evaluation isn't magic One common complaint with lazy functional programming is that reasoning about the performance of your code is harder than in a strict language. Will an expression be repeatedly evaluated or a closure repeatedly accessed? Will code use up more or less heap space? For that matter, many people have no clue as to how lazy evaluation works in the first place. This blog post show that execution in a lazy language is both understandable and predictable. Haskell is in essence a heavily sugared and extended version of a typed λ-calculus (i.e. λ-calculus with a type system attached). In 1993 Launchbury wrote A Natural Semantics for Lazy Evaluation [pdf], which provided a simple operational semantics (I’ll explain what that is in a second) for understanding the lazy evaluation of an extended λ-calculus. Before we continue, let’s remind ourselves how the λ-calculus is evaluated. What does sharing mean? Before you can apply the reduction rules, Launchbury’s semantics require a term to be normalized.

Related: