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
18 views

Encoding and decoding in Haskell — 99 Problems exercise 13, 14

I've been working on these solutions to the Haskell 99 questions, encoding and decoding series for a while now, so I figured I ought to present them to see how I screwed up the implementation. ...
5
votes
1answer
164 views
+100

Neural Network in Haskell

Following this website I wrote a neural network which uses the MNIST training data to recognize digits. The author writes that it should take a couple of minutes to train the network with 30 epochs of ...
3
votes
1answer
46 views

Haskell Parsec parser of Verilog-style number literals

I've set myself the task to write a function that parses Verilog-style number literals. In Verilog, numbers are written like this: 8'b10101100, ...
4
votes
2answers
66 views

Number Guessing Game in Haskell

I've been learning a lot about functional programming lately and I've recently started learning Haskell to which I'm very new. I've written a simple number guessing game and I would like to have ...
3
votes
2answers
24 views

Finding Permutations in Haskell

I wrote a function to find all the possible permutations of a list in Haskell. I know it can definitely be optimized, but I'm not sure how. I'm pretty sure foldl or ...
0
votes
0answers
13 views

Movable object design in Haskell [migrated]

Suppose I have an object which has a point denoting it's location and shape. ...
4
votes
1answer
46 views

Implementation of Point, Velocity and Acceleration in Haskell

I'm trying to implement point, velocity and acceleration types. They should be connected by some derive function which: takes time and velocity and returns a ...
2
votes
2answers
38 views

Termbin.com clone (commandline pastebin)

For fun I decided to write a 'real' Haskell program. The intention of the program is that it listens on a socket on a given port for input. The client can send some raw text on it and the server ...
3
votes
0answers
37 views

AVL Tree Implementation in Haskell

I'd like to get some feedback on my AVL tree implementation. I appreciate any comments related to style and performance, particularly if something can be written in a more concise or idiomatic way. If ...
1
vote
0answers
24 views

Parametric HOAS and graph reification

Is it possible to reify the graph of lambda terms expressed as parametric HOAS. Not quite sure if it is ...
7
votes
1answer
64 views

Fraction or integer parser

Question How can the following implementation of fractionParse be made less ugly? (Preserving unreduced numerators and denominators is supposed to be a feature---...
2
votes
0answers
59 views

Low performance of HTTP request using Haskell wreq

The program makes HTTP requests (checks video stream status) and calls an external program. ...
2
votes
1answer
29 views

Filtered date range function

I want to write a function to produce an inclusive range of Day such that Saturdays are excluded. ...
5
votes
1answer
79 views

Basic Nim game in Haskell

I am starting to learn Haskell, and following Dr. Erik Meijer lectures online, he suggests as an exercise to implement the game of Nim in Haskell, so I implemented a really basic game for two players (...
4
votes
2answers
109 views

I can has(kell) moar cheezburgers?

KITTEH HAS IMPROOVD CODE SKILLS, AN NAO HAS BETTR CODE 4 U This is an improvement of my original Haskell Lolcats Translator, and now features a function to do the translation (recursively?) using a ...
24
votes
4answers
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 Haskell. This ...
3
votes
1answer
63 views

Symmetry analysis for atom arrangements in a crystal

For a while now I've been meaning to post some of my Haskell code here so that someone can tell me what parts of the language/base library I've been completely overlooking. This is the first thing I'...
13
votes
3answers
1k views

Using Fibonacci sequence to generate musical melodies

I recently started picking up the Haskell programming language. I've managed to learn other languages rather quickly, but I'm still having a difficult time grasping some of the basics of Haskell. I ...
0
votes
1answer
45 views

Composing IO and Async in haskell

Whether based on MVar or TVar, async implementation are always based on operation on some underlying monad IO and STM. Making Async a monad on its own, as in F# async computation builder, if done in ...
2
votes
2answers
68 views

Print out a Zig-Zag Matrix in Haskell

My task is to code something that prints out this: This is what I have done so far. ...
-2
votes
1answer
27 views

Capture some state in Haskell

I want to capture some state in a Haskell function. For instance, I have many thread trying to print on the console and I want the to play nice with each other. So I want to have some XX to make the ...
-5
votes
3answers
95 views

Refactor code to be more succinct but yet preserve the distinction of the `if`

the below code does what it needs to do. However I would like to know if there are better (shorter) ways to express the below while maintaining the explicitness of showing the decision like with the ...
3
votes
0answers
78 views

Zipper trees implementation

Considering the lack of general purpose library to manipulate trees (not to mention zipper ones), I may end up packaging this piece of code, so I would like it to be reviewed first. Any comment is ...
26
votes
1answer
2k 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, ...
4
votes
1answer
46 views

LEB128 in Haskell

I have implemented the LEB128 encoding for unsigned integers. I'm fairly new to Haskell so I have some doubt about the coding style I'm using, particularly the definition of ...
6
votes
4answers
174 views

Get Nth item from end of list

I am starting out in Haskell and thought I would try to make a function that got the index (nth) from the end of the list. So getNthFromEnd 5 [1..10] would equal 5 ...
3
votes
1answer
40 views

Converting images to greyscale using JuicyPixel

I would like to use Haskell to do some image processing so I have been writing small programs to test performance. I wrote a program to batch convert PNG images from color to greyscale. I compared the ...
1
vote
1answer
48 views

Haskell Non-Dominated sorting

This algorithm sorts a list of Individuals, each with two fitness values, into what's called non-dominated fronts. A non-dominated front is a set of individuals where none of the individuals dominate ...
3
votes
0answers
64 views

Over-engineered fizzbuzz

I've got this fizzbuzz project I am using for a blog series, among other things. In this version, the fizzbuzz function is fed from a Fibonacci generator. I'm particularly concerned with the ...
1
vote
0answers
24 views

Implement “at” lens for Data.Map

I've been working on adding an operation like Data.Lens.At.at to Data.Map. This uses an extremely fast, extremely small, and ...
3
votes
2answers
84 views

Convert Roman Numeral to Arabic

I've been learning Haskell recently and I decided I needed to work on a (somewhat) realistic problem. What I'm most interested in getting feedback on is how well I've used the tools in Haskell to ...
1
vote
1answer
75 views

FIRST and FOLLOW sets calculator in Haskell

I found myself wanting to brush up on some notions about parsers and grammars and, at the same time, to exercise my Haskell - I am a Haskell newbie; moreover, I haven't touched the language at all in ...
1
vote
1answer
43 views

Playing with event-sourcing

I'm playing around with some ideas about how to read aggregates from events. From a high-level view I would love to have this: ...
2
votes
0answers
22 views

Unification with sequence variables and flexible arity functions

Today I wrote an implementation of the unification algorithm found in Temur Kutsia's 2002 paper. I didn't just do this for fun, it's related to other research I'm doing. I'm feeling more confident in ...
3
votes
1answer
33 views

Haskell Pig Latin Translator - v2

Thanks to Gurkenglas for the help with the previous iteration: Haskell - Pig Latin Translator! Given the constraint that the newtypes are required, what ...
3
votes
1answer
55 views

Haskell - Pig Latin Translator

What improvements can I make to the following Pig Latin translator? So far, I've been wondering about the FlexibleInstances declaration, but I can't think of how to ...
3
votes
2answers
53 views

Idiomatic Leap years in haskell

I wrote a simple function to determine if a year is a leap year or not. It works, but does not feel idiomatic. ...
7
votes
2answers
116 views

Bucket sort in Haskell

As a first step in learning Haskell I am solving this problem, which involves finding the Rith-ranked numbers, given some input list and many Ri. In an imperative language I would make a zeroed array ...
3
votes
1answer
112 views

Simple Haskell Chess

Just for fun I tried to write a chess game in Haskell, in the hope that it would eventually be good enough to beat me. It's not perfect at the rules (it doesn't know about promotion, castling or en-...
3
votes
1answer
61 views
2
votes
2answers
55 views

Determine whether input-output pairs represent something that could be a proper math function

The input is read in line by line from stdin. Input Format The first line contains an integer, T, denoting the number of test cases. The subsequent lines describe T test cases, and the ...
2
votes
2answers
57 views

U2 puzzle in Haskell

Here is a puzzle: U2 has a concert that starts in 17 minutes and they must all cross a bridge to get there. All four men begin on the same side of the bridge. You must help them across to the ...
6
votes
1answer
79 views

Data structure for expression evaluation in Haskell

I've made a data structure for mathematical expressions. I want to parse mathematical expressions like: \$x = 3\$ \$y = 4\$ \$z = x + y :\$ into an evaluated document like: \$x = 3\$ \$y = 4\$ \$...
5
votes
1answer
56 views

`read` re-implemented for Int's

I have written a safe read function for haskell (for education!). I think this is fairly idiomatic haskell code, but I'd like to know for sure. If you see anything else that could be improved, please ...
4
votes
3answers
63 views

Check whether a string contains exactly one distinct vowel

Over on Stack Overflow, someone asked a simple Haskell question: how to test whether there is exactly one distinct vowel in a given string. To clarify, there can be any number of non-vowel characters, ...
7
votes
3answers
127 views

Prolog parser written in Haskell

I am writing a very simple Prolog intepreter in Haskell. It's a class assignment and I really want to do it right. I was able to (quite quickly) write a parser for the language. Today I borrowed a ...
4
votes
3answers
68 views

Filtering triangles

I'm playing with Haskell's list comprehensions, tuples, and foldr. The exercise I've given myself is to find all triangles with a perimeter of length 26 in the set ...
9
votes
5answers
258 views

Pizza Hut math problem #1 in Haskell

I'm currently attempting to learn Haskell after a fair history of imperative programming. When I saw the Pizza Hut Pi Day math problems, I thought the first one would be a good candidate for my ...
8
votes
2answers
719 views

Conversion of a simple Python Neural Network to a Haskell implementation

I started with this code and modified and expanded it in Python. As an exercise/challenge to myself I decided to covert the original to Haskell. I either write imperatively or functionally. This is ...
4
votes
1answer
571 views

Memoized Collatz sequence

Here is one of my programs that utilized memoization and array to improve performance and memory usage. The performance seems satisfactory but the memory usage is ridiculous and I can't figure out ...