Haskell is a computer programming language. In particular, it is a polymorphically statically typed, lazy, purely functional language, quite different from most other programming languages. The language is named for Haskell Brooks Curry, whose work in mathematical logic serves as a foundation for functional languages. Haskell is based on the lambda calculus, hence the lambda we use as a logo. 1 Why use Haskell? Writing large software systems that work is difficult and expensive. WOW! Even if you are not in a position to use Haskell in your programming projects, learning Haskell can make you a better programmer in any language. I learned Haskell a couple of years ago, having previously programmed in Python and (many) other languages. Haskell offers you: Substantially increased programmer productivity (Ericsson measured an improvement factor of between 9 and 25 using Erlang, a functional programming language similar to Haskell, in one set of experiments on telephony software). 3.4 Brevity
Hackage: IntroductionExcellent Overview of Functional Programming14 Feb 2008 I just ran into an article on DZone that totally threw me off my chair in terms of content. It’s titled (ambitiously enough) “Functional Programming For the Rest of Us“. It’s worth noting that the author claims to be presenting his explanations in Java, but is in fact devising an extension of Java to represent FP constructs more concisely. The really interesting bit is how the author motivates FP through a combination of real-world examples and lengthy reasoning. So grab yourself a cup of coffee and a box of donuts (it’ll take you about that long to finish the article), and slog your way through.Haskell/Applicative functorsWhen covering the vital Functor and Monad type classes, we glossed over a third type class: Applicative, the class for applicative functors. Like monads, applicative functors are functors with extra laws and operations; in fact, Applicative is an intermediate class between Functor and Monad. Applicative are a widely used class with a wealth of applications (pardon the pun). Functor recap We will begin with a quick review of the Functor class chapter. class Functor f where fmap :: (a -> b) -> f a -> f b If a type has an instance of Functor, you can use fmap to apply a function to values in it. fmap id = id -- 1st functor lawfmap (g . f) = fmap g . fmap f -- 2nd functor law Maybe, for example, has a Functor instance, and so we can easily modify the value inside it... Prelude> fmap negate (Just 2)Just (-2) ...as long as it exists, of course. Prelude> fmap negate NothingNothing For extra convenience, fmap has an infix synonym, (<$>). Prelude> negate <$> Just 2Just (-2) The type of (<*>) is:
Haskell/The Functor classIn this chapter, we will introduce the important Functor type class. Motivation In Other data structures, we saw operations that apply to all elements of some grouped value. The prime example is map which works on lists. data Tree a = Leaf a | Branch (Tree a) (Tree a) deriving (Show) The map function we wrote for Tree was: treeMap :: (a -> b) -> Tree a -> Tree btreeMap f (Leaf x) = Leaf (f x)treeMap f (Branch left right) = Branch (treeMap f left) (treeMap f right) As discussed before, we can conceivably define a map-style function for any arbitrary data structure. When we first introduced map in Lists II, we went through the process of taking a very specific function for list elements and generalizing to show how map combines any appropriate function with all sorts of lists. Introducing Functor Functor is a Prelude class for types which can be mapped over. class Functor f where fmap :: (a -> b) -> f a -> f b The usage of the type variable f can look a little strange at first. Note
The Scala Programming LanguageHaskell/Applicative functorsWhen covering the vital Functor and Monad type classes, we glossed over a third type class: Applicative, the class for applicative functors. Like monads, applicative functors are functors with extra laws and operations; in fact, Applicative is an intermediate class between Functor and Monad. Applicative are a widely used class with a wealth of applications (pardon the pun). It enables the eponymous applicative style, a convenient way of structuring functorial computations, and also provides means to express a number of important patterns. Functor recap We will begin with a quick review of the Functor class chapter. class Functor f where fmap :: (a -> b) -> f a -> f b If a type has an instance of Functor, you can use fmap to apply a function to values in it. fmap id = id -- 1st functor lawfmap (g . f) = fmap g . fmap f -- 2nd functor law Maybe, for example, has a Functor instance, and so we can easily modify the value inside it... Prelude> fmap negate (Just 2)Just (-2) Note Déja vu
Roundup: Scala for Java Refugees13 Feb 2008 To be honest, I’m somewhat kicking myself for writing this post. As I’ve said many times: roundup posts are for people who are too lazy to write real content. I can’t tell you how many blogs I’ve come across which have a roundup-to-post ratio of easily 3:1. You know it’s a bad sign when sites start having roundups of their roundups… Meta-roundups aside, I decided (after much deliberation) that a single post linking to all six parts of the series would be useful to one or two people. Of course it’s always possible that you subscribe to my way of looking at things. Part 1: main(String) Introductory article giving motivation for learning Scala and some first steps to “get your feet wet” in the language. Part 2: Basic OOP Looking at Scala’s syntax in a little more detail. Part 3: Methods and Statics Scala’s method syntax is far too powerful to cover in a single post. Part 4: Pattern Matching and Exceptions Part 5: Traits and Types Part 6: Getting Over Java
post-rfc/sotu.md at master · Gabriel439/post-rfcWhy Scala?Before answering the question of "Why Scala?", we first need to answer the question "what is Scala?" From the Scala website, the following overview can be found: Scala is a modern multi-paradigm programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages. Scala is object-oriented: Scala is a pure object-oriented language in the sense that every value is an object. For some developers, these incentives will be enough to lure you away from Java into the Scala world. So, once again, "why Scala?" In a post titled "Scala: The best of both Ruby and Java", Ian describes that it might not be a choice between Java and Scala, but instead the choice to use a combination of Java and Scala as an alternative to other language choices such as Ruby: Many programmers love Ruby, they just can’t get enough of it. Continuing on, Ian notes that: Scala's far from perfect.