Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
38 views

How do I flip a juicy pixel image saved from glut

I'm trying to make snapshots of a opengl area in a haskell program using the glut library. I found this snippet of code using the juicypixels library. saveImage :: Window -> IO () saveImage window =...
JeanJouX's user avatar
  • 2,721
1 vote
2 answers
130 views

Does there exist a Haskell generalization of this two-pass scan algorithm that works for all two-pointer problems?

To make this question very precise and objective, I am looking for any nontrivial generalization other than "replace Int with some polymorphic numeric type". In this old SO question, the ...
lanf's user avatar
  • 365
1 vote
2 answers
31 views

Example of using `linkOnly` from the async library

I found what I'd imagine to be a useful function in the illustrious async library that allows a thread to propagate an exception if and only if the exception passes a predicate - with a type of ...
Athan Clark's user avatar
  • 3,938
0 votes
1 answer
52 views

Pattern match where type has constructors

I'm using a 3rd party library which has the following types: data ServicesRequest req contentType res accept = ServicesRequest { rMethod :: NH.Method , rUrlPath :: [BCL.ByteString] , ...
Neil's user avatar
  • 359
0 votes
2 answers
59 views

How do I overload a certain operator in haskell to take different types on either side?

MRE: class Foo s where myCons :: Char -> s -> s myCons c xs = <my definition of however I wish to interpret this> instance (Eq, Show) Foo where (:) x y = x `myCons` y Error: ...
kesarling's user avatar
  • 2,132
0 votes
1 answer
29 views

XMonad, spawn floating window right above focused window

I am trying to spawn a floating window whose screen position would match currently focused, tiled or itself floating, window. I am assuming the spawn command itself should reside inside keys list (...
John Z.'s user avatar
  • 157
1 vote
0 answers
74 views

Why the type is not correct in my action?

Haskell newbie here . I'm trying to ask a value and retrieve it in a different method, but I'm having a problem with the types that I don't fully get main= do askStrength askStrength :: () -> IO ...
Yago's user avatar
  • 373
2 votes
1 answer
84 views

Why Does This Haskell Closure Keep Giving Me 'No instance for (Integral (IO t0))' Error?

Dear StackExchange Experts, I have been trying to learn how to program in Haskell from the book 'Get Programming With Haskell', and I came across an example involving closures from Chapter 5. I tried ...
Anon Anon's user avatar
1 vote
1 answer
115 views

Function to ensure your value is wrapped in a Maybe

I'd like a function that takes an argument and gives back a Maybe value. If the argument has type Maybe a, the implementation should be id, and if the argument is anything else, the implementation ...
Alan's user avatar
  • 332
7 votes
1 answer
124 views

`seq` apparently does or doesn't force evaluation of entire recursively-defined list depending on how it is loaded into GHCi

Recently I've been trying to understand what, exactly, is forced by GHC upon the evaluation of seq. Suppose I save the below definitions: f :: Int -> [Int] -> [Int] f = \n -> \ns -> if n &...
Rafi's user avatar
  • 181
1 vote
1 answer
52 views
+50

Using streamly in Haskell to run a REPL in background

I'm trying to use streamly-process to communicate with some REPL in background. It could be Python or anything but here I try to run GHCi. I came up with the following code : import Data.Word import ...
141592653's user avatar
  • 649
2 votes
1 answer
127 views

Haskell Linked-List Monad

I am trying to write a Monad for a Linked-List enumerated datatype in haskell and I don't understand why my bind function (>>=) is getting errors in ghci. data LL a = Sentinel | Node a (LL a) ...
Simplicissimus's user avatar
4 votes
2 answers
171 views

GHC Warning: Non-exhaustive Pattern Match for List Despite Explicit Match on Empty List

I’m trying to write a simple Haskell function that distinguishes between an empty list and a non-empty list. Here’s my code: {-# LANGUAGE OverloadedLists, RebindableSyntax #-} import Prelude (Int, IO,...
Vanson Samuel's user avatar
0 votes
1 answer
113 views

How to remove speicific value constructor in a list using traversal

data Fruit = Apple Int | Banana Color Int data Color = Red | Green let basket = [Apple 3,Banana Red 30,Apple 6] The goal is to keep Banana only How to ...
Shawn Zhang's user avatar
  • 1,724
0 votes
2 answers
91 views

is something wrong with my compiler or my syntax inn

im new to haskell and when i tried some basic syntax it seems to not work the way it is supposed to work. ive tried a couple of things but nothing seems to be working properly. im starting to assume ...
Computer noob's user avatar

15 30 50 per page
1
2 3 4 5
3432