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

TicTacToe in Haskell

Are there any ways which I could improve and simplify this code? Is my code idiomatic Haskell? Is the use of a lens library to change an element of a two-dimensional array unnecessary? If so, how ...
wei2912's user avatar
  • 1,233
6 votes
3 answers
723 views

UPenn Homework 3: skips function

I've started learning Haskell by following along the CIS 194 Course from UPenn. In the first lessons there is talk about wholemeal programming and certain ways idiomatic Haskell code looks like. Now, ...
hasnoob's user avatar
  • 137
10 votes
2 answers
6k views

Implementing nub (distinct)

I've implemented the following nub' or "give distinct elements of list" function: ...
Kevin Meredith's user avatar
8 votes
2 answers
780 views

Tic Tac Toe game in Haskell

...
yasar's user avatar
  • 1,497
6 votes
1 answer
59 views

Searching a Join List for an index Attempt #2

Originally I posted this incorrect attempt - Searching a Join List for an index. Given a JoinList: ...
Kevin Meredith's user avatar
5 votes
3 answers
726 views

FizzBuzz up to 99 in Haskell

This code solves the problem of FizzBuzz. Is it possible in any way to improve it? ...
True's user avatar
  • 53
5 votes
1 answer
83 views

Retrieve annotation from a tree annotated with a Monoid

Working on this homework from 2013 for self-learning. For the following Algebraic Data Type: ...
Kevin Meredith's user avatar
4 votes
2 answers
696 views

UPenn CIS 194 Homework 1: Validating credit card numbers

I am working through UPenn CIS 194: Introduction to Haskell (Spring 2013). Since I am not able to take the course for real I am asking for CR (feedback) as it could be from teacher in that course. HW1 ...
drets's user avatar
  • 261
4 votes
1 answer
262 views

Tic Tac Toe game in haskell follow up

This is a follow-up question of this one: Tic Tac Toe game in Haskell I have revised my code. How does it look now? ...
yasar's user avatar
  • 1,497
2 votes
1 answer
147 views

Haskell Brainf*ck interpreter: runtime error handling

I have designed a Brainf*ck interpreter in Haskell. I would appreciate the code review, especially any tips related to error handling (e.g. parsing errors, runtime errors, etc.). ...
penkovsky's user avatar
  • 155
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
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.7k
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
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
10 votes
2 answers
636 views

Naive Bayes classifier

I just started learning Haskell, and I must say it is unlike anything else. As my first not-entirely-trivial piece of code I tried to write a simple Bayes Classifier. It is in two parts, a classifier ...
V9801's user avatar
  • 203
8 votes
2 answers
329 views

Log messages parser

I've been studying Haskell for some time, but I have never used it for real. So, I started following the CIS 194 Course from UPenn. I resolved the second homework but I'm not fully satisfied with the ...
Lucas Kreutz's user avatar
8 votes
2 answers
2k views

Graham Scan convex hull algorithm

I'm beginning to learn Haskell. I've implemented the Graham Scan algorithm for detection of convex hull following the Real World Haskell book. I'm looking for general advice regarding the style and ...
Michael Pankov's user avatar
8 votes
1 answer
2k views

Advent of Code 2018 day 1 part 2: find the first repeated number after some increases and decreases

Here is the problem: Part Two You notice that the device repeats the same frequency change list over and over. To calibrate the device, you need to find the first frequency it reaches twice. For ...
dagda1's user avatar
  • 309
8 votes
3 answers
168 views

A guarded FizzBuzz

Vogel612 and I decided to take a shot at the StackSTV challenge in Haskell. This is part of the CRitter Collaboration challenge. Except I don't know any Haskell. So let's try a FizzBuzz first! I'm ...
Mast's user avatar
  • 13.4k
7 votes
1 answer
3k views

Converting numbers to words in Haskell

Here's a program I wrote to convert numbers into English words using Haskell. ...
BrainFRZ's user avatar
  • 819
7 votes
1 answer
472 views

2D Convex hull exercise

I'm reading Real World Haskell, and this is my first try with the language. This is the result of the exercises of chapter 3: Consider three two-dimensional points a, b, and c. If we look at ...
mookid's user avatar
  • 181
7 votes
1 answer
1k views

Code from "Write Yourself a Scheme in 48 Hours" tutorial

I recently went through this Haskell tutorial. I'd be interested in any thoughts or comments at all, in terms of improving the structure, order, haskell conventions, or that long, kind of ugly eval ...
Irene Papakonstantinou's user avatar
7 votes
1 answer
116 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... http://chat.stackoverflow.com/...
Afonso Matos's user avatar
6 votes
1 answer
621 views

Poor AI for 2048 written in Haskell

I'm learning Haskell and thought it would be fun to write an AI for the game 2048 in Haskell. In my implementation I got rid of the randomized aspects of the game. This makes the program ...
wvdz's user avatar
  • 253
6 votes
1 answer
3k views

Reverse Polish Notation Calculator

Working through Learn You a Haskell, I made a Reverse Polish Notation calculator. Please critique it. ...
Kevin Meredith's user avatar
6 votes
1 answer
79 views

Recommend Next Note Purchase

I have just started trying to learn Haskell and tried to think of a practical, but simple problem to try and solve. I have a strong background in C, but am just beginning to dip my toes in the world ...
Free_D's user avatar
  • 207
6 votes
1 answer
395 views

Puzzle game solver via Backtracking

I'm relatively new to Haskell and I'd like to get feedback on the style of my program. Specifically: Coding Style: Can any parts be written in a more concise or more readable way? Misuse: Are there ...
flawr's user avatar
  • 261
6 votes
2 answers
4k views

A simple queue implementation in Haskell

I'm a member of a discord channel and sometimes people post simple coding exercises for fun. This time the exercise was: Implement the following operations of a queue using stacks. push(x) -- Push ...
Michel Vorwieger's user avatar
6 votes
1 answer
117 views

'Tis the season for gift-wrapping

When reviewing a Graham scan convex hull algorithm implementation, I wrote the following function in an answer: ...
200_success's user avatar
6 votes
1 answer
108 views

Yet another BrainF*** Interpretter in Haskell

I wrote a BrainF*** interpretter in Haskell. A general review would be helpful and especially, a suggestion with a better way to deal with the IO (IO Memory, IO ()) ...
Agnishom Chattopadhyay's user avatar
5 votes
2 answers
806 views

Solving Sierpinski Triangle in Haskell

I am a Haskell beginner with a background in C++ and Python. I have been teaching myself Haskell for about half a year on and off and recently I started doing Hackerrank problems to improve my Haskell ...
dhu's user avatar
  • 327
5 votes
2 answers
88 views

Advent of code #2 Haskell solution

I've tried to solve AoC day 2 challenge in Haskell (here - don't worry, it's not a competition so sharing a solution here is OK). The goal is to implement a very simple VM with opcodes 1 (add), 2 (...
msm's user avatar
  • 51
5 votes
1 answer
742 views

Caesar and Vigenère ciphers in Haskell the simple way

There are two ciphers, Caesar and Vigenère, both with an encoder and a decoder. Both work with spaces and can be passed any case (the output will be always lowercased, though). I'm a complete Haskell ...
Eugleo's user avatar
  • 267
5 votes
1 answer
234 views

3-function program computing connected components of a point cloud given a distance matrix

I wrote this code in Haskell (instead of Python) for the educational benefit. Can anyone suggest ways to improve this code? I'm guessing that I'm using fromIntegral...
Curran McConnell's user avatar
5 votes
1 answer
248 views

Project Euler Problem 54 in Haskell

I wrote an implementation in Haskell for Project Euler Problem 54: The file, poker.txt, contains one-thousand random hands dealt to two players. Each line of the file contains ten cards (separated by ...
Ben's user avatar
  • 273
5 votes
2 answers
2k 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 ...
Stefan's user avatar
  • 203
5 votes
1 answer
496 views

Revised: AI for 2048 in Haskell

This is a revised version of an AI for the game 2048, written in Haskell. Link to original thread: Poor AI for 2048 written in Haskell I think this version is a lot cleaner, thanks to the tips from ...
wvdz's user avatar
  • 253
4 votes
1 answer
3k views

List union implementation

I'm trying to implement union from the standard Data.List library. I know it's reinventing the wheel, but reimplementing ...
dopatraman's user avatar
4 votes
2 answers
102 views

Polishing partitions - Reimplementing a partitionOn

So I've read an F# question on partitioning a list in F# and wondered whether I could cleanly write the concept down in haskell and if that would help me review the code ... Now I have a haskell ...
Vogel612's user avatar
  • 25.2k
4 votes
2 answers
625 views

Sum Arithmetic Progression in Haskell

I am learning Haskell and as exercise I am doing Project Euler Problems. In this case PE1. ...
Fabián Heredia Montiel's user avatar
4 votes
1 answer
155 views

Naive implementation of Burst Balloon

As part of learning Haskell, I'm solving few problems, usually solved imperatively. I've come up with a naive solution for the problem described here, which is to find a sequence in which to burst a ...
user3169543's user avatar
4 votes
2 answers
259 views

Implementation of Graham Scan algorithm in Haskell

Here is an implementation of Graham Scan algorithm for computing the convex hull of a finite set of points: ...
qed's user avatar
  • 1,419
4 votes
1 answer
3k views

Implement `fold` on a "Rose Tree"

Given the following algebraic data type, a Rose Tree: data Tree a = Node { rootLabel :: a, subForest :: [Tree a] } I attempted a ...
Kevin Meredith's user avatar
4 votes
1 answer
540 views

Vigenere Cipher - Haskell Implementation

I'm reading 'Haskell Programming from First Principles' book written by Christopher Allen and Julie Moronuki. As part of the exercises, I'm supposed to implement encryption and decryption functions ...
user avatar
4 votes
2 answers
3k views

Poker hand identifier

Inspired by this post (along with a number of other people by the looks of it), I created a poker hand identifier with a very similar format. Note that the syntax of the hands is a little different to ...
djmcgill's user avatar
4 votes
1 answer
943 views

Project Euler #14 (Longest Collatz Sequence) in Haskell

You can check the problem here: http://projecteuler.net/problem=14 My first approach in Haskell was this: ...
jj1's user avatar
  • 143
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
4 votes
1 answer
218 views

How to avoid big tuple return types?

I recently got serious about learning Haskell and upon finishing chapter 4 in Real World Haskell, I decided to try out my accumulated knowledge on a project of my own. This code hosted on github is a ...
linduxed's user avatar