haskell

A Gentler Introduction to Functional Programming

I am trying to learn Haskell, and I really like it, but I can't wrap my head around most of it. Would Lisp, OCaml, etc. be a gentler introduction to functional programming? ...

Critique this late night, noob Haskell code

I'm working through Real World Haskell, and at the moment doing the exercises at the end of Chapter 3. I'm taking an unusual approach: even though I know there are some language features they haven't covered yet that would help me, I am trying to do these exercises using only things they have explicitly covered. Why? Just kind of for fu...

Is GHC able to tail-call optimize IO actions?

Will GHC perform tail-call optimization on the following function by default? The only weird thing about it is that it is recursively defining an IO action, but I don't see why this couldn't be TCO'd. import Control.Concurrent.MVar consume :: MVar a -> [a] -> IO () consume _ [] = return () consume store (x:xs) = do putMVar store x ...

Haskell image processing library?

Anyone have a recommendation for a good image processing package for Haskell? Why do you like it? ...

Haskell: Replacing element with a given key in an association list

Hi I've got to make a function to which is given a key (as a string), a value (as a string) and a an association list of keys and values (as [(String, String)]). The function is meant to add the key and value pair on to the end of the list, and, if the key is already present in the list with an associated value, delete the old value. I'...

Why does this Haskell code produce the "infinite type" error?

I am new to Haskell and facing a "cannot construct infinite type" error that I cannot make sense of. In fact, beyond that, I have not been able to find a good explanation of what this error even means, so if you could go beyond my basic question and explain the "infinite type" error, I'd really appreciate it. Here's the code: inters...

Haskell Cons Operator (:)

I am really new to Haskell (Actually I saw "Real World Haskell" from O'Reilly and thought "hmm, I think I'll learn functional programming" yesterday) and I am wondering: I can use the construct operator to add an item to the beginning of a list: 1 : [2,3] [1,2,3] I tried making an example data type I found in the book and then playing...

View Reduction Steps in Haskell

I was wondering if there is anyway to view the reduction steps in haskell, i.e trace the recursive function calls made, for e.g chez scheme provides us with trace-lambda, is there an equivalent form in Haskell, and how to use it? Thanks, Shiv ...

Should I use GHC Haskell extensions or not?

As I am learning Haskell, I see that there is a lot of language extensions used in real life code. As a beginner, should I learn to use them, or should I avoid them at all cost? I see that it breaks compatibility with Haskell 98 and limits code to pretty much GHC only. However, if I browse packages on Hackage, I see that most of them are...

How should I manage side effects in a new language design?

So I'm currently working on a new programming language. Inspired by ideas from concurrent programming and Haskell, one of the primary goals of the language is management of side effects. More or less, each module will be required to specify which side effects it allows. So, if I were making a game, the graphics module would have no abili...

Learning Scala or Haskell

I'm considering dipping my toe in the functional programming world, and wondering if it would be better to start with Scala or Haskell. I'm coming at this primarily as a Python programmer. My only real functional programming experience with functional programming is using Scheme in an intro comp-sci class over a decade ago. Some of th...

Where can I find a full parenthesizer for Haskell?

Is there a way in GHCI to show a fully parenthesized version of a statement? I've found myself wanting to do that sometimes to help me understand a piece of code that I'm not familiar with. Sometimes the conciseness of the masters obscure things for us n00bs, and anything to help me break these beasts apart seems to help. ...

Haskell or Standard ML for beginners?

I'm going to be teaching a lower-division course in discrete structures. I have selected the text book Discrete Structures, Logic, and Computability in part because it contains examples and concepts that are conducive to implementation with a functional programming language. (I also think it's a good textbook.) I want an easy-to-underst...

Haskell parsing tools - yacc:lex :: happy:?

So, it seems like Happy is a robust replacement for yacc in Haskell. Is there an equally robust lexer generator to replace lex/flex? ...

Haskell: looking up the second value of a tuple in a list based on the first value

I've got a function here that is meant to look through a list of tuples and find the second value in the tuple by taking in the first value. Here's the function so far: lookup :: String -> [(String,String)] -> String lookup _ _ [] = "Not found" lookup x y zs = if (notFound x zs) then "Not found" else (head [b | (a,b) <- zs, (a==...

llvm vs c-- ; how can llvm fundamentally not be better for haskell than c-- ?

I've been excited about llvm being low enough to model any system, and saw it as promising that Apple was adopting it; but then again Apple doesn't specifically support Haskell; and, some think that Haskell would be better off with c-- : That LLVM'ers haven't solved the problem of zero-overhead garbage collection isn't too surpris...

How does Haskell know which typeclass instance you mean?

This question arose while reading the new chapter in the excellent Learn You a Haskell about applicative functors. The Applicative typeclass has, as part of the definition for the Maybe instance: pure = Just If I just go to GHCi and import Control.Applicative, and do: pure (3+) I don't get Just anything (makes sense). But if I use...

Multiply two lists element by element in Haskell

How can I multiply the elements of two lists in Haskell, two by two? Basically if I have [1,2,3] and [2,3,4] I want to get [2,6,12]. ...

Compare strings in haskell

I have two strings given as arguments to a Haskell function. s1 is smaller than s2 if s1 is shorter than s2 or if they have the same length and s1 is lexicographically smaller than s2. ...

functional languages (erlang, f#, haskell, scala)

Hi, 1) Are functional languages suited for web applications development ? 2) Are functional languages suited for business/erp/crm type of applications ? ...