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.

learn more… | top users | synonyms

1
vote
1answer
56 views

Returning the common divisors of two integers

I have written this function that returns the common divisors of two integers. When called recursively 10 times with big integers ranging in 100000000, it takes over 5 seconds. How can I improve it so ...
4
votes
1answer
36 views

Multiple base numbers parser

This code is a Parser that parses numbers according to R5RS. #b1001 - binary #o2127 - octal #h02d - hexadecimal #d1231 - decimal 3923 - decimal It is ...
5
votes
1answer
88 views

CIS194: Risk!-style “battles”

After reading LYAH and using RWH as a reference, I've been doing the exercises from CIS194, which is often suggested to beginners on irc://freenode.net/#haskell and ...
3
votes
2answers
38 views

Finding heaviest path through triangle

I am doing Project Euler problem 67 which involves finding the heaviest path through a triangle of integers like this one (this is a smaller version from an earlier problem) ...
2
votes
0answers
32 views

Haskell zmq & protobuf message forwarding

I wrote a test program (and first "real" Haskell program!) that receives a zmq request on 1 socket, and forwards part of that message to another socket. There are a 2 things I specifically don't ...
4
votes
1answer
55 views

soundex implementation

The soundex algorithm maps several spellings of a name to a 4 character term. (hopefully mapping all different transcriptions to the same term) The steps as described in Introduction to information ...
6
votes
1answer
50 views

Approximating π via Monte Carlo simulation

Inspired by a tweet linked to me by a friend and a Haskell implementation by her for the same problem, I decided to try my hand at approximating the value of π using everything in the Haskell standard ...
5
votes
1answer
36 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 ...
8
votes
2answers
70 views

Simple command-line password generator

I'm very new to Haskell, I've read most of learnyouahaskell.com and played around with some simple things, but this is probably the most 'complicated' bit of Haskell I've written so far. I have an ...
4
votes
1answer
50 views

Converting image size from Maybe (Int, Int) to (Float, Float)

I have a function that returns size of an image IO (Maybe (Int, Int)) It would be nice to convert it to float tuple beautifully. I am sure there must be a better ...
5
votes
1answer
66 views

Project Euler problem 11, finding adjacent numbers with the greatest sum

The full description of the problem to solve can be found here. The code I have written works fine but seems extremely verbose for what it's doing, I'm not sure if list comprehensions are meant to be ...
6
votes
1answer
54 views

1 or 2 Player CLI Tic-Tac-Toe

I wrote a simple tic-tac-toe program in Haskell. It runs on the command line, has a one and two player mode, and implements a minimax algorithm when you play against it. I'm used to writing proper ...
1
vote
1answer
25 views

Convert a string into an R vector expression

Problem: Given a arbitrary string, split by a given regex and format into an R vector expression. E.g. Convert "a..,b..,c,d" into 'c("a","b","c","d")', when the given regex is "[.,]+". Solution in ...
8
votes
2answers
374 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, ...
4
votes
1answer
66 views

GitHub API client

Here is my Haskell program designed to list all of my GitHub repos along with their descriptions and languages via the GitHub JSON APIs: ...
6
votes
1answer
34 views

Convert data back-and-forth between CSV files and pretty-print

I wrote a script to convert CSV files in human readable format and vice versa. Human readable format is achieved like so: ...
3
votes
1answer
23 views
3
votes
1answer
60 views

Using Wreq and Lens libraries to query Prosper for account info

I am trying to create a program to manage my Prosper investments for me as an intro to Haskell project. I created a post a few weeks ago for some of the simpler backend calculations: Recommend Next ...
11
votes
2answers
89 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 ...
8
votes
1answer
81 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: ...
1
vote
0answers
46 views

Nested Monad Function Re-write? [closed]

Is there a cleaner way to write this function? ...
5
votes
1answer
45 views

Haskell CodeEval Beautiful Strings

Problem Definition : When John was a little kid he didn't have much to do. There was no internet, no Facebook, and no programs to hack on. So he did the only thing he could... he evaluated the ...
6
votes
1answer
56 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 ...
5
votes
1answer
47 views

Haskell compositor

This is a concept for a compositor. It would help me if you could review how well I expressed my ideas into the functional language. I first divide everything in an areas that each window covers ...
11
votes
1answer
99 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 ...
4
votes
2answers
87 views

Function that produces \$a^nb^nc^n\$

I'm trying to write a function that produces an infinite list containing strings of the form \$a^nb^nc^n\$. My first idea was to do it using comprehensions. ...
3
votes
2answers
87 views

A “map” function that alternates between two mapping functions

I am trying to solve following problem in Haskell using recursion: Define a recursive function funkyMap :: (a -> b) -> (a -> b) -> [a] -> [b] ...
8
votes
1answer
60 views

Haskell CodeEval FizzBuzz

CodeEval FizzBuzz Quick Description: Take 1 command line argument of a file-path. This file will contain test cases formatted as such 3 space separated numbers per line. For numbers ...
3
votes
1answer
40 views

HackerRank: Counting Sort 1

I've just solved this challenge, though I feel that there is a problem with stack growth or something because the 5th testcase has a runtime error ...
10
votes
1answer
61 views

Printing patterns in Haskell

Write a function Int -> Char -> Char -> [String] that will create the appropriate pattern. For example: ...
12
votes
2answers
116 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 ...
2
votes
1answer
54 views

Counting dashes in numbers

I have written my very first Haskell module and I feel that the code can be improved based on the simplicity of the problem I am solving. Do you have any suggestions? Problem statement: ...
5
votes
1answer
64 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 ...
5
votes
1answer
49 views

Double every 2nd item in a list

Some exercise required me to write a piece of code to double every second item in a list. My first thought was just using cons and I came up with the following: ...
3
votes
0answers
47 views

Tic Tac Toe in Haskell

After reviewing many Tic-Tac-Toe implementations, I decided to write my own. Here it is: Logic.hs ...
3
votes
1answer
69 views

Lazy attoparsec parser for log files

I've written a parser with the help of some experienced Haskellers. The parser is not bad, but the same kind of parser written in PHP7 with regular expressions is much faster (takes 25% of the time ...
2
votes
0answers
27 views

Haskell s-expression parser and quasiquoter

There are a number of questions on this site about s-expression parsing: e.g., Calculator parsing S-expressions and Code from "Write Yourself a Scheme in 48 Hours" tutorial. However, these ...
3
votes
1answer
59 views

Run-length encoding in Haskell

I wrote a short Haskell script to compress and decompress via the use of run length encoding. The concept is simple enough, n equal items ...
2
votes
0answers
38 views

Another Conway's Game of Life in Haskell

Curious what people think about this implementation of Conway's Game of Life in Haskell. ...
5
votes
1answer
49 views

Sokoban text clone

I rewrote this simple, list-based Sokoban implementation a few times, trying to make it better. Right now, I'm stuck without ideas, but I still feel there is room for improvement, specially in ...
3
votes
1answer
38 views

Copy first n lines of each file in a directory

In an attempt to learn Haskell, I've built this - it accepts a number n, a source directory, and a sink directory (ending with /) copies n lines from each file in ...
1
vote
2answers
109 views
6
votes
1answer
36 views

Module for isotopic masses and abundances

I have written a small module for accessing data on isotope masses and relative abundances. My long term aim is to build tools in Haskell for working with mass spectrometry data. Any comments on how ...
3
votes
1answer
64 views

Befunge-93 interpreter in Haskell

This is an interpreter that takes in a slightly altered Befunge-93 (no input from the user, no limits on size and division by zero defaults to zero). I'm currently looking at the state monad and how ...
2
votes
0answers
29 views

Constant-space n-dimensional loops using dependent vectors

I designed this file after learning from this awesome answer from user2407038 on Stack Overflow. The idea of the module is to replace code like: ...
2
votes
0answers
53 views

Attack-Rooks challenge

Attack-Rooks is a challenge proposed by ACM-ICPC as a variant of the N-Queens problem, using Rooks instead of Queens. Of course, to disallow the trivial "fill the diagonal" solution, pawns are used to ...
8
votes
1answer
129 views

HangPerson in Haskell

I created a HangPerson game in Haskell and I must admit it feels very imperative. How can I make it more "functional?" Are there more elegant ways of breaking up the task? The ...
5
votes
2answers
222 views

Basic random password generator

I'm trying to pick up some Haskell skills so thought I'd write a random password generator to get to grips with using IO. It was far trickier than I expected and I ...
1
vote
2answers
109 views

Brotli compression algorithm, translated from Python into Haskell

I have converted some code in Python into its Haskell equivalent. Python implementation: ...
0
votes
1answer
118 views

UPenn CIS 194 Homework 4: Higher-order programming

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. ...