Skip to main content
Filter by
Sorted by
Tagged with
Best practices
1 vote
6 replies
22 views

In English, I might talk about the category or property or type tree, and then refer to specific trees as tree "instances" of the property tree. (In philosophical writing, sometimes it's ...
Mars's user avatar
  • 8,884
-1 votes
0 answers
19 views

I have no idea how to realize MonadError for case class MyPair[+A, +B](a: A, b: B), since I don't understand how to deal with 2 types in Monad. I've been trying to write it for 2 weeks already, no ...
spydula's user avatar
Best practices
0 votes
2 replies
44 views

I want to make a function call with two arguments: function and its arguments. Arguments are provided as heterogeneous list (Data.HList). Function should have a signature matching types of arguments. ...
Dmitry Kapustin's user avatar
Best practices
1 vote
2 replies
82 views

How could I get a type of parameter from parametrized type? For example, for type T = Maybe String I want to get String, for type T = [Bool] I want to get Bool. It should be a function of T. Thanks in ...
Dmitry Kapustin's user avatar
0 votes
2 answers
80 views

I have the following sample code which shows the problem {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE FlexibleContexts #-} {-# ...
JonnyRaa's user avatar
  • 8,148
0 votes
1 answer
102 views

MRE: MyType = MyDataCtor [MyType] | MyDataCtor2 MyType MyType | ... other cases (none of which require the map operation) foo :: Type1 -> Type2 -> (Type1, Type2) For example, for the ...
kesarling's user avatar
  • 2,336
2 votes
1 answer
38 views

I'm creating a toy language in Haskell, and using Text.Parsec to parse everything, So far it's worked great, but there's a certain feature that I don't know how to implement: What I want to implement: ...
buzzbuzz20xx's user avatar
Advice
0 votes
4 replies
55 views

I can get types of arguments of the function, I can collect it in some form, for example type T1 = String -> Int and I have return type of the function, for example type T2 = Bool. How can I ...
Dmitry Kapustin's user avatar
1 vote
3 answers
58 views

I am programming a Typechecker for a language that extends System F. This is my definition of Types (MRE): data SType = SInt | SBool | SVar string | <9 other data constructors> | ...
kesarling's user avatar
  • 2,336
4 votes
0 answers
59 views

disjointCollisions :: Eq k => Word -> Array (Leaf k a) -> Word -> Array (Leaf k b) -> Bool I would like this function to be specialized (to arbitrary unknown key types k) but never ...
sjakobi's user avatar
  • 3,698
Advice
3 votes
4 replies
85 views

In Wayne Snyder's slides on the State monad, slide 11 includes the following Haskell code. There's not a lot of explanatory text on this slide, but it seems clear that these two snippets are supposed ...
Mars's user avatar
  • 8,884
Best practices
0 votes
1 replies
101 views

I currently have this implementation: data RoseTree a = RoseTree a [RoseTree a] preorder :: Tree a -> [a] preorder (Tree x ts) = x : concatMap preorder ts instance Foldable Tree where foldr :: (...
Panic's user avatar
  • 93
3 votes
1 answer
83 views

I cannot fix this error. build.sh is trying to create a shared library but it fails: ~/Desktop/deepseek$ ./build.sh Building Haskell shared library... Loaded package environment from /home/success/....
success moses's user avatar
-3 votes
1 answer
144 views

I need help with some haskell syntax. I have a really long type signature and I need a quick way of making sure that the parts of it which are equal are represented in the signature itself. Signature: ...
kesarling's user avatar
  • 2,336
2 votes
1 answer
64 views

The following program gets the error: "Illegal term-level use of the type constructor or class ‘IOError’" even though it's right out of the source to ghc: {-# LANGUAGE Trustworthy #-} {-# ...
davidg's user avatar
  • 63
1 vote
2 answers
139 views

Here is the question from Mitchell Wand's Essentials of Programming Language: Exercise 1.19 [⋆ ⋆] (list-set lst n x) returns a list like lst, except that the n-th element, using zero-based indexing, ...
YCH817's user avatar
  • 123
-1 votes
1 answer
128 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
2 votes
4 answers
219 views

I'm looking into associated type families. As an own learning example, I try to model a small part of the x86 assembly language. This compiles: {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ...
Jogger's user avatar
  • 1,783
Advice
0 votes
4 replies
135 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
4 votes
2 answers
112 views

Problem: Can't avoid a module cycle with class definitions in Haskell. Foo.hs contains: module Foo where import {-# SOURCE #-} Bar class FooClass a where ... myBar :: BarClass -> a -- use a ...
davidg's user avatar
  • 63
0 votes
1 answer
79 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
Best practices
5 votes
3 replies
152 views

I had a nice idea of using applicative for nondeterministic financial modelling. Or maybe it is a simple case of sentization. So the basic example is to define newtype ValueRange. newtype ValueRange a ...
Dominik G's user avatar
  • 614
5 votes
2 answers
155 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,783
5 votes
1 answer
140 views

Consider this Haskell code that compiles successfully: {-# LANGUAGE RankNTypes #-} -- Applies a polymorphic function to different types, expecting 3 constraints applyToMany :: (forall a. (Show a, Eq ...
Thomas's user avatar
  • 6,364
4 votes
1 answer
119 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.3k
0 votes
1 answer
154 views

MRE: module Temp where data Some r a = Thing r a instance Monad (Some r) where return :: a -> Some r a return a = Thing r a -- <- The is a phantom argument (somewhat like the s in ...
kesarling's user avatar
  • 2,336
2 votes
2 answers
187 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
3 votes
1 answer
93 views

I am currently writing common theorems of intuitionistic logic in Haskell using the Curry-Howard isomorphism: import Data.Void type a :> b = a -> b -- implies type a :+ b = Either a b -- or data ...
Zayd Mohammed's user avatar
2 votes
1 answer
95 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
5 votes
2 answers
134 views

I encountered a problem where my ram explodes and I really don't know why. the code to read a csv is: --module splitComma _ [] = [[]] splitComma False (',':t) = [[]]++splitComma False t splitComma ...
Agustin Bustos Barton's user avatar
4 votes
1 answer
121 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
2 answers
108 views

If in a terminal I enter mkfifo /tmp/pipe echo hello > /tmp/pipe (which blocks) and in another I run the haskell program main = readFile "/tmp/foobar" >>= putStr then I see it ...
Enlico's user avatar
  • 30.3k
3 votes
1 answer
87 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
2 votes
1 answer
87 views

I'm reading the paper Selective Applicative Functors. So far I've read from page 16 out 29, and I think I've understood the gist of this abstraction, but I'm having some trouble with some basic ...
Enlico's user avatar
  • 30.3k
1 vote
1 answer
91 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.3k
1 vote
1 answer
81 views

This question tries to collect the full picture if/when a stale object reference can happen from an old-gen (immutable) array referring a newer-gen object, from fragments of information. Preface: was ...
ron's user avatar
  • 9,458
1 vote
1 answer
68 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
3 votes
2 answers
107 views

I'm familiar with the SPECIALIZE pragma, or INLINE/INLINABLE that might enable automatic specialization at the use-site. But those are about specializing functions for type variables taking special ...
ron's user avatar
  • 9,458
1 vote
2 answers
170 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
5 votes
3 answers
131 views

Let's say I am receiving a streaming response from a web service. I get the response in the shape of a ConduitT () (Either a b) m (). Now, let's say I know from the API documentation that the response ...
Jules's user avatar
  • 619
3 votes
1 answer
113 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,698
0 votes
0 answers
94 views

I started a new Yesod project with stack new blog yesodweb/postgres. The template generates an app/DevelMain.hs with a comment at the top that says that we can get faster dev reloads via stack ghci ...
doliver's user avatar
  • 1,046
0 votes
0 answers
71 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
0 votes
0 answers
71 views

Why is this slow fibonacciSequence :: Integral a => [a] fibonacciSequence = 0 : 1 : zipWith (+) fibonacciSequence (tail fibonacciSequence) -- in repl take 10000 fibonacciSequence but this ...
daikonradish's user avatar
2 votes
2 answers
140 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
2 votes
1 answer
140 views

I'm trying to write a function that performs a binary operation on either floating-point numbers or integers. My attempt: data MyNum = F Float | I Int performBinaryOperation :: (Num a) => (a -> ...
Jacob Lockard'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
0 votes
0 answers
48 views

I am learning parallel programming in haskell. My example code: module Quicksort where import Control.Parallel.Strategies import Control.Parallel qsort :: [Int] -> [Int] qsort [] = [] qsort lst@(...
kesarling's user avatar
  • 2,336
3 votes
2 answers
114 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
1 vote
1 answer
74 views

I have this datatype newtype Dimension a b = MkDimension b Whenever it is properly formatted (e.g. satisfies the format constraint), I want to derive a set of classes. I do not want a Dimension which ...
Ashok Kimmel's user avatar

1
2 3 4 5
1037