Skip to main content

Questions tagged [haskell]

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.

Filter by
Sorted by
Tagged with
2 votes
0 answers
25 views

Last Stone Weight Problem in Haskell Using `fold`

A previous solution of this code has been posted on Code Review before. This solution is more complicated then that one, but more performant (see the below) Why is this another Question instead of a ...
WesAtWork's user avatar
4 votes
1 answer
149 views

Last Stone Weight Problem in Haskell using list `insert`

Background Saw this problem on TheJobOverflow which seems to be a LeetCode question. It bothered me that the "challenge" of this problem was to recognize the need for a specific data-type (...
WesAtWork's user avatar
1 vote
1 answer
137 views

Haskell code optimization for short Pi approximator

Very new in Haskell, as a first easy program I went for an old algorithm of mine to approximate pi by counting points within a circle. The snippet below is what I could get working. I had quite an ...
Tsaras's user avatar
  • 147
3 votes
1 answer
97 views

Autocomplete system with prefix tree

I am quite new to Haskell, and this problem is from dailycodingproblem.com: Implement an autocomplete system. That is, given a query string s and a set of all ...
Fin H's user avatar
  • 33
4 votes
2 answers
710 views

Performance of Haskell prime sieve

I have this code, which is a pseudo-Sieve of Eratosthenes for generating primes: ...
Ari Fordsham's user avatar
2 votes
1 answer
89 views

Solve a letter digit substitution game in Haskell

I am working on a Haskell problem from exercism, which is a learn-to-code website. The problem statement is as follows. Write a function to solve alphametics puzzles. Alphametics is a puzzle where ...
lanf's user avatar
  • 123
5 votes
1 answer
143 views

Ackermann-Péter function call count using Writer monad

I'm quite new to Monads and I tried add function call counting to the Ackermann function code. The goal was simplicity, not performance. I want to have code review on the ...
Arpad Horvath's user avatar
2 votes
1 answer
141 views

Tic Tac Toe game (Haskell)

I have written a tic-tac-toe game in Haskell and was wondering if anyone could provide any hints on how it could be improved ...
Dean Menezes's user avatar
1 vote
1 answer
116 views

Count islands in a binary grid

This is the No of Island code challenge. Please review my implementation in Haskell. I know there must be some better way of doing this. Given an m x n 2D binary grid grid which represents a map of '...
presci's user avatar
  • 249
3 votes
3 answers
100 views

Mutable IORef-based factorial example in Haskell

Here is my attempt to write the infamous factorial using Data.IORef. ...
nponeccop's user avatar
  • 1,084
1 vote
0 answers
158 views

Haskell SDL2 Yellow Snow Game. My first program [closed]

I have been working hard trying to learn Haskell, or at least understand it enough to make simple programs. This is my first program. I have been working on it for about a month now. I had already ...
Jeremiah C's user avatar
2 votes
2 answers
88 views

Slow Bioinformatics algorithm - Clump finding algorithm in Haskell

I'm working on the famous clump finding problem to learn Haskell. Part of the problem involve breaking nucleotide sequences, called kmers, into subsequences as follows: ...
plaffont's user avatar
2 votes
1 answer
459 views

Update `ith` element from Array of List[Int] in haskell

I am implementing a function that receives a list of list integers and updates the list appending to the ith element a number x, for example: ...
dpalma's user avatar
  • 165
4 votes
1 answer
223 views

Two Sum Implementation on Haskell Brute Force and Optimized approach

Two Sum Problem: Given an array of integers A and an integer K return True if there are two elements two elements xi, xj (i != j) such that xi + xj = K. Return False otherwise. I am implementing the ...
dpalma's user avatar
  • 165
2 votes
2 answers
76 views

Stepwise nested pattern mattching with exceptions

Background I'm building a lisp-like toy language in Haskell with the following (stripped down) AST: ...
mingmingrr's user avatar
0 votes
1 answer
130 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 ...
Jir's user avatar
  • 201
4 votes
1 answer
81 views

Generate varied values of some parameters over a neighboring interval

I was recently tasked with creating a function that could generate a "varied" version of some collection of parameters. As in, it should take in a list of parameters, and then vary the value ...
horriblehaskell's user avatar
1 vote
1 answer
74 views

Meta Collatz Sequence

Context Chapter 6 of Learn You A Haskell contains a function called chain, which outputs the Collatz sequence of a given input. (In short, it takes a natural number....
Jessica's user avatar
  • 818
1 vote
1 answer
56 views

Random ladder for public-key encryption

...
Pierre Abbat's user avatar
2 votes
0 answers
93 views

Source map file generator

I'm trying to use this library in my haskell program to generate a source map file, but getting some performance issue. The size of the mapping file generated was about 30M bytes, and it took almost ...
freedomhero's user avatar
1 vote
1 answer
151 views

Haskell function that executes each action until a predicate returns True

The following function executes each action from the list until a predicate returns True. I have a feeling that this function can be rewritten using ...
Aleksei Tirman's user avatar
2 votes
1 answer
120 views

Project Euler 11 Haskell - Largest product in a grid

Intro I have been learning haskell and functional programming using random Project Euler problems. Currently, I have solved Problem 11. What is the greatest product of four adjacent numbers in the ...
Naitik Mundra's user avatar
2 votes
2 answers
461 views

Implement a Queue in Haskell

I teach a data structures and algorithms course. Students can choose C++ or Java. As an exercise for myself, I am doing the assignments in Haskell. My primary goal is to understand what aspects of my ...
Jeremy Wright's user avatar
3 votes
1 answer
130 views

Rendering a cross in ASCII art

I've recently tried to write my functions by using composition. But this one, renderCross' is especially difficult to convert fully. How would I write this ...
ola_bandola's user avatar
1 vote
1 answer
121 views

Hangman game in Haskell, written using a state monad

I recently made a simple hangman game in Haskell but soon wanted to explore the state monad, since it could possibly simplify the code. The result was this (see below), which is exactly 30% more lines ...
ola_bandola's user avatar
3 votes
1 answer
145 views

A simple hangman game in Haskell

I just finished a course of functional programming in uni and continued to study Haskell because I found it very interesting! I made a simple hangman game and would like to hear any of your thoughts ...
ola_bandola's user avatar
6 votes
2 answers
857 views

Simple number-guessing game in Haskell

I've been learning Haskell for 2 weeks now which is I'm very new to it. I would like to have feedback on what is good/bad about my code and how it could I improve in learning functional programming ...
JHV's user avatar
  • 63
2 votes
1 answer
147 views

Simple Manual Lexer in Haskell

As a beginner exercise, I made small manual lexer that recognizes three types of inputs: integers: /[-]?[0-9]+/ strings, inside double quotes, with backslash ...
Pierre Arlaud's user avatar
3 votes
2 answers
420 views

Generic splitting in Haskell

I am new to Haskell and took it upon myself to make a simple generic list-splitting (e.g. string-splitting) function: ...
Ethan McTague's user avatar
0 votes
1 answer
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: ...
Jir's user avatar
  • 201
4 votes
1 answer
814 views

Haskell: implementing Read for a custom dynamic value type

I'm using Haskell to interpret a dynamically-typed language. I have a sum type called Value which can represent some basic objects: ...
pxeger's user avatar
  • 143
3 votes
1 answer
136 views

Function to sum all Armstrong numbers within a range

I've tried to solve a challenge posted on a LinkedIn forum using Haskell - a language I'm still learning the basics of - and, while the code works correctly, I would like to get some feedback on the ...
Jir's user avatar
  • 201
1 vote
1 answer
113 views

Manacher Algorithm in Haskell

Please review the manacher algorithm in haskell. Find the longest Palindrome in a String. ...
presci's user avatar
  • 249
5 votes
1 answer
314 views

Validate Finnish IBANs

I am currently studying an online course in Haskell and there are no "model examples" of the assignments after finishing them. I'm slowly getting the hang of this, but I'd like some feedback ...
Apelli's user avatar
  • 87
2 votes
1 answer
118 views

Advent of Code 2021 Day 4

Here is my attempt at Advent of Code Day 4 using Haskell. A file contains list of number in first line. And subsequent lines have the bingo Cards ...
presci's user avatar
  • 249
2 votes
0 answers
77 views

Haskell proof checker for FOL with equality

Is this a correct implementation in Haskell of a proof checker for first order logic with equality? I am most interested in if it is correct, and if the functions can be made clearer. I would like it ...
user695931's user avatar
2 votes
1 answer
177 views

AdventofCode 2021: Day 3 Solution

I am beginner to Haskell. Here is my solution to Advent of Code 2021 Day 3. Let me know what you think. I was looking at the transpose function and decided not to use head & tail function. Given ...
presci's user avatar
  • 249
2 votes
1 answer
70 views

Haskell Twitter Thread Follower

I'm learning Haskell and even though I have experience with Functional Programming the Typesystem has been a challenge. I did this yesterday (after like 2 days) and I would like to know whether this ...
Aguxez's user avatar
  • 157
5 votes
1 answer
442 views

Number to Text converter in Haskell

I've written this code in Haskell to convert a number into its written form. It feels ok but at the same time I feel like it can probably be improved on a lot. I would appreciate help in improving it. ...
noatbfgtxa's user avatar
3 votes
1 answer
247 views

Efficiently calculating perfect powers in Haskell

I'm trying to calculate perfect powers to solve this code wars challenge: https://www.codewars.com/kata/55f4e56315a375c1ed000159/haskell The number 81 has a special property, a certain power of the ...
jdkleuver's user avatar
3 votes
0 answers
188 views

Advent of Code 2021, Day 3 in Haskell

This is a working solution to today's Advent of Code puzzle, written in Haskell. However, I feel like this solution is not optimal. ...
Scriptim's user avatar
  • 131
8 votes
1 answer
577 views

Haskell Tic-Tac-Toe (with automation and GUI)

There are already many Tic Tac Toe posts. But as far as I can tell, none of the ones in Haskell are complete with a GUI Here is my implementation with Gloss. Gist Link for convenience ...
Agnishom Chattopadhyay's user avatar
4 votes
1 answer
1k views

Generate possible combinations by range and length

I am learning Haskell and I implemented a recursive function that generates possible strings by length and array (e.g. ['a'..'z']): ...
Vlad Havriuk's user avatar
4 votes
1 answer
743 views

Is there a better way to apply a filter over an Either right value?

Suppose you have an IO (Either String (String, [Int])) and you want to filter the [Int]. Let's say we want to use the following ...
Julian Espinel's user avatar
5 votes
1 answer
2k views

Reading a CSV file using Haskell

I'm reading a CSV using Haskell. I'm not sure if this is the appropriate way to do it. This is what I'm doing: Read rows from a CSV -> return lazy byte string Parse the headers and rows from the ...
Julian Espinel's user avatar
1 vote
3 answers
87 views

Word frequency finder

Challenge: find the top three most frequently used words in a string. Only imports from the base package are allowed (source: codewars) I'm looking for feedback on (...
cgoates's user avatar
  • 155
5 votes
1 answer
172 views

Small combinator parsing library in Haskell

I recently wrote code to parse lambda expressions written in a lisp like format, using a small hand-rolled parsing library. The goal This code was written as a part of this code-golf challenge not as ...
Sriotchilism O'Zaic's user avatar
1 vote
1 answer
225 views

Finding the argmaximum of a list in Haskell

I've been doing project euler problems in Haskell, and often I've found the need to get the value that gives the maximum of a function. For example, ...
Gus Beringer's user avatar
5 votes
1 answer
391 views

Breadth first search on trees in Haskell

I'm writing a breadth first search algorithm in Haskell that supports pruning. It is guaranteed that the search will never encounter nodes that have been visited before, so I implemented the search as ...
Trebor's user avatar
  • 153
4 votes
1 answer
715 views

Minesweeper in haskell

I have recently been learning Haskell, and wrote a minesweeper project as an exercise. Here is link to the project. Basically the code is separated into two parts, the pure part (no monads) and impure ...
saxo's user avatar
  • 43

1
2 3 4 5
22