[Haskell-cafe] Fibonacci Heap without using Monad

2010-12-30 Thread larry.liuxinyu
Hi, I checked the current Fibonacci Queue in Hackage DB: http://hackage.haskell.org/packages/archive/pqueue-mtl/1.0.7/doc/html/src/Data-Queue-FibQueue.html#FQueue And a history email for Okasaki in 1995: http://darcs.haskell.org/nofib/gc/fibheaps/orig The hardest part is how to consolidate all

Re: [Haskell-cafe] Fibonacci Heap without using Monad

2010-12-30 Thread larry.liuxinyu
Hi, In CLRS, there are algorithms about DECREASE-KEY and DELETE-NODE. However, in the Functional approach, I didn't find corresponding solution. One approach may just mark the node as `deleted' and when pops the top element from the heap, we repeat it until find a unmarked node. -- LIU

Re: [Haskell-cafe] Lambda Calculus: Bound and Free formal definitions

2010-12-30 Thread Hans Aberg
On 30 Dec 2010, at 03:05, Mark Spezzano wrote: ... regarding formal definitions of FREE and BOUND variables he gives Defn 5.2 as It is the occurrence of a variable that is free or bound. An occurrence of a variable is bound if it is in the scope of something that binds it; otherwise it

Re: [Haskell-cafe] Lambda Calculus: Bound and Free formal definitions

2010-12-30 Thread David Sabel
Hi, the definition in the book is a syntactic one, you are not allowed to beta-reduce when applying the definition. In particular E = E1 E2 = (\x.xy)(\z.z) The definition speaks about the term (\x.xy)(\z.z) and not about (\z.z)y and the definition does not speak about occurences of

Re: [Haskell-cafe] Lambda Calculus: Bound and Free formal definitions

2010-12-30 Thread Lauri Alanko
On Thu, Dec 30, 2010 at 02:20:34PM +1030, Mark Spezzano wrote: 5.3 BOUND: = If E1 = \x.xy then x is bound If E2 = \z.z then is not even mentioned So E = E1 E2 = (\x.xy)(\z.z) = (\z.z)y -- Error: x is not bound but should be by the rule of 5.3 Your final = here is beta equality.

Re: [Haskell-cafe] Data.Typeable TypeRep Ord instance.

2010-12-30 Thread Serguey Zefirov
2010/12/30 Andreas Baldeau andr...@baldeau.net: instance Ord TypeRep where    compare t1 t2 =        compare            (unsafePerformIO (typeRepKey t1))            (unsafePerformIO (typeRepKey t2)) I think it would suffice. Thank you for a tip.

Re: [Haskell-cafe] V.I.P.s and the associativity of merge'

2010-12-30 Thread Heinrich Apfelmus
Leon Smith wrote: Ok, after mulling over the issues that Will Ness has brought up in the last few days [1], I think I have a partial explanation for the apparent tension between Will's observations and Heinrich Apfelmus's Implicit Heaps article [2], which both concern the implementation of

[Haskell-cafe] Deep concatenation [Was: Incorrectly inferring type [t]]

2010-12-30 Thread oleg
William Murphy wrote: I've spent a lot of time trying to write a version of concat, which concatenates lists of any depth: It is a little bit more involved, but quite possible. The code is not much longer than the one you wrote (essentially, three lines: one class and two instance

Re: [Haskell-cafe] Incorrectly inferring type [t]

2010-12-30 Thread Henning Thielemann
On Wed, 29 Dec 2010, william murphy wrote: Hi All, I've spent a lot of time trying to write a version of concat, which concatenates lists of any depth: So: concat'' [[[1,2],[3,4]],[[5]]]   would return: [1,2,3,4,5] You can nicely solve this problem in Haskell 98 using a Tree

Re: [Haskell-cafe] ; in do

2010-12-30 Thread Larry Evans
On 12/29/10 22:40, Daryoush Mehrtash wrote: Why do people put ; in do {}, or , in data fields, at the beginning of the line? -- It reflects the parse tree better by putting the combining operators (e.g. ';' and ',') at the left and their operands (or combined subtrees) indented to the

Re: [Haskell-cafe] ; in do

2010-12-30 Thread Henning Thielemann
On Thu, 30 Dec 2010, Antoine Latter wrote: I started for cleaner diffs and easier editing - I can add/remove a line at the end without editing any other line. Eventually I grew to like the look of it. That's not true. As long as the comma is used as separator one line can affect an adjacent

[Haskell-cafe] Formatting function types

2010-12-30 Thread Lauri Alanko
On Thu, Dec 30, 2010 at 07:04:11AM -0600, Larry Evans wrote: On 12/29/10 22:40, Daryoush Mehrtash wrote: Why do people put ; in do {}, or , in data fields, at the beginning of the line? -- It reflects the parse tree better by putting the combining operators (e.g. ';' and ',') at the

Re: [Haskell-cafe] Formatting function types

2010-12-30 Thread Henning Thielemann
On Thu, 30 Dec 2010, Lauri Alanko wrote: Even nowadays, Haddock deliberately generates the following layout for long function types: openTempFile :: FilePath - String - IO (FilePath, Handle) The layout draws special attention to the first argument type, whereas the other argument

Re: [Haskell-cafe] ; in do

2010-12-30 Thread Antoine Latter
On Thu, Dec 30, 2010 at 8:15 AM, Henning Thielemann lemm...@henning-thielemann.de wrote: On Thu, 30 Dec 2010, Antoine Latter wrote: I started for cleaner diffs and easier editing - I can add/remove a line at the end without editing any other line. Eventually I grew to like the look of it.

Re: [Haskell-cafe] Formatting function types

2010-12-30 Thread Antoine Latter
On Thu, Dec 30, 2010 at 8:33 AM, Lauri Alanko l...@iki.fi wrote: On Thu, Dec 30, 2010 at 07:04:11AM -0600, Larry Evans wrote: On 12/29/10 22:40, Daryoush Mehrtash wrote: Why do people  put  ; in do {}, or , in data fields,  at the beginning of the line? -- It reflects the parse tree

Re: [Haskell-cafe] What's the motivation for η rules?

2010-12-30 Thread Conor McBride
Hi Thus invoked... On 28 Dec 2010, at 23:29, Luke Palmer wrote: Eta conversion corresponds to extensionality; i.e. there is nothing more to a function than what it does to its argument. Suppose f x = g x for all x. Then using eta conversion: f = (\x. f x) = (\x. g x) = g Without eta this

Re: [Haskell-cafe] Formatting function types

2010-12-30 Thread Christopher Done
On 30 December 2010 15:44, Antoine Latter aslat...@gmail.com wrote: On Thu, Dec 30, 2010 at 8:33 AM, Lauri Alanko l...@iki.fi wrote: Even nowadays, Haddock deliberately generates the following layout for long function types: openTempFile :: FilePath - String - IO

[Haskell-cafe] Not in scope: type constructor or class `Map'

2010-12-30 Thread michael rice
Not sure what's going on here. Doesn't like line 5, the type statement. And what's with the semicolons in that line and in function main? Michael = From: http://www.haskell.org/ghc/docs/6.10.3/html/libraries/mtl/Control-Monad-Reader.html import Control.Monad.Reader import qualified

Re: [Haskell-cafe] A question regarding cmdargs package

2010-12-30 Thread Sönke Hahn
That i18n is a fantastic argument - and one that really means cmdargs has no choice but to support all the attributes on help/version. Is it possible to change the groupname for the implicit help and version options? I have defined some options with groupname development flags, but I would

Re: [Haskell-cafe] Not in scope: type constructor or class `Map'

2010-12-30 Thread Eric Stansifer
Because Data.Map is imported qualified, any symbols in it (including Map) needs to be qualified: type Bindings = Map.Map String Int A standard idiom is to do import like so: import qualified Data.Map as Map import Map (Map) so that the Map symbol itself does not need qualification. Eric

Re: [Haskell-cafe] Not in scope: type constructor or class `Map'

2010-12-30 Thread Pedro Vasconcelos
On Thu, 30 Dec 2010 08:01:01 -0800 (PST) michael rice nowg...@yahoo.com wrote: Not sure what's going on here. Doesn't like line 5, the type statement. And what's with the semicolons in that line and in function main? import Control.Monad.Reader import qualified Data.Map as Map import

Re: [Haskell-cafe] Formatting function types

2010-12-30 Thread Larry Evans
On 12/30/10 08:17, Henning Thielemann wrote: On Thu, 30 Dec 2010, Lauri Alanko wrote: Even nowadays, Haddock deliberately generates the following layout for long function types: openTempFile :: FilePath - String - IO (FilePath, Handle) The layout draws special attention to the

Re: [Haskell-cafe] Not in scope: type constructor or class `Map'

2010-12-30 Thread michael rice
Thanks, all. Just tried type Bindings = Map.Map String Int and it also seems to work. Michael  --- On Thu, 12/30/10, Pedro Vasconcelos p...@dcc.fc.up.pt wrote: From: Pedro Vasconcelos p...@dcc.fc.up.pt Subject: Re: [Haskell-cafe] Not in scope: type constructor or class `Map' To:

Re: [Haskell-cafe] ; in do

2010-12-30 Thread Albert Y. C. Lai
On 10-12-29 11:40 PM, Daryoush Mehrtash wrote: Why do people put ; in do {}, or , in data fields, at the beginning of the line? There was a time I did this to help the auto-indenter. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] record types and unique names

2010-12-30 Thread Aaron Gray
Given a Haskell record type :- data Test = Test { name :: String, value :: Int } test = Test { name = test, value = 1 } main :: IO () main = do putStrLn (name test) Are name and value in the global name

Re: [Haskell-cafe] A question regarding cmdargs package

2010-12-30 Thread Neil Mitchell
Hi Sönke, helpArg [groupname Something] should work, but it sounds like it doesn't. I've raised a bug: http://code.google.com/p/ndmitchell/issues/detail?id=392 I'll probably have this fixed in about a week. Thanks, Neil On Thu, Dec 30, 2010 at 4:05 PM, Sönke Hahn sh...@cs.tu-berlin.de wrote:

Re: [Haskell-cafe] record types and unique names

2010-12-30 Thread Markus Läll
Yes, they are in the global scope, and from what I gather: they are just regular functions, created by special syntax. There are a few obvious solutions (some of which you might have thought yourself :-): - rename the accessor or the other function, or - put the data declaration or the other

Re: [Haskell-cafe] record types and unique names

2010-12-30 Thread Aaron Gray
On 30 December 2010 17:23, Markus Läll markus.l...@gmail.com wrote: Yes, they are in the global scope, and from what I gather: they are just regular functions, created by special syntax. There are a few obvious solutions (some of which you might have thought yourself :-): - rename the

Re: [Haskell-cafe] record types and unique names

2010-12-30 Thread aditya siram
I don't think record field disambiguation what you're after. My apologies. -deech On Thu, Dec 30, 2010 at 11:20 AM, aditya siram aditya.si...@gmail.com wrote: Take a look at the record field disambiguation [1] extension to GHC. It sounds like what you're looking for. -deech [1]

Re: [Haskell-cafe] Formatting function types

2010-12-30 Thread Lauri Alanko
On Thu, Dec 30, 2010 at 10:39:29AM -0600, Larry Evans wrote: Lauri, I assume then that you want to draw special attention to the return type instead of the first argument type. Only to the fact that the return type is of a different nature than the argument types, and that all the argument

Re: [Haskell-cafe] record types and unique names

2010-12-30 Thread aditya siram
Take a look at the record field disambiguation [1] extension to GHC. It sounds like what you're looking for. -deech [1] http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/syntax-extns.html#disambiguate-fields On Thu, Dec 30, 2010 at 11:01 AM, Aaron Gray aaronngray.li...@gmail.com wrote:

Re: [Haskell-cafe] A question regarding cmdargs package

2010-12-30 Thread Neil Mitchell
Hi Sönke, I've just released cmdargs-0.6.6 which supports helpArgs [groupname Something] Thanks, Neil On Thu, Dec 30, 2010 at 5:09 PM, Neil Mitchell ndmitch...@gmail.com wrote: Hi Sönke, helpArg [groupname Something] should work, but it sounds like it doesn't. I've raised a bug:

Re: [Haskell-cafe] record types and unique names

2010-12-30 Thread Aaron Gray
On 30 December 2010 17:29, aditya siram aditya.si...@gmail.com wrote: I don't think record field disambiguation what you're after. My apologies. -deech Interesting never the less. Thanks, Aaron On Thu, Dec 30, 2010 at 11:20 AM, aditya siram aditya.si...@gmail.com wrote: Take a look

Re: [Haskell-cafe] Formatting function types

2010-12-30 Thread Ketil Malde
Antoine Latter aslat...@gmail.com writes: openTempFile :: FilePath - String - IO (FilePath, Handle) My main discomfort with this is not the result type, but that the first argument appears different from the rest. I much prefer having the :: be attached to the identifier. FWIW. -k

Re: [Haskell-cafe] Formatting function types

2010-12-30 Thread Henning Thielemann
On Thu, 30 Dec 2010, Lauri Alanko wrote: Except that it falsely suggests that the last argument types are of a similar nature as the return type. Here's what went in my head when I first read Haskell code: openTempFile :: FilePath -- All right, this first part is probably the argument.

Re: [Haskell-cafe] Fibonacci Heap without using Monad

2010-12-30 Thread larry.liuxinyu
Hi, Sorry for there is a bug in my previous post. The example consolidate function for number should be like this: consolidate xs = foldl meld [] xs where meld [] x = [x] meld (x':xs) x | x == x' = meld xs (x+x') | x x' = x:x':xs | otherwise = x':

Re: [Haskell-cafe] V.I.P.s and the associativity of merge'

2010-12-30 Thread Will Ness
Heinrich Apfelmus apfelmus at quantentunnel.de writes: Leon Smith wrote: [1] http://permalink.gmane.org/gmane.comp.lang.haskell.cafe/84666 [2] http://apfelmus.nfshost.com/articles/implicit-heaps.html [3] http://hackage.haskell.org/packages/archive/data-ordlist/0.4.4/doc/html/Data-

Re: [Haskell-cafe] Formatting function types

2010-12-30 Thread Chung-chieh Shan
Lauri Alanko l...@iki.fi wrote in article 20101230133355.gb...@melkinpaasi.cs.helsinki.fi in gmane.comp.lang.haskell.cafe: The following is much clearer: openTempFile :: FilePath - String - IO (FilePath, Handle) (Possibly with the arrows aligned.) I can't understand