Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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
1answer
75 views

Extensible Fizzbuzz in Haskell

I am getting used to how things should be written/thought about in (idiomatic) Haskell. I wrote a FizzBuzz program that prints to the console. I wanted to generate things from the core info of the ...
3
votes
1answer
69 views

Longest Substring Without Repeating Characters, Haskell

I started learning Haskell a while ago and now I am in this dangerous state where I can produce code that does things but which probably makes experienced developers hit their heads against the wall :)...
2
votes
1answer
48 views

Compute text area given letter heights and a text

I have solved the designer pdf question with haskell. The code works. I am posting the code here to know how I could have done it better. First line contains the weight of each alphabet Second ...
1
vote
0answers
29 views

Haskell - Caching third party API token across requests

The following code is designed to cache a (UTCTime, Text) value that keeps the Text token around until it expires, preventing ...
5
votes
2answers
80 views

Haskell Graphing Module (Gloss)

I've been slowly learning Haskell over the past few months. I made a small module to graph functions using Gloss, and I would like feedback on how idiomatic it is (looking for ways to simplify using ...
4
votes
1answer
313 views

Monitoring Traces for Satisfaction of Temporal Logic Properties

I am trying to implement a monitor for a certain temporal logic. What this means is the following: There is some external source, from which a trace of items are coming. An item looks like a ...
0
votes
1answer
29 views

Apply labels from a stream to a Bitraversable

Labelling Traversable containers is an ancient and honorable test of skill. My task here is to create a generic labelling mechanism for a ...
2
votes
1answer
35 views

This is a Monoid instance I wrote for a Tree data type. Is this the most terse way to express mappend?

Here's my type: data Tree a = Empty | Node a (Tree a) (Tree a) Here's the instance declaration for Monoid: ...
3
votes
1answer
83 views

Transitive graph

What follows is a small but useful set of functions on transitive graphs and graphs that must be conformed to transitivity. Natural language is rich in transitive relationships expressed in a ...
2
votes
1answer
111 views

Meta-circular interpreter for lambda calculus in Haskell

For learning purpose, I've written a simple lambda calculus interpreter (plus 'Add'). I would like it to be the cleanest and most idiomatic possible. Bonus question: how would you use ...
2
votes
1answer
34 views

Apply smiley replacement filter to Pandoc but not in code segments

I wrote a filter for pandas that converts :-) to but not in inline code or code blocks. Pandoc makes it so the ...
5
votes
1answer
93 views

Implementing Gaussian integers in Haskell

Currently my code (at GitHub) is this: ...
3
votes
0answers
46 views

Finding the least number of terms to satisfy integer square equation

The following code is a solution to an exercise I've made: This exercise idea is based on a story from my current work place: My boss'es Ubuntu had a bug that made his printer, when asked to print ...
3
votes
1answer
101 views

Introduction to Haskell: Validating credit card numbers

I have implemented the introductory challenge of University of Pennsylvania's CIS 194: Introduction to Haskell (Spring 2013) course. I have added the most important information of the problem ...
1
vote
1answer
39 views

Dynamic field access in Haskell

I have to transform a response into the internal Coordinate record, some of the fields are lists and I need to handle empty lists case. Records: ...
1
vote
1answer
93 views

Hex string to Base64 in Haskell

This is my take on the first challenge on the cryptopals crypto challenges list. I think that i made it quite simple but i feel like it is possible to optimize it further. Any suggestion? The code: ...
6
votes
1answer
66 views

Haskell PitchClass Algebra, in which notes have various names

I am an OOP programmer by trade (Java) who is extremely new to Haskell and the world of purely functional languages. To get my feet wet, I decided to try and write a little musical interval translator/...
2
votes
1answer
32 views

Find intersection of rectangle with itself rotated

Given \$w, h, \alpha\$ for a rectangle centered at origin with width \$w\$, height \$h\$ and itself rotated by \$\alpha\$ around origin clockwise, I wrote a code to find the intersection area. ...
13
votes
3answers
2k views

A Haskell implementation of Conway's Game of Life, viewable on the console, no external libs

This is a Haskell implementation of Conway's Game of Life. It plays on a console. It should be able to play a field of any size, but we only give it a glider on a small field to run at this point. ...
2
votes
2answers
123 views

Miller-Rabin Large Prime Generator in Rust

I implemented the Miller-Rabin prime test in Rust and made a program to generate large primes. I have also implemented the same program in C and Haskell and the Rust version is the slowest. I am ...
2
votes
0answers
69 views

Parallel Miller-Rabin Prime Test in Haskell

I implemented a prime number finder using the Miller-Rabin prime test in Haskell and it seems to be working. You enter a number and it finds the next prime following that number. I also tried to make ...
3
votes
1answer
56 views

Haskell API for manipulating Tree/Forest

I'm experimenting how a Relation (a cartesian product's subset) can be implemented in Haskell using different data classes. Forest and Tree allow to keeps together in a single data structure ...
7
votes
3answers
138 views

Check if an integer equals the sum of its digits to the fifth power

I can do this in one line in Python: sum([i for i in range(9,9999999) if i == sum([int(x)**5 for x in str(i)])]) Not very fast, but works nicely. I thought it ...
3
votes
1answer
61 views

Modifying a random String stored in the clipboard

I wrote a simple program, that will make a string 'noisy' if the clipboard contains one. What disappoints me, is that I should manually check what I got from ...
6
votes
2answers
99 views

Simple prime factorization program in Haskell

I'm finally learning Haskell this summer and I have a few questions about conventions. I made a simple prime factorization program which is surprisingly fast, much faster than the ones I made in C++ (...
4
votes
1answer
43 views

Entropy calculation function in Haskell

I've written a function in Haskell for calculating the entropy of a collection. I'd like feedback on how the function could be rewritten to be more flexible/reusable, and also how to profile the ...
2
votes
1answer
104 views

Performing an action which may return other actions to be performed, concurrently

I have a program which, at its core, involves repeatedly performing an action on some value, and based on that action also returning a list of new values to perform that action on. The pure version of ...
0
votes
0answers
71 views

Rewrite a Haskell function to be total

I've written this function to give the neighbours of a vertex in a graph: ...
5
votes
1answer
84 views

3-function program computing connected components of a point cloud given a distance matrix

I wrote this code in Haskell (instead of Python) for the educational benefit. Can anyone suggest ways to improve this code? I'm guessing that I'm using fromIntegral...
4
votes
2answers
103 views

Simple INI file parser in Haskell

I've written a rudimentary parser for INI files: ...
4
votes
1answer
199 views

Simple decision tree in Haskell

I've been trying to get better at Haskell for a while, and have recently been working on a lot of small projects with it. This constructs a binary decision tree. The command to run it is: ...
4
votes
3answers
679 views

Classic cryptography toolbox: Caesar, Vigenere and ADFGVX ciphers

I wrote a program in haskell that aims to let the user encrypt, decrypt and crack/cryptanalyse pre-electromechanical era ciphers in Haskell. I want to know your opinion on it since this is my first ...
2
votes
1answer
67 views

Minimal Haskell Unit Testing Framework

I'm trying to come up with a unit testing framework for Haskell that is small and self-contained produces TAP-compatible output exits abnormally on failure (instead of relying on the TAP consumer to ...
1
vote
1answer
47 views

Unique elements of a list and corresponding indices in Haskell

Given a list vs, I want to get the list vs' of the unique elements of vs, as well as the ...
5
votes
1answer
58 views

Finding duplicated entries

Since the Esteemed Academia wants me to learn Haskell, and Haskell seems just weird for me, I thought that to train some basic Haskell skills I'd write a simple script I now need in Haskell. This is ...
3
votes
0answers
187 views

Fast Hamming sequence generation in Haskell

I found some months ago that I could generate Hamming multiples of 3 and 5 multiples (3^x & 5^x) in one list comprehension. There are many fewer 3 and 5 Hamming multiples in a Hamming sequence. I ...
4
votes
1answer
123 views

Stable marriage in Haskell

I implemented a stable marriage problem in Haskell few month ago. It's not optimized at all and I'd like to know how to make it better from performance and readability perspective. ...
2
votes
3answers
210 views

Determining primality by removing select composits

Calculating many remainders for each prime and composite consumes more time. I use a factoring function to find factors of single values. When I use a factoring function to find lists of primes, I ...
8
votes
1answer
440 views

Prime factors and perfect square

I want to convert an integer to a perfect square by multiplying it by some number. That number is the product of all the prime factors of the number which not appear an even number of times. Example ...
3
votes
2answers
106 views

Number of possible numbers in roman number string

I just started learning programming a few months ago, and I'm intrigued by Haskell. To learn a bit I tried to adapt some code I have in Java so I can see what are equivalent solutions in Haskell. The ...
5
votes
2answers
193 views

Sum of divisors in Haskell

I decided to write a function divisorSum that sums the divisors of number. For instance 1, 2, 3 and 6 divide 6 evenly so: $$ \sigma(6) = 1 + 2 + 3 + 6= 12 $$ I ...
3
votes
2answers
39 views

Parse a date in various formats

I have a problem similar to the question, namely reading in text which describes a date - in various formats. I want to use the parseTimeM function from ...
1
vote
1answer
394 views

The quicksort algorithm in Haskell

I am learning Haskell programming language mainly from this source. And there I have encouraged with "an elegant" realization of the quicksort sorting algorithm (the Quick, sort! section). Here it is: ...
0
votes
0answers
97 views

Cellular Automaton in Haskell

I've written a sort of library in Haskell to help create cellular automata by specifying the rules and the data-type of each cell. The problem is, it runs extremely slowly on larger "boards". A 64x64 ...
4
votes
2answers
108 views

Implementation of partitionM

I needed a monadic version of partition today. I settled on the following version: ...
2
votes
2answers
43 views

Implementing Traversable for Coproduct

Given the following definitions of Functor and Coproduct from fp-course: ...
13
votes
1answer
142 views

Brainfuck to NASM compiler in Haskell

After reading this article on writing a Brainfuck interpreter in Haskell and achieving awful performance with it (for example, mandelbrot generating 37.5 minutes on an old Intel Atom powered laptop) I'...
2
votes
1answer
61 views

Modelling Immerman–Szelepcsényi in Haskell

I am trying to model the proof of Immerman–Szelepcsényi Theorem with Haskell since it heavily uses non-determinism. An explanation of what the point of this is can be found here. ...
2
votes
0answers
35 views

Solving the wooden snake chain puzzle

My code tries to solve the wooden snake chain puzzle: I do so by generating all possible link configurations which are then tested. I was hoping that laziness would take care of the very many ...
4
votes
1answer
252 views

Writing monadic Haskell to evaluate arithmetic expression

I have been studying Haskell by myself for about a little over a year. And I have been stuck at monad/monad transformers for quite a while until recently some examples I read online enlightened me. So ...