Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. 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
5
votes
2answers
64 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 ...
0
votes
1answer
27 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 ...
4
votes
1answer
282 views
+50

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 ...
2
votes
1answer
26 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: ...
6
votes
2answers
12k views

Palindrome test in Haskell

I am new to Haskell and, coming from a OO/procedural programming background, I want to make sure my code follows the functional way of doing things. I built this short module to test if a given string ...
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
103 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
84 views

Implementing Gaussian integers in Haskell

Currently my code (at GitHub) is this: ...
3
votes
1answer
96 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 ...
3
votes
0answers
42 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 ...
1
vote
0answers
28 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: ...
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/...
6
votes
1answer
190 views

CIS 194 Homework 2: Parsing an error log

Here is another reference solution, that I discovered after writing my own: https://insight.io/github.com/beloglazov/haskell-course/blob/HEAD/hw2.hs I am following this lecture course as a ...
1
vote
1answer
84 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: ...
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. ...
6
votes
1answer
65 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
31 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. ...
6
votes
1answer
94 views

Dice Arithmetic Puzzle Solver in Haskell

As a learning exercise, I decided to implement an automatic solver for the Sacred Geometry feat from Pathfinder (a TTRPG). The requirements to use the feat are: Roll N six-sided dice, where 1 < ...
2
votes
1answer
59 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. ...
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
127 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 ...
2
votes
1answer
33 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 ...
2
votes
2answers
121 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
66 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
0answers
170 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 ...
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 ...
2
votes
3answers
209 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 ...
6
votes
2answers
82 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
42 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 ...
0
votes
0answers
69 views

Rewrite a Haskell function to be total

I've written this function to give the neighbours of a vertex in a graph: ...
4
votes
2answers
89 views

Simple INI file parser in Haskell

I've written a rudimentary parser for INI files: ...
4
votes
1answer
172 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: ...
5
votes
1answer
81 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
3answers
669 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
83 views

Parsing expressions with combinators

I'm very new to Haskell's ReadP library, and the entire concept of parser combinators, so I was wondering whether there are better ways to do some things in this program: ...
2
votes
1answer
66 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
46 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 ...
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: ...
8
votes
1answer
278 views

Computing a Discrete Cosine Transform matrix

I'm learning Haskell and I needed to work with discrete cosine transform matrices, so I made a program that generates text (usable in WolframAlpha) containing the generated matrix. The elements of ...
5
votes
2answers
163 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 ...
5
votes
1answer
213 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: ...
4
votes
1answer
120 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. ...
3
votes
2answers
102 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 ...
8
votes
1answer
428 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
38 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 ...
4
votes
2answers
867 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. ...
3
votes
1answer
333 views

Finding the biggest product of two integers formed by the digits 1-9

The question was, which is the biggest product you can make from the digits of 1 to 9 (which is 9642*87531, BTW). It is pretty clear that one number starts with 9 and the other with 8, and that you ...
1
vote
1answer
73 views

Action to transmit queued messages over a socket

I have this action and it works but looks rather clunky to me. Is there any way I could improve that? ...