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

3
votes
0answers
11 views

Generation and parsing of English numerals (cardinal and ordinal)

I need to use the English numerals (American) in Haskell, so I looked for a library that did it. I have not found one, therefore I developed the program that I am presenting here. There are actually ...
2
votes
1answer
18 views

Sum of multiples of 3 or 5 below N

How do I improve speed of this code? The problem definition is "Find the sum of all the multiples of 3 or 5 below N". ...
1
vote
1answer
38 views

Selection handler for color picker

At some point, I have this function which updates a color picker according the the mouse position, according to whether the user clicked a mouse button and according to its previous state: ...
1
vote
0answers
26 views

Traversing game state space : more search leads to bad results [on hold]

I am trying to solve a problem which i think is TSP on a 2-D grid. So, i am trying to get the best result that i can. However, looking ahead 1 step is producing ...
0
votes
0answers
17 views

Small web service using scotty

I'm writing a small tool that allows to manually protocol dial-in-actions. That means a user can say he dials in to a site or he dials out of a site. (What this means is not important for the sake of ...
1
vote
1answer
27 views

Beauty and the Strings in Haskell

I decided to make a solution in Haskell to a problem that I found on another post here at CodeReview (link: The Beauty and the Strings) I would like suggestions on how to improve letterFreqs. I have ...
0
votes
2answers
59 views

Fast sums of power algorithm

This code reaches time limit on 1 test case, solving this challenge. The approach that I'm using is from the book Algorithms Functional Programming Approach, which is a backtracking depth searching ...
3
votes
1answer
28 views

Generating all size-k consecutive subsets in Haskell

I am interested in splitting any list into consecutive subsets based on a k-value. For example, [1,2,3,4,5] splits into ...
1
vote
0answers
18 views

Implementing `repsep` Parser

I wrote the following repsep parser. It consists of (where ~ means followed by) and + ...
4
votes
3answers
58 views

Prime factorization of an integer

I have just started learning functional programming (Haskell) for fun after using imperative languages my whole life. I am looking for quick and simple tips from pros on how the particular code I just ...
3
votes
1answer
53 views

Haskell Luhn Algorithm

Trying to get to grips with Haskell. The problem is taken from here. ...
6
votes
3answers
96 views

Sieve of Sundaram for Project Euler 7

This is a sequel to my previous question: Sieve of Sundaram for Project Euler 7: Python implementation slower than C++ and R I am trying to implement the Sieve of Sundaram in various languages to ...
0
votes
0answers
12 views

Writing Parser for JSON String [migrated]

As part of trying to write a JSON Parser, I'm working on parsing a JSON String value. Given the following definition from Prof. Brent Yorgey's Haskell course: ...
2
votes
1answer
52 views

Sudoku validator

I've decided to learn some more Haskell writing a Sudoku validator, the function checkSudoku outputs True if the Sudoku is valid and False if it is not. I did not ...
1
vote
1answer
38 views

Naive primality test and summation

I am starting to learn Haskell, so I coded a naive solution to the primality test and summation of primes (Project Euler Problem 10: sum of all primes under 2 million) . As I have an imperative ...
3
votes
1answer
41 views

UpdateGame function for Tetris

I am writing a Tetris game while learning Haskell and I'm trying to make the following code more concise and easier to read. How can I improve it? Note that the function is not finished yet (There is ...
5
votes
2answers
76 views

Integers from scratch in Haskell

Inspired by this article about natural numbers from first principles in swift I implemented integers from scratch in Haskell. Besides obviously being extremely inefficient, is this code idiomatic ...
0
votes
0answers
31 views

Parsec for primes and fibs

I decided to spend some time working with parsec. I've written some code to check for primality and for whether something is a Fibonacci number. I'm mainly hoping for feedback on readability, but if ...
2
votes
1answer
20 views

Haskell: downpair :: (Monad m) => m (a, b) -> (m a, m b) implementation

I'm trying to implement function downpairs which takes monad of pairs and transform it into pair of monad My current implementation is ...
6
votes
3answers
178 views

Print “n” number of “hello world”

I had come up with the following code: ...
3
votes
1answer
30 views

Get list of the executables in the current directory

This is what I've done; ...
1
vote
0answers
21 views

Traversing trees with Lenses

I've recently started learning about lenses and for practice, I wrote a function that finds all paths from the root to a leaf of a tree for which the total of the nodes' weights is equal to a given ...
5
votes
0answers
59 views

Nim game in Haskell implementing optimal strategy

I was inspired by Stas Kurlin's Nim game to write my own. I'm new to Haskell, and quite unfamiliar with monads, do notation, and -- in general -- functional design patterns. In the game of nim, two ...
4
votes
2answers
259 views

Am I thinking functionally in these simple Haskell functions?

I'm learning Haskell using the University of Pennsylvania's online materials. I'm a few lessons in and was looking for some feedback about whether I'm thinking functionally enough or porting over my ...
1
vote
1answer
29 views

Simple command line todo-list

Introduction I've written a simple command line todo-list in Haskell. The full code can be found here. However, given people's time constraints, I have selected three verbose functions for review. ...
5
votes
1answer
57 views

Popping from a list in state while a condition is true

I'm dealing with data that stores its state as a String, treating the string like a stack. I also have to combine that with error handling. To that end, I'm using ...
6
votes
1answer
110 views

Simulate Random Risk Battle

For Prof. Yorgey's 2013 Haskell course, I'm working on a homework to simulate a Risk battle. ...
1
vote
1answer
33 views

Cutting substrings in Haskell

How can I improve readability of this code? indentChar needs to be reused elsewhere. ...
2
votes
0answers
18 views

Auto-expire key/value database (with different key types) in Haskell using acid-state

I am making a key-value database using acid-state. It has three similar "pools", one for cookie records, one for email verification of new accounts, and the last for resetting passwords. There are ...
2
votes
0answers
25 views

One-dimensional convolution using Data.Vector

As part of some code I've written, I needed to perform a 1-D convolution. This convolution ends up happening quite often, so I wanted to optimise it (in some way other than using a FFT, though I could ...
3
votes
1answer
69 views

Google Code jam puzzle - Welcome to Code Jam

Here is the link to the problem for reference. The problem is to find all possible sub-sequences of "welcome to code jam" in a given input string [and only return the last 4 digits of the total] I've ...
2
votes
1answer
64 views

Accessing list elements when counting the number of rectilinear paths

I am trying to solve the RIVALS problem on SPOJ: Starting from (0, 0), how many paths are there to reach point (X, Y), only taking one-unit steps moving to the right or up? Constraints: 0 ≤ X ≤ 106, ...
3
votes
1answer
50 views

All balanced parentheses for a given N

Write a function (in Haskell) which makes a list of strings representing all of the ways you can balance N pairs of parentheses: Example: ...
2
votes
1answer
31 views

Parsing DAG from text

This module allows to parse indented text file into Map from node to child nodes identified by Coordinate. This module seems way ...
2
votes
0answers
32 views

Ray→plane and ray→quad intersection

This checks the intersection between a Ray and a Plane and between a Ray and a ...
2
votes
1answer
39 views

Writing Read instances for HList

I'm a total newbie at parsing, so I figured I'd start by writing instances of Read for HList, which does not currently have ...
4
votes
0answers
60 views

Evaluating Fibonacci-sequence-based recurrence relation (SPOJ Flibonakki)

I have a function fib2 which returning two values as Tuple but I want to print the product of tuples returned by function fib2. I am new to Haskell so please ...
1
vote
2answers
101 views

Haskell monads: sum of primes

They say you cannot get out of the monad, but I need to use the result (at least for assertions / unit tests). But print how does it do it? Otherwise, I worked ...
2
votes
0answers
51 views

Haskell in-place quicksort, Ord a => [a] -> IO [a]

As noted below, this is more or less a direct translation from http://rosettacode.org/wiki/Sorting_algorithms/Quicksort#C. I'm fairly satisfied with its readability right now compared to the C code; ...
1
vote
2answers
39 views

Implementing `sequenceA`

I implemented sequenceA: ...
5
votes
0answers
65 views

Mucheck - a mutation analysis tool for Haskell programs

We have been working on a mutation analysis tool for Haskell tests called MuCheck. It accepts any Haskell source file, and a function name to mutate, applies a defined set of mutation operators on it, ...
1
vote
0answers
50 views

GTK application in Haskell

I'm new to both GTK and Haskell, so I'd appreciate any in both. I'm making an application which for the purposes of this question is just drawing a window that shows a red circle getting larger until ...
7
votes
1answer
44 views

Compile .tex and remove .div file from Haskell

As a practice for interacting with system commands, I wrote a Haskell program that compiles a .tex file specified by the argument. When one execute this program: If no argument is specified, print ...
6
votes
1answer
42 views

'Tis the season for gift-wrapping

When reviewing a Graham scan convex hull algorithm implementation, I wrote the following function in an answer: ...
1
vote
1answer
49 views

Project Euler #4 in Haskell

Project Euler #4 asks: Find the largest palindrome made from the product of two 3-digit numbers. The code is as follows: ...
1
vote
1answer
36 views

Project Euler #3 in Haskell

Project Euler #3 asks: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? I've written a general solution for any number: ...
4
votes
1answer
34 views

Implementing `Applicative Cons`

Given the following definition: data Cons a = Cons a (Cons a) | Empty deriving Show I implemented the following attempt at its ...
3
votes
0answers
33 views

2 4 tree insert function

I'm after creating an insert function for a 2 4 tree in Haskell. I'm just wondering if this is the best way to implement it (especially when handling the Root4s), ...
7
votes
2answers
127 views

Calculating tournament tables

This my first program in Haskell. I'm organizing a ping-pong tournament and I want to calculate a tournament table automatically. The table should contain scores in all games and some statistics ...
0
votes
1answer
33 views

Implement `flatten` for `Cons`

Given the following definition of Cons: data Cons a = Cons a (Cons a) | Empty deriving Show I ...