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
3
votes
0answers
202 views

Converting English words to numbers in Haskell

A few weeks ago, I finished a number to word converter and received an excellent review. It caused me to make several fundamental changes to numToWord, such as ...
2
votes
1answer
93 views

Storing values in an N x N grid

I am trying to write a program to store/display a grid of size N x N with cells containing either a 1 or a 0 in preparation for further computation: ...
4
votes
1answer
155 views

Converting anki-furigana to HTML-furigana without parser libraries

I wrote a converter from anki-style furigana to HTML-style furigana. Eventually I want to do it as a parser, but as a first step I do it without. Furigana is used to write the pronunciation over ...
3
votes
1answer
120 views

Programming Contest - Snuke Festival

Problem Statement The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three ...
8
votes
2answers
364 views

Simple guessing game in Haskell

Here is a simple Guessing Game I implemented in Haskell ...
12
votes
2answers
535 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 ...
5
votes
1answer
535 views

A Public and Private Key generator for RSA

I made an RSA encryption public and private key generator and I would like some feedback. In particular, as this is cryptography related I want to know if I have done anything that might be considered ...
7
votes
1answer
977 views

Converting numbers to words in Haskell

Here's a program I wrote to convert numbers into English words using Haskell. ...
5
votes
1answer
211 views

Porting Haskell list comprehensions to Standard ML

Out of curiosity I'm porting the Haskell exercises of Programming in Haskell by Graham Hutton to Standard ML. At the beginning everything seemed pretty similar until I reached list comprehensions: ...
2
votes
1answer
226 views

Haskell todo list

I don't have much experience with Haskell or functional programming, but I wrote a working todo list. My main question is if there's any idiomatic shortcuts I could take and if my code is idiomatic ...
4
votes
2answers
80 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 ...
2
votes
0answers
169 views

Game of Life in Haskell with Nested Zippers, Comonads, etc

I was trying to implement Game of Life in Haskell. Here is my approach: ...
1
vote
1answer
52 views

Functions that build a path to the model and command files for some tests

I'm currently working in a model-based testing tool. I'm writing some integration tests for it, which require two kind of input: Model files: which contain models to be parsed and run by the tool. ...
4
votes
2answers
369 views

N Queens with Haskell

I tried to solve the N Queens problem in Haskell using backtracking. Here is my approach: ...
5
votes
1answer
125 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
428 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
159 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
706 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
221 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
76 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
69 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
57 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
103 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
51 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
74 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
111 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
915 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
193 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
134 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
377 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
187 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
168 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
262 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
156 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. ...
7
votes
1answer
147 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
54 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
207 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
219 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: ...
3
votes
1answer
194 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
106 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
46 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
427 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
64 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
139 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
53 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
264 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'...