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

14
votes
3answers
557 views

Enigma machine simulator - improving recursive algorithm performance

I'm new to Haskell and am confused by why my code seems to preform so poorly, and wonder if there's something I've not grasped about the coding philosophy behind the language, or the best way to take ...
8
votes
1answer
43 views

Racetrack game with reading the track from a file

For this community challenge I made the racetrack game. I'm reading the race data from a text file, which is available here. This is only playable by entering the velocity at the console. I've got ...
2
votes
0answers
27 views

Python tokenizer in Haskell + Parsec

I wrote a tokenizer/lexer (difference?) for Python in Haskell: this is my code on GitHub. I already tested it out with some of CPython's standard library scripts, and it doesn't fail. However, it ...
5
votes
0answers
48 views

First SO chat message in Haskell followup

I have wrote an application which asks for the user id, and returns a link to the first available chat message: Output Enter user id: 322395 Fetching data... ...
4
votes
1answer
47 views

HackerRank - Candies

Here is the solution I've written for Hacker Rank Candies challenge. It uses dynamic programming (memoization in a boxed array). I'm interested on what could be done to improve this code in term of ...
1
vote
1answer
58 views

Project Euler Problem 50 in Haskell

The prime 41, can be written as the sum of six consecutive primes: 41 = 2 + 3 + 5 + 7 + 11 + 13 This is the longest sum of consecutive primes that adds to a prime below one-hundred. The ...
4
votes
1answer
41 views

Euler Problem 101 - Optimum polynomial

Here is my solution in Haskell for the Euler problem #101. It relies on building a specific base of polynomes given the values we want to fit (memories of my linear algebra courses from a long time ...
4
votes
0answers
39 views

Find first SO chat message in Haskell

I have made some simple functions to find the first SO chat message. How can I improve my code? Even if there is a stackoverflow link that will get the job done (I'd be glad to know), I'd like to ...
5
votes
1answer
55 views

Untouchable Numbers

I wrote this program in response to a CodeGolf challenge that required generating this sequence of "untouchable" numbers. This sequence can be found on OEIS as A005114. My initial implementation was ...
2
votes
1answer
64 views

General TicTacToe in Haskell

I decided to take a more general approach while implementing the TicTacToe game in Haskell. Util ...
5
votes
1answer
72 views

Parsing and plotting complex numbers

I am trying to write a Haskell application that parses a bunch of complex numbers from a Mathematica output and then produces a PPM image. The end product looks like this: The code to create this ...
4
votes
1answer
50 views

TicTacToe game in Haskell

As a beginner, I tried to implement TicTacToe in Haskell. How can I improve my code? I have refactored my code: General TicTacToe in Haskell Utils ...
5
votes
1answer
51 views

Returning all possible player moves on a board

Recently I started to learn Haskell. I did this by making exercises on the Internet. The problem of making these exercises is that I never know if I solved it the correct way. I currently wrote a ...
2
votes
1answer
47 views

Computing all Tic-Tac-Toe moves

Recently I started to learn Haskell. I did this by making exercises on the Internet. The problem of making these exercises is that I never know if I solved it the correct way. I currently wrote a ...
3
votes
1answer
31 views

Merge adjacent numeric intervals

Given a list of pairs of integers that represent closed numeric intervals, I need to output a list of intervals where the adjacent intervals are merged together. The code assumes that the intervals do ...
4
votes
0answers
39 views

Simple Echo Server

I wrote this echo server in Haskell as a way to introduced myself to programming with sockets in Haskell and generally practice Haskell. The echo server has a simple purpose: accept connections from a ...
2
votes
1answer
65 views

Parsing a component of a regex followed by an optional quantifier character

I have a piece of parsec code that parses a unit optionally followed by ?, + or ...
2
votes
1answer
30 views

Reading numbers from a file with lazy ByteString

This is my code for lazily reading a very large file which contains numbers separated by a new line character. Is there a way to simplify this using the ByteString ...
6
votes
2answers
70 views

String sequence in Haskell

Given a string sequence and a string, the function should output the next string of that sequence. For example, for sequence "abc": ...
5
votes
1answer
72 views

Permutations of a list in Haskell

I have this piece of code which given a list returns another list which combines every element with every other element (without repetitions) using a given function as a combiner. I came up with three ...
1
vote
1answer
42 views

Find disjoint integer intervals

Given a list of numeric intervals in the form of (a,b), where a and b are integers, it finds ...
5
votes
1answer
28 views

Implementation of Set data type in Haskell

I'm an advanced beginner Haskell programmer. I implemented a set data type in Haskell and I wanted to find out if I made correct choices when writing it. Would there be a way to improve some of the ...
6
votes
3answers
99 views

Project Euler problem 92 (sequences formed by the sum of squares of digits) in Haskell

I made the following program in Haskell to solve Project Euler's problem 92. The program works (i.e. the solution it yields is correct), but it's not exactly the fastest in the world. The problem is: ...
4
votes
2answers
57 views

Handling request errors in snap with haskell

I'm currently taking a look at Snap with Haskell. I'm pretty new to Haskell and functional programming in general and am working out the best way to handle errors. Currently I have something like this ...
6
votes
1answer
61 views

Finding most frequent words from Google N-Gram dataset

I have written a program to process Google 1-Gram dataset in order to obtain the list of most frequent words. This is my second more or less working program in Haskell, so I really want to know if it ...
7
votes
1answer
109 views

Implement Fibonacci with `iterate`

I implemented the Fibonacci sequence using iterate. ...
6
votes
1answer
61 views

Generating prime candidates

I'd like to generate an infinite list of prime candidates of the form 6k±1, but I'm looking for the fastest possible solution. Currently I have this: ...
3
votes
1answer
41 views

Parsing characters with parsec

I am trying to parse escape sequences as well as plain characters. Can this be made more succinct? ...
5
votes
1answer
42 views

Type Validation using State Monad

I am attempting to build a compiler for a stack-based (or concatenative) programming language in Haskell. I've done fine getting the lexer and parser up and running, but now that I'm into the meat of ...
4
votes
3answers
70 views

Append the contents of latest Stackage nightly build to the global cabal config file

I've made the following python script to to append the contents of the latest Stackage nightly build to the global cabal config file (instead of going to the site, copying the page and appending it ...
5
votes
2answers
63 views

Applicative permutation to generate knight moves

I want to understand Haskell better by trying to stretch possibilities of Functor, Applicative, and Monad as much as possible and study how they behave. So in Learn You a Haskell there's an exercise ...
1
vote
0answers
139 views

Using recursion schemes to avoid explicit corecursive unfolding

The code is self-contained and self-explaining. I want to improve the goal function. You can change everything below the ...
1
vote
1answer
55 views

Sum of Multiples

A different approach than this question, this time without using arithmetic progression. The README specs both sumOfMultiples and ...
-1
votes
1answer
48 views

Function to Map `[a] -> [[a]]` [closed]

Given [1,2,3], I wrote the following to get [[1],[2],[3]]: ...
5
votes
1answer
86 views

Finding word acronyms for telephone numbers

Having read most of Learn You a Haskell as well as parts of Real World Haskell, I decided to embark on an easy project to see if I can apply the Haskell that I've learned. ...
3
votes
2answers
71 views

Sum Arithmetic Progression in Haskell

I am learning Haskell and as exercise I am doing Project Euler Problems. In this case PE1. ...
5
votes
1answer
32 views

Safe stack operations with lens

I wrote this code to learn how to work with State monad. Then I added Either result to gracefully handle error condition (stack underflow). I believe most of this code is actually unnecessary. I know ...
10
votes
1answer
144 views

Counting unordered factorizations with distinct parts

Trying to solve this combinatorics problem, I wrote some functions to count the number of unordered distinct factorizations of an integer n into ...
1
vote
2answers
96 views

Speedup for Project Euler 44 - pentagon numbers

I'm trying to solve the problems of Project Euler with Haskell within less than 10s with optimized code (ghc -O2). Unfortunately, I'm struggling to find a correct ...
4
votes
3answers
164 views

Phone List challenge

To learn Haskell, I've been going at this challenge, which is to check a list of phone numbers to ensure that no number is a prefix of another. However, my code is way too slow. I am really new to ...
6
votes
0answers
71 views

Just another Graham scan implementation in Haskell

It looks like this is a really classical question, but I'd like to ask it one more time as all those solutions look quite long and complicated for me (maybe because I am dumb :) ) So this is a Graham ...
2
votes
1answer
84 views

Generating alphanumeric combinations

I was happy with my shell script that needed to generate alphanumeric combinations of length N (in this case, 3) for i in {a..z}{a..z}{a..z}; do ... Now I became ...
10
votes
1answer
118 views

Detecting cycles in a directed graph without using mutable sets of nodes

I recently came across the classic algorithm for detecting cycles in a directed graph using recursive DFS. This implementation makes use of a stack to track nodes currently being visited and an extra ...
10
votes
3answers
274 views

Project Euler #1 in Haskell

Looking for feedback/critiques/alternatives to my solution for the 1st Project Euler question: ...
4
votes
1answer
99 views

Fake Marquee Text in Haskell

This is my very first complete, non-completely-trivial Haskell program, and I'm extremely unfamiliar with the language. I was hoping that I could get some pointers on how to make it more idiomatic. ...
12
votes
1answer
106 views

m,n,k-game (i.e. generalized tic-tac-toe)

I'm back after Tic-Tac-Toe in Haskell with a new version. I added Haddock documentation and wrote a generalized version known as the m,n,k-game. By doing so, I had to redefine ...
7
votes
1answer
84 views

Snake in Haskell

I wrote a partial implementation of Snake in Haskell. As of now, it only supports the movement of the snake. However, since the code is getting complex, I'm requesting for a review of the code before ...
7
votes
1answer
70 views

Fermat Factorization

Please review my implementation of Fermat's Factorization. ...
1
vote
1answer
33 views

Append Tuple to Two `Maybe []`

The following function appends a tuple to two Maybe [a]'s. ...
2
votes
1answer
26 views

Mixing Lens operations with “original” operations

Is it reasonable to mix Control.Lens operations with the ones provided by the "standard library"? Consider the following fragment using qualified ...