background preloader

Haskell

Facebook Twitter

Tutorial de Haskell - Haskell. Introdução O Haskell é uma linguagem de programação funcional, baseada no lambda-calculus, que surgiu nos anos 80.

Tutorial de Haskell - Haskell

Esta linguagem possui algumas das mais recentes caracteristicas das linguagens funcionais como lazy evaluation, pattern matching e modularidade. Trata-se de uma linguagem pouco eficiente e como tal ainda não muito usado em empresas. Apesar de tudo é uma das linguagem mais populares no meio académico e muito usada em investigação. Os programas tanto podem ser compilados (usando um compilador como o GHC) ou interpretados (usando o GHCi ou o HUGS, por exemplo). Algumas noções preliminares Um programa em Haskell deve começar com a linha module Nome_Mod where, onde 'Nome_Mod' é o nome deste módulo, que tem que começar por letra maiúscula. Os tipos em Haskell começam por letras maiúsculas sendo os básicos Int, Integer, Float, Double, Char e Bool.

O primeiro programa Código (Haskell): module PrimeiroProg where funcao :: Int -> Intfuncao x = x^2 f1 ::Float->Float->Boolf1 x y = x * y >0. Installing leksah, gtk, gtk2hs, and glade on Ubuntu 10.04 LTS -the Lucid Lynx. Real World Haskell. Everything Your Professor Failed to Tell You About Functional Programming. I've been trying to learn Haskell lately, and the hardest thing seems to be learning about monads.

Everything Your Professor Failed to Tell You About Functional Programming

"Monads in Ruby" and "Monads for Functional Programming" helped me finally to break the ice, but more importantly, they gave me a glimpse behind the veil. I finally began to understand something that is trivial to people such as Philip Wadler, but something that never had been explained to me so succinctly. In computer science, we enjoy using mathematic models, but the science still works if you violate the math. And, much to the dismay of purely functional programming enthusiasts, we almost always do. However, when we embrace the math, sometimes the loss in flexibility is more than compensated for by the increase in functionality. Monads as a Design Pattern Philip Wadler says, "Monads provide a convenient framework for simulating effects found in other languages, such as global state, exception handling, output, or non-determinism.

" I'd respond: "Design patterns fluctuate by language. . $ . Download Haskell. Beginning Haskell. Before you start About this tutorial This tutorial targets programmers of imperative languages wanting to learn about functional programming in the language Haskell.

Beginning Haskell

In an introductory tutorial, many of Haskell's most powerful and complex features cannot be covered. In particular, the whole area of type classes and algebraic types (including abstract data types) is a bit much for a first introduction. For readers whose interest is piqued, I will mention that Haskell allows you to create your own data types, and to inherit properties of those data types in type instances. The other significant element omitted in this tutorial is a discussion of monads, and therefore of I/O. Prerequisites This tutorial has no prerequisites.

Back to top Haskell basics About Haskell Haskell is just one of a number of functional programming languages. Among functional languages, Haskell is in many ways the most idealized language. Obtaining Haskell Haskell has several implementations for multiple platforms. Guards.