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.
5
votes
0answers
20 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
55 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 ...
1
vote
0answers
20 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:
...
1
vote
0answers
41 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
89 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
186 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
79 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
60 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.
...
3
votes
1answer
36 views
Hacky Haskell monadic testing
I recently started writing Haskell tests with HUnit.
My general setup looks something like this:
...
8
votes
2answers
80 views
Enigma machine simulator
As my first (keep that in mind!) Haskall program (full code at end) I've written a simple Enigma machine and would like feedback on the core code related to its stepping and encoding — stripped of ...
2
votes
0answers
24 views
Using QuickCheck to Verify Free Monad's Functor Instance
Given the Free Monad, and my Eq, Show, and Functor ...
2
votes
1answer
82 views
UPenn CIS 194 Homework 3: Code golf
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.
...
3
votes
2answers
41 views
Aligning text in Haskell
This Haskell program just aligns the text lines on the given substrings.
I took inspiration from here, but my code is not golfed.
...
3
votes
1answer
69 views
UPenn CIS 194 Homework 2: Log file parsing
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.
...
1
vote
2answers
161 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.
...
3
votes
1answer
133 views
Printing an arrow of asterisks in Haskell
This code will print an arrow of asterisks, like:
*
**
***
****
***
**
*
...
6
votes
1answer
61 views
Haskell Ackermann function
I had a challenge a while back from a friend to try and produce the fastest possible program to compute A(3,16), where A is the ...
3
votes
1answer
31 views
Parallel scheduler for running actions at designated times
I've been trying to learn Haskell on and off for a couple years. I had a project for building a parallel web scraper, and I figured I'd try to use Haskell for it. Here's the part used to schedule ...
3
votes
2answers
127 views
10
votes
1answer
96 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 ...
4
votes
1answer
53 views
DSL design — C DSL
I am trying to design a DSL for writing C. Here is my code as a GitHub gist (Github does not allow me to have slashes in the filenames so I have used underscores instead). It depends on packages free ...
1
vote
1answer
24 views
MonoAlphabetic and PolyAlphabetic ciphers in Haskell
This code defines functions to cipher text with both mono-alphetic (Caesar) ciphers and poly-alphabetic ciphers. I also define a shortcut for rot13. I like this code and I think it is easy to read, ...
3
votes
2answers
61 views
N-queens problem in Haskell by bruteforce
I wrote a Haskell program to solve the N-queens problem by bruteforce. It works and I find it reasonably readable
But it is pretty slow:
5 seconds for one solution of 8 queens.
1 minute for one ...
2
votes
1answer
60 views
Convert roman to arabic
I started to teach myself Haskell recently. Here is some code I wrote to convert a roman numeral into an arabic numeral:
...
2
votes
1answer
37 views
Ruby-like squish in Haskell
squish is an onomatopoeic string function provided by Ruby on Rails that works on strings.
Given a string, squish condenses all ...
4
votes
2answers
76 views
Infinite list of strings containing 'a'
I was assigned to write a piece of Haskell code that makes an infinite list containing increasing numbers of 'a's.
My first thought was to write it as a list comprehension like this:
...
16
votes
3answers
639 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 ...
8
votes
2answers
68 views
Racetrack game with reading the track from a file
For this community challenge I made the racetrack game. I'm reading the race data from a text file, which is available here. This is only playable by entering the velocity at the console.
I've got ...
4
votes
1answer
65 views
Python tokenizer in Haskell + Parsec
I wrote a tokenizer/lexer (difference?) for Python in Haskell: this is my code on GitHub.
I already tested it out with some of CPython's standard library scripts, and it doesn't fail. However, it ...
7
votes
1answer
71 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...
...
4
votes
1answer
70 views
HackerRank - Candies
Here is the solution I've written for Hacker Rank Candies challenge.
It uses dynamic programming (memoization in a boxed array).
I'm interested on what could be done to improve this code in term of ...
1
vote
1answer
74 views
Project Euler Problem 50 in Haskell
The prime 41, can be written as the sum of six consecutive primes:
41 = 2 + 3 + 5 + 7 + 11 + 13
This is the longest sum of consecutive primes that adds to a prime below one-hundred.
The ...
4
votes
1answer
64 views
Euler Problem 101 - Optimum polynomial
Here is my solution in Haskell for the Euler problem #101. It relies on building a specific base of polynomes given the values we want to fit (memories of my linear algebra courses from a long time ...
4
votes
0answers
45 views
Find first SO chat message in Haskell
I have made some simple functions to find the first SO chat message. How can I improve my code?
Even if there is a stackoverflow link that will get the job done (I'd be glad to know), I'd like to ...
5
votes
1answer
66 views
Untouchable Numbers
I wrote this program in response to a CodeGolf challenge that required generating this sequence of "untouchable" numbers. This sequence can be found on OEIS as A005114.
My initial implementation was ...
2
votes
1answer
74 views
General TicTacToe in Haskell
I decided to take a more general approach while implementing the TicTacToe game in Haskell.
Util
...
5
votes
1answer
78 views
Parsing and plotting complex numbers
I am trying to write a Haskell application that parses a bunch of complex numbers from a Mathematica output and then produces a PPM image.
The end product looks like this:
The code to create this ...
4
votes
1answer
56 views
TicTacToe game in Haskell
As a beginner, I tried to implement TicTacToe in Haskell. How can I improve my code?
I have refactored my code: General TicTacToe in Haskell
Utils
...
5
votes
1answer
77 views
Returning all possible player moves on a board
Recently I started to learn Haskell. I did this by making exercises on the Internet. The problem of making these exercises is that I never know if I solved it the correct way. I currently wrote a ...
2
votes
1answer
86 views
Computing all Tic-Tac-Toe moves
Recently I started to learn Haskell. I did this by making exercises on the Internet. The problem of making these exercises is that I never know if I solved it the correct way. I currently wrote a ...
3
votes
1answer
33 views
Merge adjacent numeric intervals
Given a list of pairs of integers that represent closed numeric intervals, I need to output a list of intervals where the adjacent intervals are merged together. The code assumes that the intervals do ...
4
votes
0answers
62 views
Simple Echo Server
I wrote this echo server in Haskell as a way to introduced myself to programming with sockets in Haskell and generally practice Haskell. The echo server has a simple purpose: accept connections from a ...
2
votes
1answer
68 views
Parsing a component of a regex followed by an optional quantifier character
I have a piece of parsec code that parses a unit optionally followed by ?, + or ...
2
votes
1answer
43 views
Reading numbers from a file with lazy ByteString
This is my code for lazily reading a very large file which contains numbers separated by a new line character. Is there a way to simplify this using the ByteString ...
6
votes
2answers
87 views
String sequence in Haskell
Given a string sequence and a string, the function should output the next string of that sequence.
For example, for sequence "abc":
...
6
votes
1answer
149 views
Permutations of a list in Haskell
I have this piece of code which given a list returns another list which combines every element with every other element (without repetitions) using a given function as a combiner. I came up with three ...
1
vote
1answer
47 views
Find disjoint integer intervals
Given a list of numeric intervals in the form of (a,b), where a and b are integers, it finds ...
5
votes
1answer
63 views
Implementation of Set data type in Haskell
I'm an advanced beginner Haskell programmer. I implemented a set data type in Haskell and I wanted to find out if I made correct choices when writing it. Would there be a way to improve some of the ...
6
votes
3answers
125 views
Project Euler problem 92 (sequences formed by the sum of squares of digits) in Haskell
I made the following program in Haskell to solve Project Euler's problem 92. The program works (i.e. the solution it yields is correct), but it's not exactly the fastest in the world.
The problem is:
...
4
votes
2answers
69 views
Handling request errors in snap with haskell
I'm currently taking a look at Snap with Haskell. I'm pretty new to Haskell and functional programming in general and am working out the best way to handle errors. Currently I have something like this
...