« first day (1 day earlier)      last day (1865 days later) » 

1:37 AM
0
Q: No instance for (Integral Double) arising from a use of 'rem'

StardustGogetaHaskell "No instance for" error Haskell Error: "No instance for (Enum [Int]) Function definition problems (No instance for … arising from) No instance for Num String arising from the literal `1' I am very new to Haskell, and functional programming in general. In addition, I am aware that the ...

 
 
9 hours later…
10:18 AM
2
Q: Why is sum slower than foldl' in haskell?

dimidHow come the default sum in ghc is ~10 times slower than its foldl' (the stricter equivalent of foldl) equivalent? And if that's the case, why isn't it implemented using foldl'? import Data.List > foldl' (+) 0 [1..10^7] 50000005000000 (0.39 secs, 963,528,816 bytes) > sum [1..10^7] 5000000500000...

 
 
1 hour later…
11:41 AM
0
Q: JSON listing all identities in a set

mcNogardI have recently started working with JSON. The code below shows a snippet of what I'm working with. In this example, I want to extract the set {1411, 1410, 2009, 3089}. Do JSON provide a method for this, or do I need to create it myself? In case it is relevant, I'm working with Haskell. { "...

 
12:02 PM
2
Q: How to resolve overlapping instance

mb14I have the following code (transform is similar to convert) instance {-# OVERLAPS #-} Transformable a a where transform x = x instance {-# OVERLAPPABLE #-} (Transformable l l', Transformable r r' ) => Transformable (Either l r) (Either l' r') where transform = bimap transform...

 
12:20 PM
0
Q: Haskell type declarations for multiple parameter functions

0xor1I'm looking through this introduction to Haskell which contains this example: data Tree a = Leaf a | Branch (Tree a) (Tree a) which it says is essentially also defining the types: Branch :: Tree a -> Tree a -> Tree a Leaf :: a -> Tree a I und...

 
 
2 hours later…
2:11 PM
0
Q: Haskell, how to check for a palindrom

Martin Mi got a small question, how could i extend my function to return True, even if a character is a capital lette or not. My function works for Strings in lists: f1 w = w == reverse w Test: *Main> let test = ["Boob"] *Main> f1 test True *Main> let test2 = "Boob" *Main> f1 test2 False regards, ...

 
2:52 PM
1
Q: get product out of numbers in a string

PignaFor instance if input is "12345" I want the outcome to be 1 * 2 * 3 * 4 * 5 = 120. I wrote the following: import Data.Char stringProduct :: Int -> [Char] -> Int stringProduct p [] = p stringProduct p (n:ns) = stringProduct np ns where np = p * (digitToInt n) main = print $ stri...

 
3:21 PM
0
Q: Can I have plus or minus when doing cases?

QwertfordCould I put a case to be within a certain range or another number? say ... case x of +/- 3 -> yes ... Would that be something Haskell should understand? Update: In short, would i be able to match to an interval rather than a number?

 
4:07 PM
0
Q: Can I pattern match on type name?

Chad GilbertIs it possible to pattern match on the type name itself instead of on one of a type's constructors? Here's a contrived example with code that doesn't compile which I hope explains what I'm after: what :: a -> String what (x :: String) = "It's a String!" what (x :: Int) = "It's an Int!" what x...

 
4:42 PM
0
Q: Filter IO [Maybe String] to IO [String]

ParadiesstaubHow to filter IO [Maybe String] to only keep the Just values of the list using >>= and keep the IO context. -- returns Just, if the passed binary-name is not present on the system binDoesntExist :: String -> IO (Maybe String) binDoesntExist ... My current solution without the bind-operator: m...

 
4:58 PM
I saw a lot of people I know there last night. Kinda weird how there's so little overlap in groups, but there are a few people who go to everything.
wow, this room looks so empty without the feeds.
 
 
2 hours later…
6:40 PM
0
Q: Intepreter in haskell. Control of types

J. DoeI am writing an interpreter in Haskell and I am considering how to organize control of types - it makes troubles. I am going to provide three types: bool, int, string. Please give me some advice.

 
7:13 PM
0
Q: How to run function on list with error propagation

Haskell FunHelp me please in following thing: I have two functions: eFAs :: [Ex] -> [AD] -> ReaderT E (StateT St (ErrorT String IO)) [(VN, TT)] eFA :: (Ex, AD) -> ReaderT E (StateT St (ErrorT String IO)) (VN, TT) Now, I would like to be use eFA in eFAs, in order to return list or Error (keep in your m...

 
8:07 PM
0
Q: Monadic seqeunce ErrorT/Map.lookup

J. DoeI am writing interpreter in Haskell and I have map: name_of_function -> defintion of function. Map String Defun My interpreter monad: type InterpreterMonad = StateT (EnvFun, (Stack EnvEval)) (ErrorT String IO ) () And as you can see "last" monad is ErroT. Now, when I would like handle ca...

 
 
1 hour later…
9:28 PM
0
Q: Haskell Pig Latin Translator - v2

BalinKingOfMoriaThanks to Gurkenglas for the help with the previous iteration: Haskell - Pig Latin Translator! Given the constraint that the newtypes are required, what improvements could be made to the following Pig Latin translator? {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE InstanceSigs #-} import Con...

0
Q: How to make these string matching functions in Haskell?

GeorgeConsider the following multi-line string S: apple banana berry cantelope I'm trying to write/locate Haskell functions which I will call in this post or-match and and-match. Here are some examples of what they should do: or-match S ("apple","berry") {- should return the two line string: apple...

 
 
1 hour later…
10:58 PM
0
Q: Haskell: Applicative over tuples

user3550758I have a problem. I have a datatype Thing thats essentially a big record of Maybe Doubles or Maybe Texts. I want to create a datatype that can capture the idea of running computations on it even though some fields may be Nothing. data Computation a b = Computation { getInputs :: Thing -> a ...

 
11:43 PM
3
Q: (ML) Modules vs (Haskell) Type Classes

Rahul ManneAccording to Harper (https://existentialtype.wordpress.com/2011/04/16/modules-matter-most/), it seems that Type Classes simply do not offer the same level of abstraction that Modules offer and I'm having a hard time exactly figuring out why. And there are no examples in that link, so it's hard fo...

 

« first day (1 day earlier)      last day (1865 days later) »