Skip to main content
Filter by
Sorted by
Tagged with
-3 votes
0 answers
65 views

I need a function of type linearJoin :: (ctx,Functor n,Functor m,Functor x) => (forall a. n (m a) -> x a) -> t n (t m a) -> t x a A bind version would look like this linearBind bindfun f k ...
Ashok Kimmel's user avatar
Advice
0 votes
4 replies
112 views

In Haskell, how should one test the equality of two infinite lists? With finite lists, one might try: listEqual :: Eq a => [a] -> [a] -> Bool listEqual l0 l1 = and $ zipWith (==) l0 l1 But ...
Geoffrey Warne's user avatar
0 votes
1 answer
76 views

So this is the data definition and my function. Task 3 Define addAll, which adds a list of expressions together into a single expression without introducing any 'junk'. You could use foldr since it ...
charlotte chang's user avatar
5 votes
2 answers
146 views

Fur fun and education I'm trying to write a mini compiler with the final tagless method as described by Oleg Kiselyov in his paper Typed Tagless Final Interpreters. My grammar has expressions and ...
Jogger's user avatar
  • 1,773
4 votes
1 answer
105 views

The following program assumes that /path/to/mypipe is a named pipe, e.g. created via mkfifo /path/to/mypipe, with no readers/writers waiting yet, runs two threads, of which the main thread keeps ...
Enlico's user avatar
  • 30.2k
2 votes
2 answers
152 views

Suppose, we have 2 lists of lists: a = [[1,2], [3,4]] b = [[5,6], [7,8]] We want to merge every element of the first list with every element of the second list and get: c = [[1,2,5,6], [1,2,7,8], [3,...
user4035's user avatar
  • 24k
2 votes
1 answer
86 views

I've been making progress with Chris Allen's Haskell book and I am stumped in an exercise as the title suggests. First of all, the binary tree is defined as such: data BinTree a = Leaf | Node (...
Κωστής Καρβουνιάρης's user avatar
4 votes
1 answer
115 views

I'm learning about Haskell and came across this concise, but weird, definition for a function that multiplies three numbers: volume :: Float -> Float -> Float -> Float volume = ((*) .) . (*) ...
zahiko's user avatar
  • 83
3 votes
1 answer
76 views

I want to recursively collect arguments of a function to a tuple with nesting (the general idea is taken from here). I have a class with a function with polymorphic parameter (a, b). I want to make an ...
Dmitry Kapustin's user avatar
1 vote
1 answer
85 views

Take this simple program in Haskell {-# LANGUAGE OverloadedStrings #-} import Control.Exception (finally) import Control.Monad (forever) import Xmobar (tenthSeconds) import DBus.Client startServer' :...
Enlico's user avatar
  • 30.2k
1 vote
1 answer
62 views

Apart from the known safety concerns documented for unsafeFreeze / unsafeThaw, is there any issue using these functions with non-pinned backing data (that is, as I understand everything except Vector....
ron's user avatar
  • 9,458
1 vote
2 answers
163 views

Function fmap has two arguments: function and its argument(s). When I execute fmap for IO monad, it executes the second argument, but not the first: main = fmap (\_ -> print "def") (print ...
Dmitry Kapustin's user avatar
3 votes
1 answer
109 views

I have a testcase for a complicated function that for unclear reasons tends to hang on certain platforms. I would like to know which test inputs cause the hanging behaviour. I have tried to use ...
sjakobi's user avatar
  • 3,668
0 votes
0 answers
52 views

I'm trying to set up Haskell in VSCode Windows by following this Better Programming Guide Everything worked fine except for the code formatting. I tried installing brittany using stack install ...
Timeless0007297's user avatar
2 votes
2 answers
138 views

This pertains to Emily's answer here: https://stackoverflow.com/a/13850560/2026752 ansMap :: M.Map Integer Int ansMap = M.fromAscList [(i, collatz i) | i <- [1..1000000]] where collatz 1 = 0 ...
daikonradish's user avatar
0 votes
1 answer
80 views

I am trying to write a Twitch chat bot that will receive messages. The messages will be in JSON and be an object of two other objects, metadata (which appears to be mostly standardized across all ...
Jason Harrer's user avatar
3 votes
2 answers
109 views

I'm still quite new to Haskell and don't have a great grasp of monads intuitively. I'm trying to write the function below: applyPandocFilters :: (MonadIO m, PandocMonad m) => Pandoc -> m Pandoc ...
paid50-face-pretty's user avatar
0 votes
2 answers
194 views

A monad, I've been told, is a monoid of X in the category of endofunctors of X, where X is some category. Maybe is supposedly then a monoid, which means that it is: an object of a category, some ...
Erik's user avatar
  • 19
1 vote
1 answer
131 views

I want to use print from chain of functions, but it doesn't work. getNext is called from inside app1, but print is not called from inside app2. Why? The output is just Just (39,40,41,"zzz") ...
Dmitry Kapustin's user avatar
3 votes
0 answers
46 views

I have a program that does slightly different things on different OS/architectures. I'll use this example: main = do output <- readProcess "uname" [] "" print $ case ...
Koterpillar's user avatar
  • 8,288
3 votes
2 answers
89 views

I was trying to define an integer type, and a typeclass that would allow operations on all Numberlike types. {-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# ...
Ashok Kimmel's user avatar
4 votes
3 answers
125 views

I am trying to split my code into nice modules. However, while doing this, one of the classes I have in the imported module (Outer in Module 1 below) needs a constraint that is only known in the ...
Niek Janssen's user avatar
1 vote
1 answer
97 views

I'm trying to use State Monad in a personal section of code in order to have a more natural code . The problem and the code section are the following ones . I'm trying to ask interactively a user to ...
Yago's user avatar
  • 445
5 votes
1 answer
152 views

I have a class called Cls. In one of the instances of Cls, in one of the methods, I want to do some code analysis from within template haskell. I have to run a reify to start this inspection. Full ...
Niek Janssen's user avatar
0 votes
1 answer
58 views

I am having trouble getting the following code to work. I got it to work originally, then I changed it so all the Nonterminals also have positions. And I added the method parseLexeme that transforms ...
Jacob Bauer's user avatar

1
2 3 4 5
1037