Haskell is a purely functional programming language, featuring static typing, lazy evaluation, and monadic effects. The primary implementation is GHC, a high-performance compiler with a runtime supporting many forms of parallelism and concurrency.

learn more… | top users | synonyms

8
votes
1answer
603 views

Simple chat server in Haskell

I've been struggling with concurrent programming in Haskell for a while. It's so hard to reason about, especially when exceptions come into the picture. As a learning exercise, I implemented a ...
5
votes
4answers
535 views

Improving my solution to Project Euler problem #1?

I'm trying to compare my own implementation with another solution of ProjectEuler problem #1, which uses a list comprehension: module Progression1 (sumProgressions) where import Prelude ...
7
votes
3answers
1k views

Nim Game in Haskell

I wrote Nim Game in Haskell. Since I'm just learning any review comments are highly appreciated. module Nim where import Char import List import Maybe --Domain --Nim is a mathematical game of ...
6
votes
4answers
912 views

Approach to string split by character in Haskell

I'm trying to learn Haskell and the mindset of programming functionally. I have started off by trying to understand the basics by writing code without any Monads in it. So far, I think I'm getting ...
10
votes
1answer
120 views

A different code?

I have a xxs list: xxs:: [(([Char], [Char]),([Char], [Char]),[(Double, [Char], [Char])])] xxs = [(("a11","b11"),("a12","b12"), [(0,"a1","b1"),(1.2,"a2","b2"),(2.3,"a3","b3"),(4.2,"a4","b4")]), ...
5
votes
1answer
105 views

Chaining method calls and “bubbling” the results

I need a way to build up a sort of stack of places to search for an item. What I would like to do is to have each layer searched for an item, and if it is found at that level, then it should be ...
4
votes
1answer
229 views

Using Parsec for lexing&parsing

I'm creating list of Tokens from input [Char] stream using Parsec v3. The definition of Token looks like this: data Token = CharKeyword | OpeningBracket | Identifier String | Natural Int As result ...
8
votes
1answer
205 views

How to improve performance of this?

I am still pretty new to haskell and am working on a graph generator for undirected unlabeled graphs containing loops and I have a bottleneck in the following functions. So far, I have not given any ...
4
votes
1answer
158 views

Basic Directory / 'Text entry' create / delete / traversal (bash inspired) in Haskell

I'm new to Haskell and functional programming and I did for training purpose a basic program where you can: create a directory (consisting of a name and an array of sub-directories) create an entry ...
5
votes
2answers
288 views

Sorted Grep: How would you improve this program?

This program implements a sorted grep, that is, a specialized version of grep for sorted files. It uses binary search for the lines of a file that begin with a certain string. You can copy and paste ...
5
votes
3answers
167 views

Each element is the sum of itself with the next element of a List: now do this point-free in Haskell

Here it is the best I can do (I am a noob using Haskell): map (\(y, z) -> y + z) (zip x (tail x)) I'm looking for a point-free solution.
1
vote
1answer
146 views

replace digit at some positions in number

I'm trying to write function, that replace digits at some positions in number. For example f 91521 [3,4] -> [91001,91111,91221,91331,91441,91551,91661,91771,91881,91991] It's behavior like 91**1 ...
3
votes
1answer
120 views

Higher-order way of expressing for-style loop in Haskell

I needed to write a function which would 'error diffuse' floating values to integers: errorDiffuse :: Double -> Int -> Double -> [Int] errorDiffuse _ 0 _ = [] errorDiffuse v num err = ...
9
votes
3answers
600 views

Obvious design flaws in Haskell code (convert to Roman numerals)

As an excercise to "Haskell: The Craft of Functional Programming", I created some code to convert an Integer to Roman numerals. This is the first version and I think I'm probably not doing it in the ...
2
votes
1answer
223 views

A combinatorial algorithm

How could I improve this algorithm? The goal is to organize matches between sport teams such that: Each team affront each other A minimum number of team should start a match after just finishing one ...
1
vote
1answer
261 views

Lazy computation of primes in Haskell

I wanted to give Haskell a try, and I started with a simple exercise I found here. Write isPrime :: Integer -> Bool, which determines whether a given integer is prime. Define primes :: ...
4
votes
2answers
366 views

Enclosing Circle Problem implementation in Haskell

I implemented the algorithm by Pr. Chrystal described here in Haskell so could someone please tell me: Do i have implemented this algorithm correctly? Initial calling of findPoints takes the first and ...
4
votes
1answer
563 views

New Haskell Package: OpenCL

I am developing a high level OpenCL binding in Haskell, and I need peer-review and testing. Currently only get Platform and Device info from OpenCL. http://github.com/zhensydow/opencl Thanks a lot! ...
2
votes
2answers
269 views

Can my solution to TopCoder's BestApproximationDiv2 problem be any better?

Link to problem statement on TopCoder import Data.Char import Data.List import Data.Maybe showResult :: (Int, Int, Int) -> String showResult (a, b, x) = show a ++ "/" ++ show b ++ " has " ...
1
vote
4answers
437 views

Cabbage-Goat-Wolf puzzle in Haskell

Could you please review the following code, and point out how I can make it cleaner, more idiomatic and easier to understand? module Cabbage ( solve ) where data Place = Here | There deriving ...
2
votes
2answers
207 views

How might I improve the structure of this IO based Haskell source?

Moved originally from StackOverflow, not knowing the existence of this sister site ... Must say I find programming in Haskell to require much more cognitive intensity than any other language I've ...
9
votes
1answer
809 views

Prim's algorithm for minimal spanning trees

I want to write an article giving a Haskell introduction specifically to Java developers, and would like to get feedback on my implementation. Please keep in mind that I don't want to be "too clever", ...
9
votes
1answer
771 views

Haskell code critique (simple xkcd comic downloader)

I'd really appreciate some harsh/constructive criticism of what I would consider as my first program in Haskell. The program should download all of the xkcd comics into a folder in the current ...
5
votes
1answer
723 views

Parsing strings with escaped characters using Parsec

I have been working through the exercises in a Write Yourself a Scheme in 48 Hours/Parsing and hacked together something to get parseString to comprehend escaped characters. Also had some inspiration ...
4
votes
2answers
382 views

INI File Parser in Haskell

I'm learning Haskell at the moment, and have just written my first useful module - a parser fo INI files. I used Parsec. I'd like to know what can be improved here - or maybe I did some things ...
2
votes
1answer
322 views

Haskell - Different log methods

I'm pretty new to Haskell and was playing around with some number manipulation in different bases when I had to write an integer logarithm function for my task. I don't mean discrete/modular logs, ...
3
votes
1answer
486 views

Idiomatic haskell database connectivity

In this post I asked about what would be idiomatic haskell database abstraction. I had been thinking for it a while, and the first answer was similar to what I had in mind, and I wrote a ...
3
votes
1answer
163 views

Most elegant approach to writing list renumbering function

I'm writing a function with the following signature: (Ord a) => [a] -> [Int] It's semantics is to find an order-preserving mapping from list of objects to list of Ints. The version of mine: ...
3
votes
0answers
281 views

On Implementing a Lisp

Background: This began with James Colgan's Lisp-Dojo for Ruby. My implementation can be found here. I then moved on to Write yourself a scheme in 48 hours. This question has to do with one of the ...
4
votes
1answer
325 views

Full-precision summation in Haskell

I'm trying to speed up the following code for summing doubles with full precision, based on a Python recipe from Raymond Hettinger. Any thoughts on how to make this go faster? -- Full precision ...
6
votes
3answers
2k views

Towers of Hanoi in Haskell

Of course the recursive version is trivial: hanoi n = solve n 1 2 3 solve 0 _ _ _ = [] solve n from help to = (solve (n-1) from to help) ++ [(from,to)] ++ (solve (n-1) help from to) However my ...
5
votes
1answer
577 views

Baby's First Parsec Attempt

I figured it's about time to get off my ass and jump into some Haskell. So here's a first attempt at an oddly specific SVG parser. import System.Environment import Text.ParserCombinators.Parsec ...
9
votes
2answers
907 views

Game of Life in Haskell

I wondering what people think of this game of life. I don't think it is working properly, but I am interesting in what people think of the general design. module GameOfLife where import Data.List ...
10
votes
1answer
373 views

Converting simple markup to HTML

This is going to be rather long and generic, so apologies in advance. I've been reading a lot about Haskell lately, but I've never really programmed anything with it beyond simple experiments in ...

1 2 3