Re: [Haskell-cafe] Bubble sort algorithm implementations (Haskell vs. C)

2010-03-20 Thread Casey Hawthorne
You may want to use a mutable array. >The performance may suffer from the memory allocation for the list. I >wonder if it's possible to make Haskell implementation work faster >without changing the algorithm (there's are actually a few tricks to >make it work faster, but neither implementations ha

Re: [Haskell-cafe] ANN: fixed-list -- A fixed length list library

2010-03-20 Thread Casey McCann
Job Vranish wrote: > Its main advantages are: >  Very easy to use. >  Almost entirely Haskell98 (the non Haskell98 pieces are not critical, just > nice) >  The datatype is a member of  Foldable, Traverable, Applicative, Monad, > etc... >  Then length of the list is encoded in the type in a natural

[Haskell-cafe] Bubble sort algorithm implementations (Haskell vs. C)

2010-03-20 Thread Yasir Arsanukaev
Hello. I have written 2 implementation of bubble sort algorithm in C and Haskell. Haskell implementation: module Main where main = do contents <- readFile "./data" print "Data loaded. Sorting.." let newcontents = bubblesort contents writeFile "./data_new_ghc" newcontents print

Re: [Haskell-cafe] Occurs check error, help!

2010-03-20 Thread boblettoj
newStdGen results in IO Ints whereas i need normal Ints and it seems theres no easy way to convert them without a lot more knowledge of haskell. I have tried using a where clause instead of using do but this is giving me the occurs check error again! --function used to shuffle cards --list equal

[Haskell-cafe] ANN: fixed-list -- A fixed length list library

2010-03-20 Thread Job Vranish
I uploaded a new fixed length list library to hackage: http://hackage.haskell.org/package/fixed-list Its main advantages are: Very easy to use. Almost entirely Haskell98 (the non Haskell98 pieces are not critical, just nice) The datatype is a member of Foldable, Traverable, Applicative, M

Re: [Haskell-cafe] installing Haskell

2010-03-20 Thread Erik de Castro Lopo
love_pku wrote: > It is true that I have asked about the installation of Haskell on > the beginners list. But the problems appeared one after another. I > just felt very sorry to trouble other peopel again and again. Its still better to keep it in one place so that people can see the thread of

Re: [Haskell-cafe] Why does `flip` cause function type so different ?

2010-03-20 Thread zaxis
As a beginner, i cannot understand completely what both Maciej Piechotka and Daniel Fischer-4 said. However, i think it will be a big step for me to study haskell once i understand it. thanks ! zaxis wrote: > >>let f x xs = [x:xs,xs] >> :t f > f :: a -> [a] -> [[a]] > >>:t (>>=) .f > (>>=)

Re: Re: [Haskell-cafe] Why does `flip` cause function type so different ?

2010-03-20 Thread zaxis
yes, i am a haskell-beginners. However, i still feel haskell-cafe is a good place for me to learn haskell ! If the question is too simple for you to answer, then you can just ignore it . I believe somebody else can still supply help even if without you. Ivan Lazar Miljenovic wrote: > > Hein

Re:Re: [Haskell-cafe] installing Haskell

2010-03-20 Thread love_pku
Thank you for response! It is true that I have asked about the installation of Haskell on the beginners list. But the problems appeared one after another. I just felt very sorry to trouble other peopel again and again.Thus ,I begin to wonder if I am too stupid or the installation of Haskell

Re: [Haskell-cafe] Performance question

2010-03-20 Thread Arnoldo Muller
Hello Daniel, Regarding your solution, can I apply {-# SPECIALISE ... #-} statements to datatypes I define? And if so, I am not able to import the datatypes to the module where binarySearch is. The problem is that if I import them a circular dependency is detected and the compiler gives an error.

Re: [Haskell-cafe] Occurs check error, help!

2010-03-20 Thread Ivan Lazar Miljenovic
boblettoj writes: > I was using a do loop to try and create a generator before using it in the > randomR call, is there a better way to do this? Use newStdGen in IO, then pass it around everywhere. > randoms and randomRs return lists whereas i just want a single number. > thanks OK, I though

Re: [Haskell-cafe] Occurs check error, help!

2010-03-20 Thread boblettoj
I was using a do loop to try and create a generator before using it in the randomR call, is there a better way to do this? randoms and randomRs return lists whereas i just want a single number. thanks -- View this message in context: http://old.nabble.com/Occurs-check-error%2C-help%21-tp27966341

Re: [Haskell-cafe] Occurs check error, help!

2010-03-20 Thread Ivan Lazar Miljenovic
boblettoj writes: > Yes sorry, that line should be indented, now it gives me a bigger error :( > What that line is trying to achieve is return a list where the first element > is the card at the given random number in the first list and the rest of the > list should be fed back in to shuffle alon

Re: [Haskell-cafe] Occurs check error, help!

2010-03-20 Thread boblettoj
Yes sorry, that line should be indented, now it gives me a bigger error :( What that line is trying to achieve is return a list where the first element is the card at the given random number in the first list and the rest of the list should be fed back in to shuffle along with a new random number.

Re: [Haskell-cafe] Occurs check error, help!

2010-03-20 Thread Ivan Lazar Miljenovic
boblettoj writes: > shuffle i cards = do > gen <- mkStdGen 10 > return ([(cards!!i) : (shuffle (randomR (0, ((length cards)-2)) gen) > (delete (cards!!i) cards))]) Thta last line doesn't make sense; should it be on the line above? -- Ivan Lazar Miljenovic ivan.miljeno...@gmai

Re: [Haskell-cafe] Occurs check error, help!

2010-03-20 Thread boblettoj
Oh yeh, how silly. How do i create a generator to use in that function call then? i've tried using a do like this: shuffle i cards = do gen <- mkStdGen 10 return ([(cards!!i) : (shuffle (randomR (0, ((length cards)-2)) gen) (delete (cards!!i) cards))]) but that gives me

Re: [Haskell-cafe] Occurs check error, help!

2010-03-20 Thread Yuras Shumovich
2010/3/20 boblettoj : > > Ah yes, that makes sense now, however i have another problem, here is the > updated code: > > --function used to shuffle cards > --list equals random member of array plus the rest of the array > --i is randomly generated from range of length equal to that of cards. > shuff

Re: [Haskell-cafe] Occurs check error, help!

2010-03-20 Thread boblettoj
Ah yes, that makes sense now, however i have another problem, here is the updated code: --function used to shuffle cards --list equals random member of array plus the rest of the array --i is randomly generated from range of length equal to that of cards. shuffle :: Int -> [a] -> [a] shuffle i [

Re: [Haskell-cafe] Occurs check error, help!

2010-03-20 Thread Yuras Shumovich
Hi, > shuffle :: int -> [a] -> [a] > shuffle i [cards] = ... So 'cards' is of type 'a' : cards :: a > ... = (cards!!i) So 'cards' is a list of something: cards :: [b] > ... = (cards!!i) + ... (+) :: b -> b -> b, the result of the 'shuffle' should be of type [a], so b :: [a], cards :: [[a

[Haskell-cafe] Haskell hackathon in Philadelphia (Hac phi 2) in May?

2010-03-20 Thread Brent Yorgey
We are gauging interest in another Haskell hackathon to be hosted at U Penn in May, the weekend of either May 15 or May 22. If you might be interested in attending such a thing, send me an email (please DON'T reply to all!) with your name and whether you have a strong preference for one or the oth

[Haskell-cafe] Occurs check error, help!

2010-03-20 Thread boblettoj
Hi i am writing a shuffle function which takes in a random number i and a list and then produces a jumbled up version of the list at the end. Here is what i have at the moment (i'm not sure if it works yet as it won't compile! --function used to shuffle cards --list equals random member of array

Re: [Haskell-cafe] Takusen sqlite3 insert is very slow

2010-03-20 Thread Jason Dagit
On Sat, Mar 20, 2010 at 3:32 AM, Vasyl Pasternak wrote: > Hi Cafe, > > I have another problem, please look at code: > > storeInDb = withSession (connect "test.db") > (do > execDDL (sql "create table x (y int)") > forM_ ([1..1] :: [Int]) >

Re: [Haskell-cafe] RFC: only-read-or-write-vars

2010-03-20 Thread Bas van Dijk
On Fri, Mar 19, 2010 at 5:49 PM, vlado wrote: > +1 - I like it, I've used this technique in some private projects Nice, I hope you can use this package. > I wonder if this would be a place to add a function returning the pair > of the read and write capabilities (for the lack of a better word) o

[Haskell-cafe] Takusen sqlite3 insert is very slow

2010-03-20 Thread Vasyl Pasternak
Hi Cafe, I have another problem, please look at code: storeInDb = withSession (connect "test.db") (do execDDL (sql "create table x (y int)") forM_ ([1..1] :: [Int]) (\x -> do execDML (cmdbind ("insert int

[Haskell-cafe] Call for Praatjes: Dutch HUG Day

2010-03-20 Thread Sean Leather
>From ZuriHac, we bring you... *Call for Praatjes: Dutch HUG Day* To celebrate our first anniversary, the Dutch Haskell Users Group (HUG) invites Haskell and functional programming enthusiasts in the Netherlands and surrounding area to a short symposium. The Dutch HUG is an informal group with mo

Re: [Haskell-cafe] Takusen and iteratee problem

2010-03-20 Thread Vasyl Pasternak
Hi, seems, that I found how to solve it. I replased `mtl` dependency with `transformers` and `monads-fd` and everything works fine. BTW. Iteratee and Takusen didn't want to work because of different instances of MonadIO (Iteratee needs MonadIO from transformers package, but Takusen implements Mona