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,412
questions
0
votes
0
answers
7
views
How to protect against XSS attacks in Servant Framework?
I have an S2S API which takes in user input and some of that input later gets sent to the frontend. If the user data contains any html like <script> tags, I want to throw a Bad Request 400 ...
0
votes
1
answer
12
views
How to use custom HTML attributes with Blaze in Haskell
I'm trying to write the following HTML element from Bootstrap in blaze-html in Haskell.
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-...
1
vote
1
answer
19
views
What does it mean in Haskell when a function doesn't handle every constructor of a data type?
Consider
data Pair = Pair (Headers, Builder)
| CompoundPair (Headers, [Pair])
showBoundPart :: Boundary -> Pair -> Builder
showBoundPart (Boundary b) (Pair (headers, content)) = ...
3
votes
1
answer
40
views
Why does GHC's type-checker accept this UndecidableInstance trick?
GHC accepts the following code.
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
class Blib b where
blib :: b
class Blob b where
blob :: b
instance Blib b => Blob b ...
0
votes
0
answers
16
views
How to run Servant context entries in a custom monad stack instead of DelayedIO (for HasServer implementations)
We are writing custom Servant combinators to handle "resource authorisation" in our application. So we don't have to explain the domain itself, I'm going to use a task list app as an analogy....
2
votes
1
answer
53
views
What's the difference between placing a parser in its "box" vs using it without it? [duplicate]
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
54
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
67
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
77
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
39
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
31
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
53
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
83
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
37
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
56
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/...