background preloader

The Haskell Cheatsheet

The Haskell Cheatsheet
Related:  haskellHaskellProgrammation

Apprendre Haskell vous fera le plus grand bien ! - Fonctions d’ordre supérieur Les fonctions Haskell peuvent prendre d’autres fonctions en paramètres, et retourner des fonctions en valeur de retour. Une fonction capable d’une de ces deux choses est dite d’ordre supérieur. Les fonctions d’ordre supérieur ne sont pas qu’une partie de l’expérience Haskell, elles sont l’expérience Haskell. Elles s’avèrent indispensable pour définir ce que les choses sont plutôt que des étapes qui changent un état et bouclent. Fonctions curryfiées En Haskell, toutes les fonctions ne prennent en fait qu’un unique paramètre. ghci> max 4 55ghci> (max 4) 55 Mettre un espace entre deux choses consiste à appliquer une fonction. En quoi cela nous aide-t-il ? Regardons cette fonction violemment simple : multThree :: (Num a) => a -> a -> a -> amultThree x y z = x * y * z Que se passe-t-il vraiment quand on fait multThree 3 5 9 ou ((multThree 3) 5) 9 ? ghci> let multTwoWithNine = multThree 9ghci> multTwoWithNine 2 354ghci> let multWithEighteen = multTwoWithNine 2ghci> multWithEighteen 10180 Yo !

Haskell Haskell is a functional programming language. If you are a seasoned programmer, consult the overview to see what makes Haskell unique and different from other languages. Haskell is distinct in a few ways: Haskell is pure. Haskell is enjoyable to use because dealing with pure functions makes code much easier to reason about, and the advanced type system helps catch silly and profound mistakes. Our aim in this book is to introduce you to the Haskell programming language — from the very basics to advanced features — and to computer programming in general. Overview[edit] The book is divided into a Beginner's Track, an Advanced Track, and a section called Haskell in Practice which covers more day-to-day issues and uses mostly items from the Beginner's Track. Search[edit] You may search the book here: Beginner's Track[edit] Our aim in this track is to introduce you to Haskell basics and some commonly used libraries. Advanced Track[edit] Haskell in Practice[edit] Appendices[edit] About the book[edit]

Haskell « A Critical Systems Blog Looking to make a statement this holiday season? You could try to win the office “ugly holiday sweater” contest. Or, you could play “Jingle Bells” on your Arduino microcontroller, using Haskell. This post is about the latter. We’re going to write this small program using the Copilot embedded domain-specific language (on Hackage and the source on Github). (For the impatient, the Haskell file is here, and the generated .c and .h files are here and here, respectively.) We’re going to essentially recreate this C/Wiring program, plus flash some LEDs, but hopefully in a easier, safer way. Determine the note and number of beats to play.Play the piezo speaker.Flash the LEDs. We’ll start by defining which pins control what function: -- pin numbers speaker, red, green :: Spec Int32 speaker = 13 red = 12 green = 11 The type Spec Int32 takes an Int32 and lifts it into a Copilot expression. We’ll call the program cycleSong. Now for the actual program: And that’s basically it. x = [0] ++ map (+1) x

Screencasts Yesod 1.4 Making a blog with Yesod, using Yesod 1.4 by Max Tagher. Source code for this screencast is available on Github. Yesod 1.0 Yesod 1.0 Introductory Screencast from Michael Snoyman on Vimeo. Older Screencasts Some of the specific details shown here may be slightly out of date. Yammer (Twitter clone) Introduction to Yesod Web Framework 0.5 Hello World Blog, part 1 Blog Tutorial - Part 1 - Yesod Web Framework 0.4.0 from Michael Snoyman on Vimeo. Here's the source code: Blog, part 2 Blog Tutorial - Part 2 - Yesod Web Framework 0.4.0 from Michael Snoyman on Vimeo. Sifflet Tutorial Gregory D. Weber August 12, 2013 Sifflet Version 2.2 Just as water flows through rivers, and as rivers flow into other rivers and join their waters, so data flows through channels and mingles with other flows of data. In Unix (including Macintosh OS X), start Sifflet by typing this command into a terminal in an X Window session: sifflet or, if you want to be able to continue using your terminal before Sifflet finishes: sifflet & In Microsoft Windows, using Windows Explorer, navigate to the folder containing sifflet.exe and double-click on it. Alternately, in Microsoft Windows, launch CMD, navigate to the folder containing sifflet.exe, and type A company sells two products, A and B, and makes a gross profit of $0.12 per unit of product A and $0.25 per unit of product B. When you start Sifflet, it will open two windows: the Function Pad window and the Workspace window. Figure 1. Figure 1. Figure 2. Figure 2. This diagram shows a function named grossProfit. Figure 3. Figure 3. Figure 4. Figure 4.

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. Stuff You Should Know Already 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 The “has type” (::) operator can appear as an expression in parentheses, or a separate declaration.

Haskell comme un vrai! tlpl: Un tutoriel très court mais très dense pour apprendre Haskell. Merci à Oleg Taykalo vous pouvez trouver une traduction Russe ici: Partie 1 & Partie 2 ; Table of Content Je pense vraiment que tous les développeurs devraient apprendre Haskell. Peut-être pas devenir des ninjas d’Haskell, mais au moins savoir ce que ce langage a de particulier. Son apprentissage ouvre énormément l’esprit. La plupart des langages partagent les mêmes fondamentaux : les variablesles bouclesles pointeursles structures de données, les objets et les classes Haskell est très différent. Plier son esprit à Haskell peut être difficile. Cet article sera certainement difficile à suivre. La manière conventionnelle d’apprendre Haskell est de lire deux livres. Cet article fait un résumé très dense et rapide des aspect majeurs d’Haskell. Pour les francophones ; je suis désolé. Cet article contient cinq parties : 01_basic/10_Introduction/00_hello_world.lhs Introduction Install Tools: Don’t be afraid ~ runhaskell . Functional In C:

C’est quoi une API ? Si la pertinence des métaphores s’arrête où commence la complexité technologique, il peut être intéressant d’exposer les principales caractéristiques d’une API à travers la métaphore électrique. Dans un premier temps, prenons un fournisseur d’électricité : Ce fournisseur produit et distribue un service : l’électricité.Pour distribuer ce service, il utilise une infrastructure : le réseau électrique (câbles, poteaux électriques, compteurs…). Dans un second temps, prenons une lampe (consommateur de ce service) : La lampe, pour fonctionner, doit être reliée au réseau électrique.Pour y être reliée, la lampe est vendue avec une fiche qui devra être branchée dans une prise électrique. La prise électrique est donc une interface (comme l’API) à travers laquelle la lampe (un développeur ou un programme) consomme un service (des données). Les APIs permettent donc aux développeurs de déléguer le service qu’ils consomment. le nombre et la forme des brochesle voltage et la fréquencele type de courant

GTK+ and Haskell (gtk2hs) on Windows | mark shroyer, dot com Gtk2hs is my favorite way to do cross-platform GUI programming in Haskell — and it’s the toolkit to use if you want to work through the examples in the excellent *Real World Haskell*. But the official instructions for building gtk2hs on Windows leave out some important information, so here’s how I got it all working on Windows 7… Haskell Platform First of all, if you haven’t done so already, download and install the latest release of the Haskell Platform for Windows (version 2010.2.0.0 at the time of this writing). Opt for the installer to add GHC and friends to your %PATH%. Next download the GTK+ 2.16 all-in-one bundle and extract it to C:\Gtk, then add C:\Gtk\bin to %PATH% by hand. Verify that the library is installed correctly by running: pkg-config.exe --modversion gtk+-2.0 The above will report the version number of your installed GTK+ library, e.g. 2.16.6. MinGW gtk2hs Now you should have everything you need to install gtk2hs from Hackage: Hello, world! Build it with GHC: Happy hackage!

Related: