Re: ext-core Questions

2002-12-30 Thread Kirsten Chevalier
On Fri, Dec 20, 2002 at 12:01:01PM -0500, [EMAIL PROTECTED] 
wrote:
 
 Secondly, in GHC produced Core programs, one sees frequently references to
 intermediate values from other Modules such as SystemziIO.lvl (print
 newline?) or GHCziNum.lvl1 (which seems to be an Integer constant) or even
 GHCziNum.a4 (which seems to be () :: Integer - Integer - Bool). The type
 of those names as well as any other names from imported Modules is not
 given, however. How then is it possible to type check a Core program?


To typecheck a Core program, you need the type environment obtained from
typechecking all the modules it imports -- i.e., at least the Prelude modules.
The Core typechecker in the utils/ext-core directory in the GHC distribution
gives an example.

-- 
Kirsten Chevalier * [EMAIL PROTECTED] * Often in error, never in doubt
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Re: ANNOUNCE: Haskell Wiki resurrected

2002-12-30 Thread John Meacham
What do people feel about switching to a better Wiki implementation? I
know we all have been secretly hoping a Wiki implemented in haskell
would surface, but this is certainly an area which is already
overcrowded and I think the community would be better served by a fully
functional Wiki now. I highly recommend UseMod, 
http://www.usemod.com/cgi-bin/wiki.pl?UseModWiki
It is very easy to set up and provides useful features like online
browsing of Diffs and being much more robust than pywiki.

On another note related to providing services to the haskell comunity,
how about a public bugzilla server on bugs.haskell.org?
(http://bugzilla.org) any haskell project which wishes to use the public
bug server could be set up with an entry, it would be nice to have a
central place to report bugs in the various haskell systems as well.
This is not meant to replace whatever established project have, but
rather provide a service to anyone with a haskell project who wishes bug
reporting capability.

Just some thoughts...
John


On Thu, Dec 05, 2002 at 10:36:15AM +, Keith Wansbrough wrote:
 Hi all... last night I resurrected the Haskell Wiki,
 
 http://haskell.org/wiki/wiki
 
 This is a set of web pages on Haskell which can be edited and updated 
 by anyone.  The intention is to accumulate the combined wisdom of 
 posters to the Haskell lists - if you ever reply to a FAQ with what you 
 think is a particularly good answer, please add it to the Wiki.  If you 
 see a FAQ that's been Frequently Asked, just point the poster at the 
 appropriate page on the Wiki.
 
 Sadly, the Wiki isn't very stable at the moment.  I'm hoping that one 
 day it will be made more stable, but in the meantime, I've taken a 
 snapshot of the state as it was last night, and placed a link to it on 
 the haskell.org front page:
 
 http://haskell.org/wikisnapshot/FrontPage.html
 
 Note that no updates to the Wiki are ever lost; they're kept in a 
 version control system.  So if you see a blank page on the main Wiki 
 where you once spent several hours writing the perfect page, don't 
 worry - it's not lost!
 
 Hope this is useful to people!
 
 --KW 8-)
 
 PS: I'm not officially in charge of the Wiki, John Heron 
 [EMAIL PROTECTED] is; I'm just helping him out at the moment.
 
 ___
 Haskell mailing list
 [EMAIL PROTECTED]
 http://www.haskell.org/mailman/listinfo/haskell
 

-- 
---
John Meacham - California Institute of Technology, Alum. - [EMAIL PROTECTED]
---
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: ANNOUNCE: Haskell Wiki resurrected

2002-12-30 Thread David Sankel
--- John Meacham [EMAIL PROTECTED] wrote:
 On another note related to providing services to the
 haskell comunity,
 how about a public bugzilla server on
 bugs.haskell.org?
 (http://bugzilla.org) any haskell project which
 wishes to use the public
 bug server could be set up with an entry, it would
 be nice to have a
 central place to report bugs in the various haskell
 systems as well.
 This is not meant to replace whatever established
 project have, but
 rather provide a service to anyone with a haskell
 project who wishes bug
 reporting capability.

I concur on this idea.  This would be very useful.

David J. Sankel
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Question About lists

2002-12-30 Thread Cesar Augusto Acosta Minoli

Hello! I'm Working with Lists in Haskell, I´m a Beginner in Functional Programming and I would like to know if there isa way to write a more efficient function that return the length of a list, I wrote this one:
long :: [a]-Intlong p = longitud p 0 where longitud [] s=s longitud (x:xs) s=longitud xs (s+1)
but I think that it have a lineal grow O(n).
thanks!



Add photos to your e-mail with MSN 8.  Get 3 months FREE*. 
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: Question About lists

2002-12-30 Thread gilesb
Hi Cesar

If you check the prelude, you will find the definition (something like):

length::[a]-Int
length= foldl' (\n _ - n + 1) 0

and the definition of foldl'

foldl'   :: (a - b - a) - a - [b] - a
foldl' f a [] = a
foldl' f a (x:xs) = (foldl' f $! f a x) xs

Which also gives a linear complexity (O(n)) to length.

Unless your representation of lists stores the length, you will pretty
much always need linear time to find out the length as you have to count
how many items there are.  

Alternatively, if getting the length is something you need to do a lot,
consider creating your own datatype and corresponding class for inserts
etc. that keeps the length on hand. This could allow O(1) length
queries.

On 30 Dec, Cesar Augusto Acosta Minoli wrote:
 htmldiv style='background-color:'DIV
 PHello! I'm Working with Lists in Haskell, I´m a Beginner in Functional 
Programming and I would like to know if there isnbsp;a way to write a more efficient 
function that return the length of a list, I wrote this one:/P
 Plongnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; ::nbsp; [a]-gt;IntBRlong 
pnbsp;nbsp;nbsp;nbsp; =nbsp; longitud p 
0BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;
 
whereBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;
 longitud []nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; 
s=sBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;
 longitud (x:xs) s=longitud xs (s+1)/P
 Pbut I think that it have a lineal grow O(n)./P
 Pthanks!/P
 Pnbsp;/P
 Pnbsp;/P
 Pnbsp;/P
 Pnbsp;BRBR/P/DIV/divbr clear=allhrAdd photos to your e-mail with 
MSN 8.  a href=http://g.msn.com/8HMEEN/2021;Get 3 months FREE*./a /html
 ___
 Haskell mailing list
 [EMAIL PROTECTED]
 http://www.haskell.org/mailman/listinfo/haskell

-- 
Brett G. Giles
Grad Student, University of Calgary
Formal Methods, Category Theory, Semantics of Programming
http://www.cpsc.ucalgary.ca/~gilesb mailto:[EMAIL PROTECTED]

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: Question About lists

2002-12-30 Thread Mark Carroll
On Mon, 30 Dec 2002, Cesar Augusto Acosta Minoli wrote:

 Hello! I'm Working with Lists in Haskell, I´m a Beginner in Functional
 Programming and I would like to know if there is a way to write a more
 efficient function that return the length of a list, I wrote this one:

 long    ::  [a]-Int
 long p =  longitud p 0
    where
    longitud []   s=s
    longitud (x:xs) s=longitud xs (s+1)

 but I think that it have a lineal grow O(n).

Yes, it's O(n), but you can't do any better for calculating the length of
a list. Your second parameter seems to be an accumulator which is the sort
of thing you'd make explicit in an imperative approach but can often be
eliminated in functional code - e.g.,

long [] = 0
long (x:xs) = 1 + long xs

A decent optimizing compiler will probably turn that code into something
that uses an accumulator. This code probably isn't any more efficient than
yours, it's just shorter.

-- Mark

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: Question About lists

2002-12-30 Thread Artie Gold
Cesar Augusto Acosta Minoli wrote:


Hello! I'm Working with Lists in Haskell, I´m a Beginner in Functional 
Programming and I would like to know if there is a way to write a more 
efficient function that return the length of a list, I wrote this one:

long::  [a]-Int
long p =  longitud p 0
   where
   longitud []   s=s
   longitud (x:xs) s=longitud xs (s+1)

but I think that it have a lineal grow O(n).



Sure. The only way to count the elements in a list is to, well, count 
the elements; it's an inherently linear operation.

One suggestion, though is that you're working too hard; there's really 
no reason to define a locally defined function. The much simpler:

long [] = 0
long (x:xs) = 1 + long xs

will do quite nicely.

HTH,
--ag



thanks!

 

 

 

 



Add photos to your e-mail with MSN 8. Get 3 months FREE*. 
http://g.msn.com/8HMEEN/2021 
___ Haskell mailing list 
[EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell



--
Artie Gold -- Austin, Texas

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: Question About lists

2002-12-30 Thread William Lee Irwin III
On Mon, Dec 30, 2002 at 01:47:37PM -0600, Artie Gold wrote:
 One suggestion, though is that you're working too hard; there's really 
 no reason to define a locally defined function. The much simpler:
 long [] = 0
 long (x:xs) = 1 + long xs
 will do quite nicely.
 HTH,
 --ag

There is already a length function in List and/or the Prelude.


Bill
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



RE: Question About lists

2002-12-30 Thread Jong Keun Na
 long = sum . map (const 1)
How's this?

/JongKeun

-Original Message-
From: William Lee Irwin III [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, December 31, 2002 5:18 AM
To: Artie Gold
Cc: Cesar Augusto Acosta Minoli; [EMAIL PROTECTED]
Subject: Re: Question About lists

On Mon, Dec 30, 2002 at 01:47:37PM -0600, Artie Gold wrote:
 One suggestion, though is that you're working too hard; there's really

 no reason to define a locally defined function. The much simpler:
 long [] = 0
 long (x:xs) = 1 + long xs
 will do quite nicely.
 HTH,
 --ag

There is already a length function in List and/or the Prelude.


Bill
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell