« first day    last day (1866 days later) » 

12:13 AM
0
Q: QuickCheck Generator - Arbitrary element of custom type

VSZMI am trying to generate arbitrary sized element for my custom data type: newtype ZippList a = ZPL ([a], [a]) deriving (Show) This is what I got: instance Arbitrary a => Arbitrary (ZippList a) where arbitrary = sized zipplist where zipplist n = do firstLength <- choose(0,n) ...

 
12:24 AM
0
Q: AD, type unification error with constrained-type Vector

ocramzI need to find the Jacobian of a V.Vector CDouble -> V.Vector CDouble function. While trying to produce a minimal example from the answer How to do automatic differentiation on complex datatypes? , I still stumble on a knot of type unification problems. The closest I got so far (complete code b...

0
Q: Read csv and return JSON

KanotaurI'm brand new to haskell, this is the second day I use it, I have an csv file, which I need to format to a JSON file, I manages to read the csv file, the function I did returns a [[String]] data type, now I need to work on it to make the J Value, but I honestly have no clue on how to go on with ...

-2
Q: Suming the digits of a very large number

papajoI want to sum the digits of the first 100.000 digits of pie (I have a txt with the numbers) but I want to do it in a specific form I want to put the digits in a matrix (or whatever is convinient as a placeholder) with a small number of cells predifined by me and overlap the digits in those cell...

 
12:49 AM
0
Q: How to shorten a Hakell implementation like this?

heyheyheyyyyyI have a function with a lot of guards that look like this: function | p `elem` [0,1,2,3,4,5,6] = [0,1,2,3,4,5,6] | p `elem` [7,8,9,10,11,12,13] = [7,8,9,10,11,12,13] | p `elem` [14,15,16,17,18,19,20] = [14,15,16,17,18,19,20] | otherwise = [] I'm sure I can write this much sh...

 
 
2 hours later…
2:50 AM
0
Q: Hooking up a build tool in Cabal (Haskell)

user5803465I was trying to use bnfc tool to generate a bunch of files , like Lexer , Parser etc for me. This works fine. Now I wanted to clean this up a bit by not having to manually compile the bnfc file and having it generate a number of files which clutter my /src folder. I tried the cabal mechanism wh...

 
 
4 hours later…
7:07 AM
0
Q: build error on dependencies when using cabal

ormI am building a small project, and when cabal attempts to install MissingH 1.3.0, it runs into a compiler error (name clash): src/System/IO/HVFS.hs:287:23: Ambiguous occurrence ‘isSymbolicLink’ It could refer to either ‘System.IO.PlafCompat.isSymbolicLink’, i...

0
Q: Is it a good approach to build backend using Yesod(haskell framework)?

khaled el omarI am new to Haskell , I love its style and I am looking to build a web application following the rest concept (separating Backend from Frontend) what about Yesod, does it have an active community and good libraries ?

 
7:36 AM
0
Q: Dealing with (the risks of) infinite sequences in Haskell

kaiI'm a couple of weeks into dabbling with haskell and I've made a pretty big dent in Learn You A Haskell. I feel like many of the type classes and common implementations up to applicatives and monads make a lot of sense to me and I understand how they work, but I still lack a lot of practical expe...

 
 
5 hours later…
12:43 PM
0
Q: Using Graphics.Gloss and animate to make a clock

HoRnsUpmodule Main (main) where import Graphics.Gloss main = animate (InWindow "" (600, 600) (100,200)) white scene scene :: Float -> Picture scene t = scale 3 3 ( pictures ( [ circle 80 , translate 80 0 (color green (rectangleSolid 10 5)) , translate 0 80 (color green (rectangleSolid 5 10)) , ...

 
 
1 hour later…
1:47 PM
0
Q: Is there a builtin "inverse function" of Control.Monad's join?

wizzupI use map (:[]) to split String to [[Char]] and wonder if there any builtin function that do the same exist In [1]: as = "abcdefg" In [2]: bs = map (:[]) as print bs ["a","b","c","d","e","f","g"] In [3]: import Control.Monad cs = join bs print cs "abcdef...

 
 
1 hour later…
2:51 PM
0
Q: Custom sine function in Functional Programming

SenseiPlease help, I've been trying to get this code to work but I can't find the errors. Below is my code sumToN f x 1 = f (x 1) sumToN f x n = f x n + f x (n-1) facOfN 0 = 1 facOfN n = n * facOfN (n-1) sgfr sineApprox x n = ((-1) ^ n) * ((x ** (2*n+1))/facOfN(2*n+1) sine x n = sumToN (sineApprox x...

 
Haskelly goodness tonight: fn and url routing: meetup.com/NY-Haskell/events/230142951
 
3:09 PM
0
Q: Haskell Generating graphs with QuickCheck properties

AnonymousGraphs have these properties: The type 'Edge' represents an edge between two nodes. data Edge v = Edge {source :: v, target :: v} deriving (Show,Eq,Ord) The 'Graph' type represents a directed graph. data Graph v = Graph {nodes :: Set v, edges :: Set (Edge v)} deriving Sh...

 
3:30 PM
0
Q: How to set the status and send a body with Yesod?

mb14I have the following case. The user need to be able to upload a spreadsheet (csv) but if there are errors (for example a value supposed to be a Integer is not a number) I need to display the full csv as a table with a red background on the invalid cell. I would like to set the status to 422, but ...

 
4:09 PM
1
Q: List monad instance that appends elements

Vlad the ImpalaIs it possible to make a Monad instance of List that would work like this? foo = do [1] [2] [3] main = print foo -- prints [1,2,3] To make this work, I would need a constraint that every array have the same type: [Int].

 
4:50 PM
0
Q: Printing Pascal's triangle in Haskell

Master_PabuI just started learning Haskell, and have been doing a few problems online. Most of the times, I can figure out the solution but I am unable to print it out in the output format that is expected. For example, I tried doing a Pascal's triangle program. I found out how to generate Pascal's Triang...

 
 
1 hour later…
6:06 PM
0
Q: Opposite of Maybe data type

Haitham GadSo the Maybe data type is defined like this: data Maybe a = Just a | Nothing What would you call the data type that's conceptually opposite to Maybe: data <Type> = Okay | Error String That is, a type that declares the computation successful or holds some error produced by the computation.

 
6:53 PM
-1
Q: parse [[String]] to Json

KanotaurI have a function that returns a [[String]] data,I need to iterate over it, to create JSON structures and then write them to a file, I think I know how to iterate over it, but I have no clue on how to create the JValue data when the incoming data may be a string, a boolean or a number.

0
Q: Operator & in haskell?

P_FerreiraHow to check the second argument between an operation of true and false in haskell? E.g, False && True will only check the first argument and then will stop the operation. Is there something like False & True in Haskell to check both arguments?

 
7:12 PM
0
Q: Testing 'DAG' aka acyclic graphs properties in Haskell QuickCheck

Fluidsmodule Graph where import Control.Monad.State import Data.Maybe import Data.Set as Set -- | 'Edge' represents an edge entre two nodes. data Edge v = Edge {source :: v, target :: v} deriving (Show,Eq,Ord) data Graph v = Graph {nodes :: Set v, edges :: Set (Edge v)} ...

 
7:35 PM
0
Q: How would one access ActiveXObject with elm?

Mikeec3I'm playing around with the idea of an installer similar to ninite but all web based ( for practice ) where I built a very minimal powershell lexer using elm. I want to be able to access ActiveXObject to be able to run a powershell script using elm. Is there a specific way to do this? Also, how...

 
7:58 PM
0
Q: Why can't I replace libraries distributed with GHC? What would happen if I did?

Echo NolanI see in this answer that "everything will break horribly" and Stack won't let me replace base, but it will let me replace bytestring. What's the problem with this? Is there a way to do this safely without recompiling GHC? I'm debugging a problem with the base libraries and it'd be very convenient.

 
8:24 PM
0
Q: not able to install Haskell package using Cabal

khaled omarI am mac user, I have installed Haskell-platfrom and trying to install some Haskell library using cabal( cabal install servant ) with no success getting the below error message cabal: /Users/myuser/.cabal/logs/network-2.6.2.1.log: does not eDownloading stm-2.4.4.1... xist please advise.

 
8:55 PM
0
Q: How do I express this in Typescript?

bchernyLet's say I have an interface A: interface A { foo: number bar: string } And I have a generic type Option: type Option<T> = { map: () => T } Then I create a new interface B from A and Option: interface B { foo: Option<number> bar: Option<string> } How can I make this operation ...

 
 
2 hours later…
10:47 PM
0
Q: Haskell call Node.js file not working

user3700129I am trying to write a program in Haskell that takes in the input as a string of sentences, calls a javascript file with that input, and return the output of that javascript file as the output of the Haskell file. Here is the script in Haskell: main :: IO () main = do putStrLn "...

 

« first day    last day (1866 days later) »