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
4
votes
2answers
320 views

N Queens with Haskell

I tried to solve the N Queens problem in Haskell using backtracking. Here is my approach: ...
5
votes
1answer
115 views

Haskell limit number of recursions

I want to create a monad which will prevent more than 10 instances of recursion (which I am implementing by preventing more than 10 instances of >>=). My <...
4
votes
1answer
410 views

Validating credit card numbers - Haskell

I'm learning Haskell and doing the exercises from http://www.seas.upenn.edu/~cis194/spring13/lectures.html. This is my code to validate credit cards as described on http://www.seas.upenn.edu/~cis194/...
3
votes
1answer
145 views

Transform a vector with the FFI in Haskell

In Haskell, I want to apply a transformation to each element of a vector using the FFI. I am rather ignorant in C, I am more or less novice in Haskell and this is the first time I use storable vectors ...
1
vote
1answer
192 views

Search for a value in tuple of lists/vectors

I guess there is some smarter way to implement such simple piece of code, but I couldn't figure out other solution by myself. Could it be done recursively without some sort of ...
7
votes
1answer
631 views

takeWhile, groupBy and group higher order functions

I'm trying to implement few higher order functions from Haskell in C++. Below are the definitions of takeWhile, groupBy, and <...
7
votes
1answer
205 views

A type for prime numbers

I have recently discovered that in type theory there is a concept of a "predicate type" which is a type \$A\$ formed out of all members of the underlying type \$U\$ that satisfy a given predicate ...
2
votes
1answer
75 views

Array Search in Haskell

I currently try to learn some Haskell to improve my overall programming skills. To practice, I implement the C course exercises that I very familiar with. One is this: Write a function that finds ...
1
vote
1answer
67 views

Mail merge (Parsec string formatting) example

My intent is to perform "mail merge" where I can write strings like "hi <<name>>" and format them according to a ...
3
votes
1answer
55 views

Creating a Stripe Subscription

I have some working Haskell code in a Yesod application that is responsible for creating a new paid Stripe subscription for a user. Although it works, I'm not pleased with the walking indentation ...
2
votes
1answer
102 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.). ...
1
vote
0answers
50 views

Extensible XML parser

Context My aim is to write an RSS parser that can handle extensions in a generic and type-safe way. I already have a working RSS parser, the missing part is the extensions handling, which is the ...
4
votes
1answer
73 views

Heterogenous lists using type classes

I am developing a chat system including chat bots and human chat users. Every user must be stored in one large list. Possible implementation using multiple type constructors: ...
4
votes
1answer
106 views

Human-readable number of bytes in Haskell

This is a tiny etude on a theme given here, using Python: Provide a function that generates a human readable file size such as 10.0GiB, ...
6
votes
3answers
821 views

Pretty-printed tables in Haskell

Purpose A clean, reusable module to generate pretty tables (much like those in SQL-clients), like so: ...
2
votes
2answers
180 views

Find acronyms in Haskell

Related to this code golf challenge, I tried to find acronyms with Haskell without using regular expressions. The idea is to split the input string at every space or dash before finally gluing the ...
1
vote
1answer
126 views

Haskell permutations matching criteria

How would one do the following in Haskell: Return all permutations of a list where one element comes before the another element (cannot assume that elements of the list can be ordered)? My ...
4
votes
0answers
341 views

Sound recorder, based on sdl2

This is my first Haskell program, a command-line sdl-based(so, hopefully, cross-platform), parameter-less sound recorder. Tutorials, articles or chapters that concern mistakes in my code are just as ...
7
votes
1answer
180 views

Basic OCR using a 1-Layer Neural Network in Haskell

I've used this tutorial in order to learn the basics of creating a neural network from scratch. The program is meant to read handwritten numbers from the MNIST database. The author of the tutorial ...
2
votes
2answers
159 views

Lucky Triples in Haskell

In answering this question on Stack Overflow, I decided to stretch my legs in Haskell a bit to see if I could implement a solution to find the count of lucky triples in a list of ints. A lucky triple ...
2
votes
1answer
60 views

Ways of forming multiple elements in a list comprehension without duplicates (Euler #109)

I was working on Project Euler #109 (Potential spoilers for people who haven't done so yet); I got the correct solution, but I'm not satisfied with how one of my lines of code ended up looking, and ...
6
votes
1answer
241 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 ...
7
votes
1answer
152 views

UPenn CIS194: Credit Card Validation (Homework 1 Part 1 Tests)

I am working through the UPenn CIS194 lectures and homework assignments in an effort to learn more about Haskell. The first part of the first homework is focused on validating credit card numbers. ...
6
votes
1answer
140 views

BingWallpapers: Fetches and applies the image of the day from Bing as the wallpaper

I have written a small desktop program nabeelomer/BingWallpapers in Haskell. This is my first time writing Haskell. I was wondering how I can make the code use more functional programming features/...
2
votes
1answer
52 views

Extract integers from a string that is split at given positions

I am writing a program which runs quite slow and on profiling I found that the bottleneck is to split a given string at given positions. The first and short version I wrote was (80% of 67 sec, i.e. ...
4
votes
1answer
191 views

Prim's Lazy Minimum Spanning Tree Algorithm in Haskell (Project Euler# 107)

I have implemented Lazy version of Prim's Minimum Spanning Tree Algorithm. I want to improve the code structure, follow prevalent conventions and reduce code size. I am solving Project Euler #107. ...
6
votes
2answers
210 views

The Morra game implementation in Haskell

Me and my friends play a variant of Morra when drinking. The rules are as follows: The players sit in a circle and hold one of their hands in front of them. One player guesses a number. All the ...
0
votes
1answer
41 views

Automation of entity reading in yesod

I'm trying to automate entity reading in my yesod application. This is what I have: ...
2
votes
1answer
176 views

Haskell Listing Directories in Working Directory

I've got this fairly simple program to print out each subdirectory of the working dir. ...
6
votes
1answer
103 views

Brain Flak implementation in Haskell

I'm a beginner to Haskell and functional programming as a whole and as a first project I've written a Brain-Flak implementation in Haskell. I wanted to get some feedback on this implementation ...
2
votes
1answer
45 views

Project Euler # 95 in Haskell - kind-of finding longest cycle in a graph

I am trying to solve Project Euler #95 in Haskell, though I have already solved it in Java (see). I found that writing imperatively, we can easily do the task this way: Pseudocode Define cache as an ...
6
votes
1answer
99 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 ()) ...
2
votes
1answer
403 views

Finding the longest common substring of multiple strings in Haskell

The task is to find the longest common substring of a multitude of long strings. I'm trying to find the best algorithm that wouldn't use syntax trees/arrays (as I don't know anything about them yet). ...
5
votes
0answers
62 views

FRP: Processing task lists

I recently heard about functional reactive programming and thought it was rather interesting. Therefore, I started out with writing a simple program which processes a list of tasks. (In this example, ...
3
votes
1answer
132 views

Area under curve

The following code is a solution to a Hackerrank problem in Haskell. Given a list of polynomial coeficients a and exponents b, ...
0
votes
0answers
51 views

Interleaving List w / IO (print's)

Looking at conduit's README, I used its magic function to try to achieve the following interleaved output: ...
3
votes
3answers
255 views

Haskell Sudoku Solver

Any comments on the following Sudoku solver? Comments I'm particularly interested are (but not limited to...) Algorithm. It created a list of "potentials" for each cell, and trims them down until it'...
1
vote
0answers
177 views

Haskell - Adjacency Matrix

This program is used to solve Challenge #140 [Intermediate] on /r/dailyprogrammer. The challenge is, given a input set of directed edges, print the corresponding ...
1
vote
0answers
80 views

Making Change via State Monad

From Simple IO to Monad Transformers presents the following exercise: The guts of our algorithm will be a function next_coin which does something like this (amt,coins) -> (amt,coins) ...
7
votes
1answer
136 views

Find the center of a red dot of an image in Haskell

I try to find the center of all the red pixels contained in an image using Haskell and repa. My problem is, that the code is ...
4
votes
2answers
211 views

Functionaly Finding Prime Factors with Multiplicity

I am quite new to Haskell so any suggestions are welcome, also I noticed that it works quite slow even for something like ...
4
votes
1answer
91 views

Nearest Neighbor Classifier for CIFAR-10 in Haskell

To get myself into functional programming, I implemented a simple nearest neighbor classifier using Haskell. The code works but is incredibly slow. Profiling tells me that most of the time is spent ...
0
votes
1answer
153 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? ...
3
votes
2answers
172 views

Vigenere cipher exercise in Haskell

This is my implementation using the dreadful !!: ...
2
votes
1answer
128 views

Euler #4: Refined Palindrome in Haskell

This is my attempt at the Problem Euler #4 in Haskell ("Find the largest palindrome made from the product of two 3-digit numbers.") ...
3
votes
3answers
242 views

Project Euler #2 in Haskell

Problem By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. My solution ...
-3
votes
1answer
393 views
5
votes
1answer
164 views

Euler 1 but pointless

I've been teaching myself basic haskell this week in order to be able to better read literature about functional programming (about 80% of which in haskell by my completely off-the-cuff statistic). ...
3
votes
0answers
168 views

Sudoku solver in Haskell using Reader+ST

While trying to understand monad transformers in Haskell I came up with a sudoku solver based on a combination of the ST and Reader monad. I am positively surprised with the performance, however ...
0
votes
3answers
382 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 ...