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.

1,080 questions
Filter by
Sorted by
Tagged with
1 vote
225 views

### Over-engineered fizzbuzz

I've got this fizzbuzz project I am using for a blog series, among other things. In this version, the fizzbuzz function is fed from a Fibonacci generator. I'm particularly concerned with the ...
1 vote
864 views

### Expression parser in Haskell using operator precedence table

This is my first non-trivial Haskell project, an expression parser implemented using the Pratt Parser's technique for managing precedence as a layer on top of Parsec. It simply builds an expression ...
• 421
112 views

### Chaining Applicatives

I wrote this code to append Maybe's: ...
• 3,193
793 views

### All possible combinations of colors for Mastermind

Just started out with CIS 194 on Haskell and wonder what the more idiomatic way to solve this problem would have been. This code is supposed to generate all possible combinations of 6 given colors up ...
• 728
8k views

### Producing all possible combinations of a list

I've written a function that produces all combinations of elements in a given list: ...
74 views

### Haskell solution to Day 2 problem of Advent of Code '21

I won't restate the problem in full, but in a nutshell you have to parse a file with a "direction" and a "magnitude", for instance: ...
• 201
105 views

### Unbalanced Parenthesis correction

I'm prepping for a coding interview, and am examining the task of correcting unbalanced parentheses. The finger tree seems to be the right data structure. As a proof of concept I've used ...
2k views

I was working on Haskell Problem 21: Insert an element at a given position into a list. Example: * (insert-at 'alfa '(a b c d) 2) (A ALFA B C D) I have ...
• 368
131 views

### Unit testing and alternative to mocking in Haskell

Let's say you have a simple pure function that applies a discount of 30% if the total price of a list of Items is over 30.00 (let's not delve into the fact that I'm ...
• 201
411 views

### CRUD App in Haskell with Servant/Opaleye

I was trying to learn how to use libraries like Opaleye and Servant. I wrote this toy Create/Read/Update/Delete App. ...
70 views

### Optimized list filtering on implementation of Project Euler 23

I'm new to Haskell, the part of my code I'm concerned with is the isSumAbundant function. Surely there must be a better way, in an imperative language I might use a ...
266 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 ...
64 views

### Squashing multiplication identity in an expression

I'm learning Haskell, and one exercise was to implement squashing of identity-multiplications, e.g.: $5 + (2*1) => 5 + 2$ Here is my implementation: ...
• 591
274 views

### Pure fixed length queue

I am modeling an infectious disease with a fixed incubation period. I chose a queue to keep track of when people become symptomatic. I imagined using some operations like so: ...
216 views

### Sum of fractions

Objective: Create a function to sum a list of fractions (represented as pairs) Rules Only Prelude functions allowed Notes I was debating if I should create a ...
• 155
296 views

### Pairwise summation in Haskell, take two

Here's my second try at pairwise summation in Haskell: ...
• 218
45 views

### Find a n x m binary matrix with exactly a 1's in all rows and b 1's in all columns

[Base on https://codeforces.com/contest/1360/problem/G] So my logic is to process each column at a time and find b rows such that the total 1s in them is less than ...
• 1,456
32 views

### Apply labels from a stream to a Bitraversable

Labelling Traversable containers is an ancient and honorable test of skill. My task here is to create a generic labelling mechanism for a ...
54 views

### Using foldl to add numbers, while validating that they are nonnegative

I have a function that will calculate the sum of a list of integer, however if any of the number is negative, it will should an error instead (not throwing exception). The following is a working ...
• 141
114 views

Here is one a handler for dealing with logins, I've recently refactored it to try and make dealing with the different error cases a bit more elegant, though I still think there is room for improvement:...
• 247
360 views

### Project Euler # 3 in Haskell: largest prime factor of some number

The program works, but is extremely slow. Project Euler problem 3 Problem: What is the largest prime factor of the number 600851475143? ...
• 159
55 views

### Foldr code snippet

The function traverse takes an element and a map, and returns another element and a new (updated) map. Given a list of elements ...
• 273
165 views

### Finding Largest Integer Palindrome within a Set

I've "solved" Project Euler Question 4 and I was wondering if I could make my answer more efficient (I'm using Project Euler to help me learn Haskell). The problem reads: Find the largest ...
112 views

### Naïve optimization by stepping until the error falls below a threshold

As an exercise, I wanted to rewrite this toy Python code in Haskell: ...
49 views

### Automation of entity reading in yesod

I'm trying to automate entity reading in my yesod application. This is what I have: ...
400 views

### Reinforcement learning example (chap. 1) from Sutton's book

I ported the Lisp Tic Tac Toe code from Chapter 1. to Haskell. The original code repo is down for some reason. I believe I have completely rewritten that in Haskell (Less functional than one would ...
70 views

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

Given [1,2,3], I wrote the following to get [[1],[2],[3]]: ...
• 3,193
73 views

### Capture some state in Haskell

I want to capture some state in a Haskell function. For instance, I have many thread trying to print on the console and I want the to play nice with each other. So I want to have some XX to make the ...
• 171
866 views

...
• 159