Re: List comprehensions
* Rijk J. C. van Haaften <[EMAIL PROTECTED]> [2003-01-30 11:41 +0100]: > Recently, I came accross this expression: > [ x + y | x <- xs | y <- ys ] ^ Put a comma ',' here. That's something totally different. Two examples: 1. Comma [ x + y | x <- [1,2], y <- [3,4] ] = [4,5,5,6] 2. Bar [ x + y | x <- [1,2] | y <- [3,4] ] = [ x + y | (x,y) <- zip [1,2] [3,4] ] = zipWith (+) [1,2] [3,4] = [4,6] The first is according to the standard. No problems so far. However, I couldn't find a description of the semantics of the second (and it is clearly non-standard), though I think the semantics given above using zip and zipWith are correct. Rijk ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
List comprehensions
Hello, Recently, I came accross this expression: [ x + y | x <- xs | y <- ys ] As far as I can see (Haskell Report), this is not allowed by the haskell 98 standard. So I assume it to be an ex- tension. Where can I find information about this? Thanks, Rijk ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Binary search tree
>Hi everybody, > >I studied haskell this semester at the university and I was required to >implement a binary search tree in haskell. >I would appreciate if anyone could send me an example code of this data >structure. Just read a standard textbook. Some useful course notes by Jeroen Fokker are available online at http://www.cs.uu.nl/people/jeroen/courses/fp-eng.pdf Enough to solve your problem. Rijk-Jan van Haaften ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: hashmap withdrawal and poor haskell style
At 13:27 03-04-02 +0100, D. Tweed wrote: >On Wed, 3 Apr 2002, Michal Wallace wrote: > > > module Main where > > alphabet = "abcdefghijklmnopqrstuvwxyz" > > count ch str = length [c | c <- str , c == ch] > > hist str = [count letter str | letter <- alphabet] > > oneline ch str = [ch] ++ " " ++ stars (count ch str) > > stars x = if x == 0 > > then "" > > else "*" ++ stars ( x - 1 ) > > report str ch = do putStrLn ( oneline ch str ) > > loop f (h:t) = if t == [] > >then f h > >else do f h > >loop f t > > main = do content <- getContents > > let rpt letter = report content letter > > loop rpt alphabet > > """ > > > > Other than ignoring upper case letters, and being really > > really slow, it seems to work fine in hugs > >I'm a bit confused how this can have worked... in Haskell `let' is used in >the context of a `let ..<1>.. in ..<2>..' where the code ellided in <1> >binds some names to values which are then used in the expression <2> (as >in `let x=sqrt 2 in exp x') and so the contents of main isn't (unless I'm >missing something) syntactically Haskell. It's correct Haskell. Have a look at http://www.haskell.org/onlinereport/exps.html#sect3.14 Rijk-Jan ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Rectification Hugs bug
Dear all, After intensive investication of several people here at Utrecht University, these are the results 1. The very latest Hugs version doesn't have the bug 2. All before-december-2001 versions don't have the bug I were using a version downloaded some weeks ago. After installing the current distribution, the problems disappeared Therefore, I suspect there have been one or more bug-fix updates after December 2001, fixing this problem. However, I couldn't find that documented on the Hugs site. Can anyone confirm such an update? Where can I find last- minute distribution information? Thanks, Rijk-Jan ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Bug in Hugs Dec 2001: type inferencer incorrect!
Hello everybody, Although I didn't manage to reproduce the bug with a minimal example, I think it is still important enough to tell you (and especially the Hugs writers and maintainers). Yesterday evening, I tried to add some correct (!) code (by-hand-verifyable; by GHC accepted; just using plain Haskell 98) to one of the projects I'm working on. Hugs however said this: Type checking ERROR "TypeInferDecls.hs":102 - Type error in application *** Expression : checkedUnify (snd newTyEnv) inferredHpPtr explicitHpPtr (\t1 t2 ue -> ([l],ExplicitError n t1 t2 ue)) *** Term : checkedUnify *** Type : NonGenerics -> HpPtr -> HpPtr -> ErrorFunction -> TI Error () *** Does not match : a -> b -> c -> d -> e *** Because: types do not match I've read this ten times, checked my code looking whether I were doing strange things, but I can only conclude: This is, even without a minimal example, clearly a bug: the types do match. Moreover, the bug is reported about a completely different part of the file (relative to the location I edited), in code almost unrelated to the code I added (about line 300). I have explicit types everywhere in that file, so if it were wrong, the error should be reported about line 300. So the reporting-place is wrong (but I don't expect Hugs to report good error-placement). Though I didn't manage to write a minimal example, I hope our Hugs experts are able to find the bug soon. As a last point: the file is rather big: 726 lines of code, 27KB. Rijk-Jan van Haaften ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Ground Up
Jerry wrote >However, my problems are: >* I still don't understand most of the codes I found, like the various > haskell libraries Practice is the only answer to this problem, as Keith Wansbrough says. >* I still have no clue of most (ok, almost all) of what is being > discussed in this mailing list Though I am a CS student, being highly interested in Haskell and practising a lot, I didn't understand most of the discussions on this mailing list. I started understanding them only after I got involved in implementing a Haskell compiler. Therefore, don't worry about this point. A haskell-user doesn't need to know the details of the haskell compiler ins and outs. Rijk-Jan van Haaften ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Help
You probably want to do something like this: main = do { contents <- input "twoboxes.dat" return (control (parser contents)) } At 11:53 25-02-02 -0300, Juan M. Duran wrote: >Hi, I'm writting a small parser in Haskell and, when it is all done, I get >the following problem: Type Binding. >The thing is, I have 3 main functions: >1) Read the file, its type is: [Char] ->IO [Char] (see InputOutput.hs) >2) Parse a string (using words and readDec), its type is: Integral a => >[Char] -> [a] (see Parse.hs) >3) Parse a list of integer, its type is: [Float] -> [[Float]] >(Functions.hs) > >Now the problem is that I cannot run the first function, then use its >results as an input of the second function and, finally, its results as >the input of the third function. > >How can I fix this without modifing all my functions because they, >independly, works fine. > >Juan ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe