Most voted "haskell" questions
Haskell is a functional programming language, with referential transparency and non-standard evaluation.
Learn more…66 questions
Sort by count of
-
24
votes4
answers4078
viewsPros and cons of the functional paradigm and Haskell
I saw that, clearly, the Functional Programming Stop is not at all famous in the world of programming in general. However, talking to a few fans of languages like Lisp, Ocaml, F#, Haskell, etc. I…
-
13
votes2
answers1533
viewsMaterial for the study of functional languages: scala, Haskell and Erlang
Well, I asked a question recently and it was suspended because it is a matter of opinion of each person, so here I repeat my question to be more clear what I want: Could someone please pass me…
-
8
votes1
answer87
viewsCompile Archive . ly
I’m compiling a program in Haskell, but came a file .ly, and I can’t compile it. I try ghc Grammar.ly And I get the message: ld: warning: ignoring file Grammar.ly, file was built for unsupported…
haskellasked 9 years, 9 months ago Pedro Soares 1,136 -
8
votes1
answer1009
viewsFunctional Programming and Referential Transparency
Referential transparency assures me that given the same input values for a function, it will always give me the same return value. As I would have to do in the case of a function that accesses the…
javascript functional-programming haskell erlang f#asked 9 years, 5 months ago Henri Cavalcante 384 -
8
votes1
answer150
viewsWhat it means to infix on Haskell
What is and what this infixr 3 is for &&? infixr 3 && (&&) :: Bool -> Bool -> Bool True && True = True _ && _ = False
-
7
votes2
answers4189
viewsHow to generate the alphabet with white space between letters?
In Haskell I can generate the alphabet as follows: alfabeto = ['a'..'z'] To display it is enough: alfabeto "abcdefghijklmnopqrstuvwxyz" However, I would like to know how I can put a space between…
-
5
votes1
answer152
viewsCheck whether it is palindrome (No instance for (Eq a) arising from a use of `==')
I got the second error in the code: No instance for (Eq a) arising from a use of `==' Code: --Verifica se a lista é um palíndromo palin :: MList a -> Bool palin(x) |x==reverter(x) = True…
-
4
votes2
answers650
viewsCreating files in Haskell
I wanted to record the output of my program straight into a file. When I executed the code, I automatically generated a file with the outputs of this code instead of printing them on the screen. A…
-
4
votes1
answer503
viewsProgram to filter odd numbers in a number list
I wrote a script in Haskell to find filter the odd numbers from a list and show them on the screen, but I keep getting an error when displaying the results.. impares[] =[] impares(x:xs) |(mod(x…
-
4
votes0
answers388
viewsHow to compare two Strings in Haskell?
buscaLivroNome :: Livro -> Nome -> String buscaLivroNome [] _ = "Nao Encontrado" buscaLivroNome ((codigo,nome1,preco, autor, ano):resto) nome2 | nome1 == nome2 = "Livro Encontrado" | otherwise…
haskellasked 7 years, 4 months ago Alison Vieira 49 -
4
votes2
answers98
viewsHow do I know if a value is higher or lower than another value in a list using recursion?
Being a classified monster with your name, attack and defense. ("medusa", 2, 5) or (string, int, int). And getting a list of monsters, how do I create a function that tells me if the monster I want…
-
3
votes1
answer273
viewsSimple error in code in Haskell
I’m starting at Winhugs, programming at Haskell. I’m new at Functional Programming. Since yesterday I am looking to solve the error you have in the code below but unsuccessfully so far. Follow the…
-
3
votes1
answer87
viewsDefine a function with different amounts of arguments
Is there any reason why this function: foo f x y = f x y foo x y = (+) x y Return this error? Equations for `foo' have Different Numbers of Arguments Why doesn’t Haskell allow this behavior?…
-
3
votes0
answers223
viewsFunctional or imperative language to study Machine Learning?
I am new to programming and I am studying javascript to become Front End Developer as a short term goal, in the future I intend to be a programmer, because I have an interest in machine…
functional-programming artificial-intelligence haskell machine-learning imperative-programmingasked 8 years, 6 months ago Misael 41 -
3
votes1
answer75
viewsHow to use Monad batteries?
I studied the topic of Monad and decided to make a program to test my knowledge. import Control.Monad.IO.Class (liftIO) import qualified Control.Monad.State as ST import Control.Monad.Trans.State…
-
3
votes1
answer149
viewsDoubt about duties in Haskell
I decided to dive into the world of functional programming recently, and was introduced to the Haskell language. I started researching how language works, and soon I was able to get the main…
haskellasked 7 years, 9 months ago Artur Trapp 5,175 -
3
votes1
answer51
viewsWhat is the difference between [a] and "a" in Haskhell?
That is correct?? [a] = a list with only 1 element a = a list of all the elements you want Ps: I have some doubts because some functions are of the type [a]->a but also read , for example [2,3]…
haskellasked 7 years, 2 months ago Joao Parente 43 -
3
votes1
answer55
viewsGuards vs functions with Pattern matching
I’m starting out in Haskell and I was doing some exercises on her Exercism. When I sent a code, I compared it with the others and came across a very similar one to mine, but I used a definition of…
-
3
votes3
answers1433
viewsHow to create list in Haskell
How do I create a function that takes a list (can be dynamic or static) and returns the n-issimo element of that list? I use the Haskell language.
-
3
votes1
answer54
viewsWhy doesn’t this simple code in Haskell compile?
I’m studying Haskell, and I don’t understand why this code doesn’t compile: foo :: Int -> Double -> Double foo a b = a+b The error message is: Couldn't match expected type `Double' with actual…
haskellasked 6 years, 5 months ago Daniel Moreira 33 -
3
votes1
answer303
viewsHow to pick the first item from each list from a list list
I’m new to programming at Haskell, and I wanted to know a way to take the first item from each list and put it on a list, then the second, then the third and so on... An example would be more or…
haskellasked 6 years, 5 months ago Felipe Queiroz Barreto 31 -
3
votes1
answer1119
viewsConcatenation of lists in Haskell eliminating repetitions
Hello, it’s been a few hours that I’m trying to make a function in Haskell that gives two lists and returns a new list Where this new list is the union of the other two lists but without repetitions…
-
3
votes1
answer257
viewsRecursiveness and Haskell
How to define recursively in terms of multiplication, the power function, where a base is raised to a non-negative integer exponent? Code: expo (x, y) y > 0 fun(pot) return x*expo(x, y-1)…
-
3
votes1
answer81
viewsPolymorphism with list comprehension in Haskell
I have these two functions: sequenciaInt :: Int -> Int -> [Int] sequenciaInt i j |j >= i = [i..j] |otherwise = sequenciaInt j i sequenciaChar :: Char -> Char -> [Char] sequenciaChar i…
haskellasked 5 years, 2 months ago Henrique Silva 95 -
3
votes1
answer72
viewsError in calculating a PA with Haskell
The function does not return the expected result but I followed the formula and can not understand the error in logic. I hope to return the term i-th. termoPA :: Int -> Int -> Int -> Int…
-
2
votes2
answers2119
viewsResume a list without repeats
Define a primitive recursive function capable of compressing the list by removing all elements repeated in sequence. Ex : aaabbbcddd abcd Any idea how to do that? I honestly don’t know where to…
-
2
votes1
answer117
viewsCouldn’t match expected type `Double' with actual type `Integer'
Code Haskell: bin2dec::[Integer]->Integer bin2dec (h:[]) = h bin2dec (h:t) = h*(2^length(t))+bin2dec(t) bin2frac :: ([Integer], [Integer]) -> Double bin2frac(x,y) = fromDouble(bin2dec(x)) * 10…
-
2
votes1
answer50
viewsWhy doesn’t this code go wrong, but it doesn’t return anything?
I’m still learning Haskell (actually just started about 2 days ago) with a basic C# knowledge. In this piece of code the code is supposed to iterate several times in a list and subtract the first…
-
2
votes1
answer94
viewsRecursiveness-elemindices
They know how to recursively define the elemindices function, predefined in Prelude. I defined it in a way, but it doesn’t give the expected result. myElemIndices :: Eq a => a -> [a] ->…
haskellasked 7 years, 2 months ago João Sampaio 125 -
2
votes2
answers72
viewsTree Junction - joinTree
data BTree a = Empty | Node a (BTree a) (BTree a) data LTree a = Tip a | Fork (LTree a) (LTree a) data FTree a b = Leaf b | No a (FTree a b) (FTree a b) Also set the function joinTrees :: Btree a…
haskellasked 7 years ago João Sampaio 125 -
2
votes1
answer85
viewsHow to change typing in Haskell
I want the function to draw a number and, if it is larger than 7, send an approval message and call this add function. However, my function only falls in the 'Else'. The "failed" message appears. I…
haskellasked 7 years ago Joao Albuquerque 45 -
2
votes2
answers366
viewsElements of a List are all the same
I made this function definition equal, which checks that all elements in a list are equal. iguais :: [Float] -> Bool iguais [x,y] = x == y iguais (h:t) = h == (head t) However the result is not…
haskellasked 7 years ago João Sampaio 125 -
2
votes1
answer68
viewsHow can I change the code I made to a recursion
This was the initial code I made: count :: Char → String → Int count x xs = length [x’ | x’← xs, x == x’] Switch to recursion: count = length x' | x' <- xs | x == x' What am I doing wrong? Or is…
haskellasked 6 years, 1 month ago João Santos 21 -
1
votes1
answer70
viewsWhy use the rational type?
Why do languages like Haskell and Clojure adopt rationale as a type? Why would I use Rationale instead of Float or Double?
-
1
votes1
answer918
viewsPosition of an element in the list
Well, I had to do a function that, given a list and a number, returns the element from the list that is in that position (the number). Basically it is the function already defined. The problem is…
haskellasked 7 years, 2 months ago Joao Parente 43 -
1
votes1
answer333
viewsHaskell- List replacement function
They know if there is a predefined function in Haskell that, given an element, replaces it with another element of a given list position. For example: func 1 2 [1,2,3,4] [1,2,1,4]…
haskellasked 7 years, 1 month ago João Sampaio 125 -
1
votes1
answer126
viewsRecursive definition of the pre-closed Enumfromthento function
How to recursively define the Enumfromthento function
haskellasked 7 years, 1 month ago João Sampaio 125 -
1
votes1
answer155
viewsHaskell - Higher Order Functions
(a) any :: (a -> Bool) -> [a] -> Bool that test whether a predicate is true for some element of a list; for example: any odd [1..10] == True (b) zipWith :: (a->b->c) -> [a] ->…
haskellasked 7 years, 1 month ago João Sampaio 125 -
1
votes1
answer61
viewsSave function status in Haskell
I want to implement a button that every time it is clicked changes state in Haskell. If it is on when press it should turn off and vice versa. In c++ I would save the state in a global variable, but…
haskellasked 7 years ago Matheus Toniolli 50 -
1
votes0
answers38
viewsInput and Output - Definition
What is the definition of the following predetermined functions of the System.Random :: to) randomRIO :: (Int,Int)-> IO Int b) putChar :: Char -> IO ()…
haskellasked 7 years ago João Sampaio 125 -
1
votes1
answer41
viewsDoubt in case of Stop
listasIguais :: (Eq a) => [a] -> [a] -> Bool listasIguais [] p = False listasIguais p [] = False listasIguais (x: xs) (y:ys) = x == y && (listasIguais xs ys) listasIguais…
haskellasked 6 years, 12 months ago João Sampaio 125 -
1
votes1
answer41
viewsDoubt Error Tree in Haskell
My teacher, in a matter of Haskell asked to set tree in the following way: Being that defining this way gives this error: And in many corners of the internet, the tree in Haskell they define using…
-
1
votes2
answers117
viewsHow to use guards with Let in Haskell
I wanted to make that same problem calculating the roots of a second-degree function, but using Let. raizes2 :: Float -> Float -> Float -> (Float, Float) raizes2 a b c |delta < 0 = error…
haskellasked 6 years, 2 months ago RareProton 51 -
1
votes1
answer195
viewsHaskell error Not in Scope: data constructor 'Medicines'
Good afternoon, how do I get out of that mistake? I’m trying to include an element in a list of tuples. type Nome = String type Quantidade = Int type HorarioProximo = Int type HoraAtual = Int type…
-
1
votes1
answer69
viewsHow to declare type in a function in Haskell?
Ghci, version 8.6.5: http://www.haskell.org/ghc/ :? for help I’m studying Haskell on this website. It uses the type declaration example in functions, but when trying to do the same ghci generates an…
haskellasked 5 years, 5 months ago WesleyRodrigues 42 -
1
votes1
answer112
viewsBest Backend Platform for Microservices
I have to develop a server with microservices with some functional programming language, initially I thought of Haskell and Clojure (languages with whom I most identify), I need a language with fast…
-
1
votes1
answer92
viewsQuestions with tail recursion in Haskell
Hello, I would like to know how to base the tail recursion in this language. I did not understand why this 1 in the part: "fatcalda n = fataux n 1". I would like you to help me please! fatcalda ::…
haskellasked 5 years, 2 months ago Jessé Júnior 13 -
1
votes2
answers205
viewsa Haskell function that receives with input a number n and a list and returns the number amount greater than n
maiores :: Int -> [Int] -> Int maiores _ [] = 0 maiores n (x:xs) someone has some idea of how to do?
-
1
votes3
answers244
viewsException: Non-exhaustive Patterns in Function - Haskell
I’m trying to make a code in Haskell that eliminates all repeated values from a list, the code is like this: import Data.List filtraLista [] = [] filtraLista (xs : []) = [xs] sort filtraLista…
haskellasked 4 years ago Gustavo Lofrese 35 -
1
votes1
answer298
viewsHow to return a tuple to a function in Haskell?
I started messing with Haskell because of some college activity, and I’m having doubts about what the error in my code might be. The program will have two functions. 'tam', which will return the…