Questions tagged [haskell]
Haskell is a purely functional programming language featuring strong static typing, lazy evaluation, extensive parallelism and concurrency support, and unique abstraction capabilities.
haskell
51,408
questions
2
votes
1
answer
31
views
What's the difference between placing a parser in its "box" vs using it without it?
So this is my parser, and two functions to run a parser:
data Parser a = MkParser (String -> Maybe (String, a))
unParser :: Parser a -> String -> Maybe (String, a)
unParser (MkParser a) inp =...
-1
votes
0
answers
46
views
Why is quick sort in Haskell so good? [closed]
I'm going through Learn you a Haskell and it claims that quick sort can be easily implemented in Haskell like this:
quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x:xs) =
...
1
vote
2
answers
60
views
Is read inverse of show in Haskell?
I just tried writing
read (show 42)
in ghci. It responds with '*** Exception: Prelude.read: no parse'.
My assumption was that it should return 42. My reading of various manuals and tutorials suggests ...
2
votes
1
answer
72
views
How to combine two Maybes
I'm curious of different ways of combining Maybes. There's a small example of what I am able to achieve with a do (I reckon using the fact Maybe is a monad), however for this particular example I'm ...
0
votes
0
answers
36
views
VS Powershell wont let me compile, but using it externally will
I'm currently using two different languages and having a similar issue on both. With Java the powershell within VS code isn't allowing me to compile using Javac, and I can't use GHCI for Haskell.
...
2
votes
0
answers
28
views
How to load custom dependencies in interactive Haskell-mode?
When using haskell-mode, I use C-c C-l to load the current file into repl/ghci and normally it works like magic. However, if I want to load a file from the test directory, ghci fails to load the ...
0
votes
2
answers
51
views
How to use answers of parsers when nesting parsers (sequentially)
This is my Parser
data Parser a = MkParser (String -> Maybe (String, a))
This is a parser that parses if a particular predicate holds true.
satisfy :: (Char -> Bool) -> Parser Char
-- takes a ...
1
vote
3
answers
82
views
`type <nameOfType> = Typeclass` compiles, but `type <nameOfType> = (Typeclass, Typeclass)` doesn't
I've been reading about the renaming of pre-existing types using the haskell's type and, as much as I could understand, the type is only used for renaming concrete types, like Int, Integer, Char, ...
2
votes
0
answers
34
views
How do I solve this infinitely recursive type problem I've created in Haskell with Church Numerals [duplicate]
data ChurchN a = ChurchN
{ numeral :: (a -> a) -> a -> a
, litRep :: String
}
next :: ChurchN a -> ChurchN a
next x = ChurchN
{
numeral = \f y -> f (numeral x f ...
0
votes
1
answer
55
views
Cabal run unable to see packages that interactive haskell mode can
I am having trouble using cabal. I am looking to use the Data.Finite package from hackage.
I ran cabal install finite-typelits-0.2.0.0 which I believe went successfully. I now see the directory .cabal/...
0
votes
0
answers
21
views
Compiling project errors within a docker container targeting linux/amd64
I've been developing a side project (a small web app). I'm developing on a Macbook M1 Pro, however, I need to compile it to test against a linux/amd64 environment. I'm trying to use docker for that. I ...
1
vote
1
answer
67
views
Understanding bracket use in Haskell - Parser that depends on previous parser gives error when using brackets
Ok so I'm trying to learn Haskell.
This is my Parser.
import Data.Char
data Parser a = MkParser (String -> Maybe (String, a))
This is a parser which parses a string once, and depending on what it ...
0
votes
3
answers
165
views
Scan that splits accumulator and yielded value
Edit: the function I was asking for was mapAccumL
Problem: split a list of ints such that the sums of the sublists are bounded (by 10)
Here's how I would solve it in python using a scan to do the ...
3
votes
1
answer
124
views
Primes using setjmp
I wrote a simple Haskell function, that gives a list of primes.
primes' :: [Int] -> [Int]
primes' (p : xs) = p : primes' (filter (\x -> x `rem` p /= 0) xs)
primes :: [Int]
primes = primes' [2 .....
4
votes
3
answers
142
views
How does <$ = (fmap . const) in Functor even work in Haskell?
I know that the dot (.) operator takes two functions which both take an argument respectively, and the third argument for the second argument.
Its type is (.) :: (b -> c) -> (a -> b) -> a -...