haskell

Getting the Local AppData folder in Haskell

Hi, I'm trying to get the location of Window's Local AppData folder in a version-agnostic manner using Haskell, and I'm having a bit of trouble doing so. I've tried using the System.Win32.Registry library, and I was able to get the code below (after some trial and error), but I wasn't able to figure out how to use the regQueryValueEx or ...

Haskell: Algebric data types whose type variables need to be an instance of a typeclass

I am trying to define an algebric type: data MyType t = MyType t And make it an instance of Show: instance Show (MyType t) where show (MyType x) = "MyType: " ++ (show x) GHC complains becasue it cannot deduce that type 't' in 'Show (MyType t)' is actually an instance of Show, which is needed for (show x). I have no idea where an...

Introduction or simple examples for iteratee?

I find Oleg's docs on Iteratee somewhat difficult to get into. Especially since some of the functions in his posts to Haskell-Cafe aren't in the iteratee library (like enum_file). Is there a good introduction to iteratee somewhere, something that goes through basics like opening a file/socket, reading and processing the data. ...

Haskell: -fglasgow-exts should one avoid code that requires this?

I am a beginner with Haskell and I've started seeing errors similar to: Illegal parallel list comprehension: use -fglasgow-exts I am working within ghci and with ghc but only due to the fact that it was the first one I found on a search. I'm curious if this is the type of situation one would want to avoid moving forward. Any searche...

How do I remove every occurance of a value from a list in haskell using Prelude?

I want to remove every occurance of a certain value from a list. I have written a function to do this: removeall val [] = [] removeall val list = if (head list) == val then removeall val (tail list) else (head list):(removeall val (tail list)) but I would like to use Prelude if possible for re...

Summation notation in Haskell

On the Wikipedia page about summation it says that the equivalent operation in Haskell is to use foldl. My question is: Is there any reason why it says to use this instead of sum? Is one more 'purist' than the other, or is there no real difference? ...

Haskell: type inference and function composition

This question was inspired by this answer to another question, indicating that you can remove every occurrence of an element from a list using a function defined as: removeall = filter . (/=) Working it out with pencil and paper from the types of filter, (/=) and (.), the function has a type of removeall :: (Eq a) => a -> [a] -> [a] ...

Is there an encyclopedia/list of common type classes in Haskell?

Is there any website that lists and describes common type classes in Haskell? ...

How does Type Deduction work in Haskell?

I'm trying to broaden my mind by learning Haskell. My self-inflicted homework was to build a clock-tick generator which would give me Poisson-distributed intervals, and the end result (after a long struggle, I admit) was this: import System.Random poissonStream :: ( Ord r, Random r, Floating r, RandomGen g) => r -> r -> r -> g -> [r] ...

Haskell, HDBC, ODBC, MySQL and Mac OS X

I'm trying to use Haskell (version 6.10.3) and HDBC to connect to a MySQL Database. I've chosen to do it with Haskell ODBC. I've used cabal to install HDBC (2.1.1) and HDBC-ODBC (2.1.0.0). I've downloaded and installed the MySQL ODBC driver (5.1.5). I used macports to install unixODBC (2.2.14_1). All of this on top of Mac OS X (10.5.8). ...

Mysterious word ("LPS") appears in a list of Haskell output

I am new to Haskell and trying to fiddle with some test cases I usually run into in the real world. Say I have the text file "foo.txt" which contains the following: 45.4 34.3 377.8 33.2 98.4 456.7 99.1 44.2 395.3 I am trying to produce the output [[45.4,34.3,377.8],[33.2,98.4,456.7],[99.1,44.2,395.3]] My code is below, but I'm get...

What factors could determine whether Clojure, Scala or Haskell will gain traction?

Given that it's impossible to see into the future, what factors related to Clojure, Scala or Haskell are likely to determine whether one of them catches on? Are there cultural or economic issues that could give one of these languages an advantage over the others? Or are none of these languages likely to gain traction because of their c...

Which Haskell XML library to use?

I see that there is a few of XML processing libraries in Haskell. HaXml seems to be the most popular (according to dons) HXT seems to be the most advanced (but also the most difficult to learn thanks to arrows) xml which seems to be just the basic parser HXML seems to be abandoned tagsoup and tagchup libXML and libXML SAX bindings So...

Algorithm to create fair / evenly matched teams based on player rankings

I have a data set of players' skill ranking, age and sex and would like to create evenly matched teams. Teams will have the same number of players (currently 8 teams of 12 players). Teams should have the same or similar male to female ratio. Teams should have similar age curve/distribution. I would like to try this in Haskell but the...

Is there a modeling language for the functional programming paradigm?

UML is a standard aimed at the modeling of software which will be written in OO languages, and goes hand in hand with Java. Still, could it possibly be used to model software meant to be written in the functional programming paradigm? Which diagrams would be rendered useful given the embedded visual elements? Is there a modeling languag...

Haskell function pattern-matching issues

I'm doing some homework and while I have some experience with SML, Haskell has some oddities. Consider this simple function: type Pos = (Int, Int) data Move = North | South | East | West move :: Move -> Pos -> Pos move North (x,y) = (x, y+1) move South (x,y) = (x, y-1) move East (x,y) = (x+1, y) move West (x,y) = (x-1, y) moves :: [M...

Cabal won't get a new haskell package

Hi I tried to get the wxHaskell package using cabal using: cabal install wxcore --global cabal install wx But running this gave the following error: >cabal install wxcore --global Resolving dependencies... cabal: Error: some packages failed to install: wxcore-0.11.1.2 failed during the configure step. The exception was: sh: runGenPro...

Autoindenting Haskell in Vim

I started playing with Haskell and I use Vim. I have autoindent on in my vimrc, but it seems to not be aware of haskell somehow. I would like to autoindent work in some cases where it doesn't (for example, after = and newline). How can I customize autoindentation rules in vim? (I googled it, but every site suggested turning autoindent...

Finding advanced programming classes

I have an intense job and large family. Finding time and energy to explore/expand technical skills on my own is difficult. I'd like to find some courses on advanced software topics without having to enroll in a PhD program. I'm not quite sure where to start. There are some great resources out there for learning different programming top...

How to format numbers according to locale in Haskell?

In Python I can use locale.format to pretty-print numbers according to locale setting: >>> import locale >>> locale.setlocale(locale.LC_ALL, "en_US.UTF-8") 'en_US.UTF-8' >>> locale.format("%.2f",1234567.89,grouping=True) '1,234,567.89' How can I do the same in Haskell? I see that there are localeconv and setlocale bindings, but is the...