Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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
47 votes
1 answer
3k views

Charmander Brainfuck interpreter in Haskell

I just started learning Haskell and this is my first big project (ie not factorials, fibonacci or graphers). This is kind of a gift for somebody so the language is a bit different. The program works, ...
Ignis Incendio's user avatar
47 votes
1 answer
1k views

Capture the notion of invertible functions

I find sometimes it is useful to capture the notion of invertible functions. The idea is that if two functions f :: a -> b and ...
Javran's user avatar
  • 591
41 votes
1 answer
2k views

Finding minimum scalar product using ST Monad

Inspired by a Stack Overflow question, I decided to practice my Haskell by taking a crack at the Google Code Jam's Minimum Scalar Product problem: Given two vectors \$\mathbf{v_1}=(x_1,x_2,\ldots,...
rampion's user avatar
  • 563
31 votes
4 answers
5k views

I can has(kell) cheezburger?

Edit 13 June: I have made a new and improved version here. Original Question This is a very rudimentary lolcats translator (it only works on the phrase "Can I have a cheeseburger") in ...
Michael Brandon Morris's user avatar
27 votes
1 answer
1k views

How can I make my stack monad faster?

I made a stack monad that lets one manipulate and control values on a stack. I want to know if it's correct (it seems correct), how to make it faster, and how I could detect stack overflows without ...
Ms. Molly Stewart-Gallus's user avatar
23 votes
2 answers
2k views

Calculating Luhn-algorithm checksum digit

Today I decided to learn some basic Haskell, and for starters I made a program for calculating the checksum of a Swedish personal identification number. It uses the Luhn-algorithm, aka. ...
Simon Forsberg's user avatar
23 votes
1 answer
1k views

Decoding Factorio blueprints in Haskell

In the game Factorio there are string-encoded representations of blueprints that I wish to decode. The implementation according to their wiki is the following: This is a technical description of the ...
skiwi's user avatar
  • 10.6k
23 votes
0 answers
399 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, ...
Rahul Gopinath's user avatar
19 votes
3 answers
1k 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 ...
orome's user avatar
  • 401
18 votes
1 answer
5k views

Execute a function n times, where n is known at compile time

Motivation In this question, a user asked whether it is possible to inline the following function: ...
Zeta's user avatar
  • 19.3k
16 votes
2 answers
1k views

Recursive directory tree printer

I wrote this program that recursively prints all the files and directories starting at the current directory: ...
hao's user avatar
  • 486
16 votes
1 answer
1k views

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 ...
adrian's user avatar
  • 371
16 votes
0 answers
3k views

Realtime concurrent Haskell MIDI buffer

Problem Background MIDI is a serial representation of control signals to a sound generator. Typically, a noteOn message initiates the attack phase of a sound at a given pitch. The note will ...
user1441998's user avatar
15 votes
4 answers
2k views

How to shorten this terrible HTTP header parser?

I am trying to read a line ending in \r\n from a Handle. This is an HTTP header. I’m fairly new to functional programming, so I ...
daknøk's user avatar
  • 664
15 votes
3 answers
4k views

Converting 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 "...
user avatar
15 votes
4 answers
3k views

Script for copying files to the appropriate directory

In the book Real World Haskell, the author writes in the first line of every file that uses, for example the following: file: ch05/PrettyJSON. The chapter slash and ...
Dragno's user avatar
  • 285
15 votes
2 answers
337 views

Interactive Brainfuck interpreter in Haskell

Last week I started learning Haskell, and since I have some experience with Brainfuck already, I decided it would be a great idea to implement an interactive Brainfuck interpreter in Haskell. I'll ...
skiwi's user avatar
  • 10.6k
15 votes
2 answers
6k 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 ...
sh54's user avatar
  • 283
15 votes
3 answers
3k views

A Haskell implementation of Conway's Game of Life, viewable on the console, no external libs

This is a Haskell implementation of Conway's Game of Life. It plays on a console. It should be able to play a field of any size, but we only give it a glider on a small field to run at this point. ...
Aaron Hall's user avatar
  • 1,568
15 votes
1 answer
1k views

Finding Local Maxima

The following function finds all local maxima. A local maxima is an element of a list such that it's greater than either of its neighbor elements. An element with 1 neighbor is not a local maximum. <...
Kevin Meredith's user avatar
15 votes
2 answers
275 views

One, two, three, … Un, deux, trois, …, maxBound::Int

I wrote a numbers-to-words converter for English, then tried to adapt the code to work for French. I'm wondering mainly whether any simplifications are possible. In English English is relatively ...
200_success's user avatar
14 votes
3 answers
1k views

Using Fibonacci sequence to generate musical melodies

I recently started picking up the Haskell programming language. I've managed to learn other languages rather quickly, but I'm still having a difficult time grasping some of the basics of Haskell. I ...
Jake Rieger's user avatar
14 votes
2 answers
4k views

Blackjack in Haskell

This is my first attempt at creating a game in Haskell, and I would greatly appreciate some feedback. Here is Main.hs: ...
Colin Ray's user avatar
  • 143
14 votes
1 answer
20k views

Boolean expression parser

I was trying to write some of the Haskell list functions into Java, and I realized that one of the key strengths for many of the functions was the ability to pass in a boolean expression. I decided to ...
Azar's user avatar
  • 385
14 votes
1 answer
646 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 ghci....
shang's user avatar
  • 301
14 votes
1 answer
2k 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", ...
Landei's user avatar
  • 6,982
13 votes
2 answers
467 views

Resistance is futile, Resistors have been dispatched to model your Resistance

Since it was getting boring to always do OOP Languages I decided to dabble in the functional realm of programming. For that I chose the narrowly missed community-challenge by Edward: Resistor Mania, ...
Vogel612's user avatar
  • 25.2k
13 votes
3 answers
466 views

Haskell FizzBuzz with a type system

The core problem is simple enough, but I've developed a type system that I'm not sure about. The intention is, if the result is a number, calling num $ fizzBuzz 16,...
200_success's user avatar
13 votes
1 answer
1k views

Haskell Particle Simulation

I recently started learning Haskell and as my first project I decided to port a particle simulation I had written in C. The simulation is pretty simple. We have a cubic box with particles (spheres) ...
Grieverheart's user avatar
13 votes
1 answer
2k 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 ...
John Tyree's user avatar
13 votes
1 answer
307 views

Brainfuck to NASM compiler in Haskell

After reading this article on writing a Brainfuck interpreter in Haskell and achieving awful performance with it (for example, mandelbrot generating 37.5 minutes on an old Intel Atom powered laptop) I'...
atmostmediocre's user avatar
12 votes
3 answers
5k views

Given a Haskell list, return all sub-lists obtained by removing one element

I am trying to write a Haskell function which takes a list ls and returns all sub-lists obtained by removing one element from ls....
Paul's user avatar
  • 223
12 votes
4 answers
18k 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 ...
rzetterberg's user avatar
12 votes
2 answers
1k views

Vigenère Cipher in Haskell

I wrote a Vigenere cipher in Haskell, but I feel like I way overdid it. This is the second version of the program that allows custom cipher tables, removing the limit of just having letters from A to ...
Electric Coffee's user avatar
12 votes
1 answer
2k views

DFA and NFA in Haskell

I've written a determinstic & non-deterministic finite state machine. I've scrubbed the code quite a bit but I wonder if it could perhaps be scrubbed even more. Suggestions for code clarity, ...
wei2912's user avatar
  • 1,233
12 votes
1 answer
2k 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 ...
Joey Adams's user avatar
12 votes
2 answers
700 views

Compute the perimeter of a polygon

This is taken from HackerRank, which I hope is okay. I've been playing around with Haskell and I haven't really been able to find anything that really goes beyond toy examples in terms of how to ...
Daniel McLaury's user avatar
12 votes
1 answer
785 views

Finding the next higher digital permutation of a number

This is my solution for CodeEval challenge 44. You are writing out a list of numbers.Your list contains all numbers with exactly Di digits in its decimal representation which are equal to i, for ...
sjakobi's user avatar
  • 428
12 votes
1 answer
1k 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 ...
wei2912's user avatar
  • 1,233
12 votes
1 answer
212 views

Solving alethic modal logic formulas using truth trees

Disclaimer: this first section is about alethic modal logic and truth trees. It's important to the question but significant parts of the code can probably be reviewed without it. You're welcome to ...
overactor's user avatar
  • 654
11 votes
4 answers
2k 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 ...
Garry Cairns's user avatar
11 votes
2 answers
2k 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. ...
Jonathan Fischoff's user avatar
11 votes
3 answers
2k views

PPM/PGM Image processing library in Haskell

I've written a small library for reading and writing PGM/PPM images. The format is described here. I attach the library itself and a small utility to convert binary encoded images to ASCII encoding. ...
darwish's user avatar
  • 285
11 votes
2 answers
174 views

"Vc" as in Vancouver, or Valencia?

It is common to shorten city names when writing, or at least in Sweden. "Göteborg" (Gothenburg) is often referred to as "Gbg" "Uddevalla" is commonly written as "Ua" "Trollhättan" is often written as ...
Simon Forsberg's user avatar
11 votes
1 answer
566 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 ...
John F. Miller's user avatar
11 votes
1 answer
192 views

A different code?

I have a xxs list: ...
Nomics's user avatar
  • 219
11 votes
1 answer
821 views

The ugly Christmas tree, Haskell style

Inspired by a few inverse tree ascii art F# questions, I wanted to give it a shot in Haskell. As seen in the linked questions, the resulting program reads an Int ...
joranvar's user avatar
  • 992
11 votes
1 answer
1k views

My first Haskell: dice rolling

Yesterday morning I decided to stop procrastinating and start learning me some Haskell. So far I've made this, which is a simple cli 'dice rolling' utility that can be used like: ...
Anentropic's user avatar
11 votes
1 answer
1k 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 ...
Ted Sperling's user avatar
11 votes
1 answer
464 views

Telegram bot in Haskell using custom monad transformers

Note: I show almost all of my code for completeness, but I really only want the review to focus on Session.hs, Handler.hs, and maybe Controller.hs. I can delete the extra code from the review or ...
Me again's user avatar
  • 176

1
2 3 4 5
22