Re: [Haskell-cafe] Re: [Haskell] Swapping parameters and type classes

2007-09-19 Thread Jim Apple
On 9/18/07, Simon Marlow [EMAIL PROTECTED] wrote:
 Ian Lynagh wrote:
  I proposed renaming
  haskell@ - haskell-announce@
  haskell-cafe@ - haskell@
[snip]
 but now I have to admit I think haskell-cafe is a big win
 for the community.

To me this suggests renaming haskell@ to haskell-announce@ while
leaving haskell-cafe@ as is.

Jim
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Missing Symbol (2)

2007-09-19 Thread PR Stanley

Hi
Here's another one:
f [] = v
f (x:xs) = x . f xs
The . is supposed to denote a generic operator - f [] maps to some 
value v and applied to non-empty list applies head to ? operator.

Thanks, Paul

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Missing Symbol (2)

2007-09-19 Thread Joel Koerwer
Paul,

The Hutton book has gotten great reviews, but pouring over a faulty
OCRd version can only be counterproductive. I highly recommend Yet
Another Haskell Tutorial[1]. After that you can check out all the
other wonderful online resources (starting here [2]). At that point a
few OCR errors won't be able to stand in your way!

Best wishes on you Haskell explorations,
Joel

[1] http://www.cs.utah.edu/~hal/docs/daume02yaht.pdf
[2] http://haskell.org/haskellwiki/Learning_Haskell
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Missing Symbol (2)

2007-09-19 Thread PR Stanley
The book is very well written. I did try to follow the wikibook 
thingummajig but found the English a bit trying.

Cheers
Paul
t 07:43 19/09/2007, you wrote:

Paul,

The Hutton book has gotten great reviews, but pouring over a faulty
OCRd version can only be counterproductive. I highly recommend Yet
Another Haskell Tutorial[1]. After that you can check out all the
other wonderful online resources (starting here [2]). At that point a
few OCR errors won't be able to stand in your way!

Best wishes on you Haskell explorations,
Joel

[1] http://www.cs.utah.edu/~hal/docs/daume02yaht.pdf
[2] http://haskell.org/haskellwiki/Learning_Haskell
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: [Haskell] Functor ((,) a)

2007-09-19 Thread Matthew Brecknell
Janis Voigtlaender:
 What do I have to import to get the Functor ((,) a) instance?

(redirected to haskell-cafe)

Control.Monad.Instances, believe it or not.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] help me ! who has vty ?

2007-09-19 Thread clisper
who has vty for haskell?
I can't find the right one so who can mail one to me ?
thanks 

2007-09-19 



clisper 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Library Process (was Building production stable software in Haskell)

2007-09-19 Thread Simon Marlow

Sven Panne wrote:

On Tuesday 18 September 2007 09:44, Dominic Steinitz wrote:

This discussion has sparked a question in my mind:

What is the process for the inclusion of modules / packages in ghc, hugs
and other compilers  interpreters?


Personal interest of the people working on GHC et. al. ;-)


I thought the master plan was that less would come with the compiler /
interpreter and the user would install packages using cabal. [...]


Although this statement might be a bit heretical on this list, I'll have to 
repeat myself again that Cabal, cabal-install, cabal-whatever will *never* be 
the right tool for the end user to install Haskell packages on platforms with 
their own packaging systems like RPM (the same holds for other systems, I 
just use RPM as an example here).


I think you're identifying a non-problem here.  Cabal was never intended to 
be used instead of the system's packaging tools for installing packages 
globally on the system, if you look back through the original Cabal design 
discussions you'll see this.  We recognised the critical importance of 
working with, rather than around, emerge/ports/RPM/apt/whatever.


Nowadays from a Cabal package you get make an RPM, a Windows installer, and 
 the Gentoo folks have imported the entirety of Hackage.  This is how it's 
meant to work.


Cheers,
Simon
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Library Process (was Building production stable software in Haskell)

2007-09-19 Thread Johan Tibell
Building Debian packages seems a bit hard to do for laymen like me.
Anyone have a script that takes a .cabal file, some additional meta
data and creates a .deb package? It would be really nice if we could
make this procedure easier. Every time I read some documentation on
how to create a Debian package, I feel like crying. ;)

Cheers,

Johan

On 9/19/07, Simon Marlow [EMAIL PROTECTED] wrote:
 Sven Panne wrote:
  On Tuesday 18 September 2007 09:44, Dominic Steinitz wrote:
  This discussion has sparked a question in my mind:
 
  What is the process for the inclusion of modules / packages in ghc, hugs
  and other compilers  interpreters?
 
  Personal interest of the people working on GHC et. al. ;-)
 
  I thought the master plan was that less would come with the compiler /
  interpreter and the user would install packages using cabal. [...]
 
  Although this statement might be a bit heretical on this list, I'll have to
  repeat myself again that Cabal, cabal-install, cabal-whatever will *never* 
  be
  the right tool for the end user to install Haskell packages on platforms 
  with
  their own packaging systems like RPM (the same holds for other systems, I
  just use RPM as an example here).

 I think you're identifying a non-problem here.  Cabal was never intended to
 be used instead of the system's packaging tools for installing packages
 globally on the system, if you look back through the original Cabal design
 discussions you'll see this.  We recognised the critical importance of
 working with, rather than around, emerge/ports/RPM/apt/whatever.

 Nowadays from a Cabal package you get make an RPM, a Windows installer, and
   the Gentoo folks have imported the entirety of Hackage.  This is how it's
 meant to work.

 Cheers,
 Simon
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] help me ! who has vty ?

2007-09-19 Thread Neil Mitchell
Hi

 who has vty for haskell?
 I can't find the right one so who can mail one to me ?

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vty-3.0.0

hackage has a lot of packages, and is always a good place to start a search.

Thanks

Neil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: [Haskell] Functor ((,) a)

2007-09-19 Thread Bas van Dijk
On 9/19/07, Janis Voigtlaender [EMAIL PROTECTED] wrote:
 BTW, what would have been the easiest way for me to find this out on my
 own?

The following is probably not the easiest way:

I keep a copy of the sources of GHC and the libraries [1] on my disk.
When I want to search for something I simply do a grep. In emacs you
also have a grep-find function which performs a grep in the background
and shows the result in a new buffer. The results are hyperlinked so
you can just click on a result and emacs will open the respected file
and jump to the found string.

In your case you do a 'M-x grep-find' followed by the search string:
instance Functor ((,).
This will result in:

./Control/Monad/Instances.hs:19:instance Functor ((-) r) where
./_darcs/pristine/Control/Monad/Instances.hs:19:instance Functor ((-) r) where

I think you can get rid of the annoying _darcs... by following: [3]. I
haven't tried that though.

(Note I'm on Linux. I don't know if this works in Windows. It probably
does with Cygwin.)

Of course the disadvantage of this approach is that you have to know
exactly what you are looking for.

Then there's also Hoogle [3] with which you can search for names or
types. However in your case this wouldn't have helped.

regards,

Bas


[1] http://hackage.haskell.org/trac/ghc/wiki/Building/GettingTheSources
[2] 
http://wiki.darcs.net/DarcsWiki/HintsAndTips#head-c189bd259a3d141796ebb4f8d58b8a7664c52ece
[3] http://haskell.org/hoogle
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread Peter Verswyvelen
I'm experimenting with functional reactive programming for creating 
simple 2D/3D video games and interactive apps, trying to develop my own 
version of it from scratch, for learning Haskell.


I got stuck with an endless loop when trying to split a stream into a 
pair of two streams (a kind of reactive if/then/else). Luckily I first 
read the Haskell School of Expression so I remembered that pattern 
matching is not lazy and this could be the cause, which it was (I had to 
replace (x:xs) by ~(x:xs))


I could also fix the problem by not using pattern matching at all, using 
head/tail calls instead.


Now why isn't pattern matching lazy by default?  This seems odd for a 
newbie since everything else is lazy by default.


Thanks,
Peter

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread Felipe Almeida Lessa
On 9/19/07, Peter Verswyvelen [EMAIL PROTECTED] wrote:
  Now why isn't pattern matching lazy by default?  This seems odd for a
 newbie since everything else is lazy by default.

AFAIK, pattern matches are desugared to cases, so

f (x:xs) = rhs
f [] = rhs'

is equivalent to

f y = case y of
(x:xs) - rhs
[] - rhs'

Case's have to be strict because that's how we look inside the values
in Haskell =). Of course I may be somehow mistaken here, as I am
learning Haskell, too.

-- 
Felipe.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread Neil Mitchell
Hi

   Now why isn't pattern matching lazy by default?  This seems odd for a
  newbie since everything else is lazy by default.

f ~(x:xs) = rhs
f ~[] = rhs'

Now guess what f [] does...

If you use a where binding then pattern matching is lazy.

Thanks

Neil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] transparent parallelization

2007-09-19 Thread Tim Harris (RESEARCH)
 The problem with Haskell is not finding opportunities to parallelize,
 they are legion. Actually, quite the opposite, there's so much that your
 code ends up slower than a sequential realization.  The hard part is
 making a good cost-model and a good way to create coarser chunks of
 work.  It's not worthwhile to spawn a thread (even a very lightweight
 one) for virtually every subexpression.

 Automatic parallelization is easy, efficient parallelization is hard.

Absolutely.

We had another crack at this recently in an upcoming ICFP paper (draft online 
at http://research.microsoft.com/~tharris/papers/2007-fdip.pdf).

In that paper we start out by collecting profiles of the thunk creation, entry, 
and update operations for a set of benchmarks and conduct a limit study of how 
fast these dependencies would allow them to be evaluated (e.g. ignoring 
interactions through the GC, cache effects, the costs of sparking thunks etc.).

We then make the system increasingly more practical, (i) setting a lower bound 
on the compute-time of thunks that we spark, (ii) making predictions of a 
thunk's compute-time when it's allocated, and then (iii) building a real 
implementation based on GHC 6.6.

The parallel speedup dwindles at each stage: this kind of automated approach 
looks plausible for using 2n cores instead of using n, but I'm sceptical 
about it being able to efficiently exploit n cores instead of 1.

Tim

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread Peter Verswyvelen

Mmm, yes of course... blush...

But shouldn't

f ~(x:xs) = rhs

give a compile-time error since neither x nor xs is used in the right 
hand side, and hence nothing will ever get pattern matched when this 
function is called, which clearly indicates a mistake? That is, if I 
understand lazy pattern matching correctly... And then in these cases 
the user would have to annotate the pattern match as being strict, so he 
is aware of the eager evaluation taking place


Oh well, the way it is now is also easy to get used to, one just has to 
know how it works (just like M-theory ;-) )


Cheers,
Peter


Neil Mitchell wrote:

Hi

  

 Now why isn't pattern matching lazy by default?  This seems odd for a
newbie since everything else is lazy by default.
  


f ~(x:xs) = rhs
f ~[] = rhs'

Now guess what f [] does...

If you use a where binding then pattern matching is lazy.

Thanks

Neil


  


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread C.M.Brown
Hi Peter,

 Mmm, yes of course... blush...

 But shouldn't

 f ~(x:xs) = rhs

 give a compile-time error since neither x nor xs is used in the right
 hand side, and hence nothing will ever get pattern matched when this
 function is called, which clearly indicates a mistake? That is, if I
 understand lazy pattern matching correctly... And then in these cases
 the user would have to annotate the pattern match as being strict, so he
 is aware of the eager evaluation taking place

Well if you defined f:

f ~(x:xs) = 1 + 2
f ~[] = 42

Then you will get a warning stating that the pattern matches of (x:xs)
and [] are overlapped. It may not be a mistake though, so possibly a bold
error for the compiler to throw, it just means that 1+2  will always be
evaulated no matter what list you throw at it (provided of course that
the result of f is needed to evaluate the rest of the program).

It's interesting to note that if you had:

f ~(x:xs) = x + 2
f ~[] = 42

Then f [] would give a complie error:
 Irrefutable pattern failed for pattern (x : xs)

Hope that gives some insight.
Chris.



 Oh well, the way it is now is also easy to get used to, one just has to
 know how it works (just like M-theory ;-) )

 Cheers,
 Peter


 Neil Mitchell wrote:
  Hi
 
 
   Now why isn't pattern matching lazy by default?  This seems odd for a
  newbie since everything else is lazy by default.
 
 
  f ~(x:xs) = rhs
  f ~[] = rhs'
 
  Now guess what f [] does...
 
  If you use a where binding then pattern matching is lazy.
 
  Thanks
 
  Neil
 
 
 


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Missing Symbol (2)

2007-09-19 Thread PR Stanley

Joel
YAHT is full of symbols which cannot be rendered by the Adobe text extractor.
I appreciate your kind advice but you must also bear in mind that I 
am using the Hutton book for a reason. Did you not think it'd 
occurred to me also that there were other tutorials out there?

Sincerely, Paul

At 08:28 19/09/2007, you wrote:
The book is very well written. I did try to follow the wikibook 
thingummajig but found the English a bit trying.

Cheers
Paul
t 07:43 19/09/2007, you wrote:

Paul,

The Hutton book has gotten great reviews, but pouring over a faulty
OCRd version can only be counterproductive. I highly recommend Yet
Another Haskell Tutorial[1]. After that you can check out all the
other wonderful online resources (starting here [2]). At that point a
few OCR errors won't be able to stand in your way!

Best wishes on you Haskell explorations,
Joel

[1] http://www.cs.utah.edu/~hal/docs/daume02yaht.pdf
[2] http://haskell.org/haskellwiki/Learning_Haskell
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Missing Symbol (2)

2007-09-19 Thread Rodrigo Queiro
This looks like foldr, specifically:
f = foldr (.) v

so really, there's no way of telling what the operator could be, other
than that:
(.) :: a - b - b
where
f :: [a] - b
v :: b

BTW, I find that most of your emails are in a very large font size. Do
other people notice this? It's not very nice to read. Gmail's 'Show
Original' feature tells me that the HTML version of your message
contains font size=3 near the start.

On 19/09/2007, PR Stanley [EMAIL PROTECTED] wrote:
 Hi
 Here's another one:
 f [] = v
 f (x:xs) = x . f xs
 The . is supposed to denote a generic operator - f [] maps to some
 value v and applied to non-empty list applies head to ? operator.
 Thanks, Paul

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread C.M.Brown

 f ~(x:xs) = x + 2
 f ~[] = 42

 Then f [] would give a complie error:
  Irrefutable pattern failed for pattern (x : xs)

Sorry, that should be *runtime* error!

Chris.




 Hope that gives some insight.
 Chris.


 
  Oh well, the way it is now is also easy to get used to, one just has to
  know how it works (just like M-theory ;-) )
 
  Cheers,
  Peter
 
 
  Neil Mitchell wrote:
   Hi
  
  
Now why isn't pattern matching lazy by default?  This seems odd for a
   newbie since everything else is lazy by default.
  
  
   f ~(x:xs) = rhs
   f ~[] = rhs'
  
   Now guess what f [] does...
  
   If you use a where binding then pattern matching is lazy.
  
   Thanks
  
   Neil
  
  
  
 
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Library Process (was Building production stable software in Haskell)

2007-09-19 Thread Ian Lynagh
On Wed, Sep 19, 2007 at 11:05:05AM +0200, Johan Tibell wrote:
 Building Debian packages seems a bit hard to do for laymen like me.
 Anyone have a script that takes a .cabal file, some additional meta
 data and creates a .deb package? It would be really nice if we could
 make this procedure easier. Every time I read some documentation on
 how to create a Debian package, I feel like crying. ;)

http://urchin.earth.li/pipermail/debian-haskell/2007-June/000322.html


Thanks
Ian

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] (win)hipe for Haskell?

2007-09-19 Thread Peter Verswyvelen
During a googling session, I can across (Win)HIPE, a visualization 
program for the functional language HOPE. See 
http://dalila.sip.ucm.es/~cpareja/winhipe


IMHO a similar tool would be a nice for learning/teaching Haskell; does 
that exist, or something else that comes close?


Thanks,
Peter



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] (win)hipe for Haskell?

2007-09-19 Thread Neil Mitchell
Hi Peter,

  During a googling session, I can across (Win)HIPE, a visualization program
 for the functional language HOPE. See
 http://dalila.sip.ucm.es/~cpareja/winhipe

  IMHO a similar tool would be a nice for learning/teaching Haskell; does
 that exist, or something else that comes close?

Yes, Hat does this http://www.haskell.org/hat/ (if you can get it to
work, I typically have little success)

Thanks

Neil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] (win)hipe for Haskell?

2007-09-19 Thread Peter Verswyvelen



Yes, Hat does this http://www.haskell.org/hat/ (if you can get it to
work, I typically have little success)
  


Thanks. WinHIPE uses graphics and animation. If briefly encountered Hat 
before, but I had the impression it did not visualize the graphs using 
graphics, only text. Is this correct?




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] (win)hipe for Haskell?

2007-09-19 Thread Neil Mitchell
Hi

  Yes, Hat does this http://www.haskell.org/hat/ (if you can get it to
  work, I typically have little success)
 

 Thanks. WinHIPE uses graphics and animation. If briefly encountered Hat
 before, but I had the impression it did not visualize the graphs using
 graphics, only text. Is this correct?

Yes, mainly. There is a graphical user interface for Hat, but its not
very well developed. http://www-users.cs.york.ac.uk/~ndm/hat/

Thanks

Neil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread C.M.Brown
 It seems GHC does give a warning at compile-time about it, so you did
 get it right the first time :-)

Well the warning happens at compile time certainly. But the irrefutable
pattern error only occurs at runtime.


cmb21$ ghc --make Main.hs
[1 of 1] Compiling Main ( Main.hs, Main.o )

Main.hs:3:0:
Warning: Pattern match(es) are overlapped
 In the definition of `f': f ~[] = ...
Linking Main ...



cmb21$ ./a.out
a.out: Main.hs:(3,0)-(4,10): Irrefutable pattern failed for pattern (x :
xs)

Cheers,
Chris.


 Thanks for the info,
 Peter



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Missing Symbol (2)

2007-09-19 Thread PR Stanley

It's probably \oplus  then.
The font size according to my trusty screen reader is 11 point which 
is not particularly large. Still, if anybody else finds it annoying 
I'll reduce it to 9pt.

Paul
At 13:21 19/09/2007, you wrote:

This looks like foldr, specifically:
f = foldr (.) v

so really, there's no way of telling what the operator could be, other
than that:
(.) :: a - b - b
where
f :: [a] - b
v :: b

BTW, I find that most of your emails are in a very large font size. Do
other people notice this? It's not very nice to read. Gmail's 'Show
Original' feature tells me that the HTML version of your message
contains font size=3 near the start.

On 19/09/2007, PR Stanley [EMAIL PROTECTED] wrote:
 Hi
 Here's another one:
 f [] = v
 f (x:xs) = x . f xs
 The . is supposed to denote a generic operator - f [] maps to some
 value v and applied to non-empty list applies head to ? operator.
 Thanks, Paul

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: [Haskell] downtime for monk ({darcs, hackage, cvs}.haskell.org) Monday from 3pm UTC

2007-09-19 Thread Ian Lynagh
On Wed, Sep 19, 2007 at 09:16:56AM +0100, Bayley, Alistair wrote:
  From: [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On Behalf Of Ian Lynagh
  
  The machine called monk ...
  will be down from 3pm UTC on Monday 24th for an OS and RAM upgrade.
 
 Do you have any estimate for how long the upgrades will take?

That depends on how many things go wrong. I'll send an e-mail when we
believe it's all up and working again.


Thanks
Ian

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Missing Symbol (2)

2007-09-19 Thread Thomas Hartman
as provided, this won't compile because v hasn't been defined.

f [] = 0
f (x:xs) = x . f xs

compiles but gives 

f :: (Num (a - c)) = [c - c] - a - c

which seems wrong. maybe I'm not understanding what v is not supposed to 
be.

I am thinking maybe you want iterate

*Main take 5 $ iterate (+1) 0
[0,1,2,3,4]

It would be easier to understand your desired function if you would 
provide an example of desired usage.

t.




PR Stanley [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
09/19/2007 02:17 AM

To
haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] Missing Symbol (2)






Hi
Here's another one:
f [] = v
f (x:xs) = x . f xs
The . is supposed to denote a generic operator - f [] maps to some 
value v and applied to non-empty list applies head to ? operator.
Thanks, Paul

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: [Haskell] Functor ((,) a)

2007-09-19 Thread Ross Paterson
On Wed, Sep 19, 2007 at 10:24:50AM +0200, Janis Voigtlaender wrote:
 BTW, what would have been the easiest way for me to find this out on my 
 own? Somehow, I would have hoped to be able to navigate to the appropriate 
 point from the mentioned place in the online docs, where it is stated that 
 the instance in question exists.

Usually the instance for C (T a1 ... an) should be in either the module
defining C or the one defining T (so if you import both you have it);
if T is from the Prelude, then the instance should be together with C.

But Control.Monad.Instances is a special case, because exists to hold
instances of Haskell 98 classes for H98 types that are not defined in H98.
Putting them in the proper place would break compatibility with H98.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Missing Symbol (2)

2007-09-19 Thread Joel Koerwer
Hi Paul,

Sorry that my suggestion wasn't so practicable.

On the other hand, I see that the YAHT tex source is available on
darcs.haskell.org/yaht. Maybe we can do something about those
unextractable symbols.  Anyone know more about this? It really is a
great resource for beginners.

-- Joel

On 9/19/07, PR Stanley [EMAIL PROTECTED] wrote:

  Joel
  YAHT is full of symbols which cannot be rendered by the Adobe text
 extractor.
  I appreciate your kind advice but you must also bear in mind that I am
 using the Hutton book for a reason. Did you not think it'd occurred to me
 also that there were other tutorials out there?
  Sincerely, Paul
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Missing Symbol (2)

2007-09-19 Thread Joel Koerwer
Hi Paul,

Sorry that my suggestion wasn't so practicable.

On the other hand, I see that the YAHT tex source is available on
darcs.haskell.org/yaht. Maybe we can do something about those
unextractable symbols.  Anyone know more about this? It really is a
great resource for beginners.

-- Joel

On 9/19/07, PR Stanley [EMAIL PROTECTED] wrote:

  Joel
  YAHT is full of symbols which cannot be rendered by the Adobe text
 extractor.
  I appreciate your kind advice but you must also bear in mind that I am
 using the Hutton book for a reason. Did you not think it'd occurred to me
 also that there were other tutorials out there?
  Sincerely, Paul
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread Peter Verswyvelen

C.M.Brown wrote:

f ~(x:xs) = x + 2
f ~[] = 42

Then f [] would give a complie error:
 Irrefutable pattern failed for pattern (x : xs)



Sorry, that should be *runtime* error!

Chris.
  
It seems GHC does give a warning at compile-time about it, so you did 
get it right the first time :-)


Thanks for the info,
Peter


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread Henning Thielemann


On Wed, 19 Sep 2007, Peter Verswyvelen wrote:

I got stuck with an endless loop when trying to split a stream into a pair of 
two streams (a kind of reactive if/then/else). Luckily I first read the 
Haskell School of Expression so I remembered that pattern matching is not 
lazy and this could be the cause, which it was (I had to replace (x:xs) by 
~(x:xs))


...
Now why isn't pattern matching lazy by default?  This seems odd for a newbie 
since everything else is lazy by default.


It's even more confusing that pattern matching in 'let' _is_ lazy.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Missing Symbol (2)

2007-09-19 Thread Miguel Mitrofanov

YAHT is available from wikibooks in HTML form.

19.09.2007, в 18:30, Joel Koerwer писал(а):


Hi Paul,

Sorry that my suggestion wasn't so practicable.

On the other hand, I see that the YAHT tex source is available on
darcs.haskell.org/yaht. Maybe we can do something about those
unextractable symbols.  Anyone know more about this? It really is a
great resource for beginners.

-- Joel

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread Miguel Mitrofanov
Now why isn't pattern matching lazy by default?  This seems odd  
for a newbie since everything else is lazy by default.


It's even more confusing that pattern matching in 'let' _is_ lazy.


No, it's not.

See, in let or where constructs you don't have a choice; you can't do  
different things depending on whether some value is Just x or  
Nothing. Therefore, there is no need to perform pattern matching  
strictly.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread Chaddaï Fouché
2007/9/19, Miguel Mitrofanov [EMAIL PROTECTED]:
  Now why isn't pattern matching lazy by default?  This seems odd
  for a newbie since everything else is lazy by default.
 
  It's even more confusing that pattern matching in 'let' _is_ lazy.

 No, it's not.

 See, in let or where constructs you don't have a choice; you can't do
 different things depending on whether some value is Just x or
 Nothing. Therefore, there is no need to perform pattern matching
 strictly.

In other words, the pattern matching in case can't be lazy by default
since the primary purpose of case is to choose an alternative and for
that you NEED to evaluate the matched value. In let or where, the
pattern matching is only there to allow convenient deconstruction of
the value, but you don't make any choice based on the form of the
value, so you can afford to be lazy (which is the default in the
language everywhere it makes sense, it doesn't in a normal case
construct).
If you want to use your pattern matching in a case only to deconstruct
the value but not to choose an alternative, you need to specify it
using ~ .

So, IMHO, the rules on strictness of the pattern matching are
perfectly consistent and clear. You just need to reflect on the
purpose of the constructs where you use it..

-- 
Jedaï
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread Henning Thielemann


On Wed, 19 Sep 2007, Miguel Mitrofanov wrote:

Now why isn't pattern matching lazy by default?  This seems odd for a 
newbie since everything else is lazy by default.


It's even more confusing that pattern matching in 'let' _is_ lazy.


No, it's not.

See, in let or where constructs you don't have a choice; you can't do 
different things depending on whether some value is Just x or Nothing. 
Therefore, there is no need to perform pattern matching strictly.


Then why are patterns in lambdas not lazy?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread Peter Verswyvelen

 It's even more confusing that pattern matching in 'let' _is_ lazy.
 Then why are patterns in lambdas not lazy?

I'm learning a lot here! :-)

Peter

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread Roberto Zunino

Henning Thielemann wrote:

Then why are patterns in lambdas not lazy?


Because they should allow for more branches! ;-))

null = \ [] - True
 _  - False

--
Zun.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread Bas van Dijk
On 9/19/07, Roberto Zunino [EMAIL PROTECTED] wrote:
 Henning Thielemann wrote:
  Then why are patterns in lambdas not lazy?

 Because they should allow for more branches! ;-))

 null = \ [] - True
   _  - False

See http://hackage.haskell.org/trac/haskell-prime/ticket/114 for a
relevant proposal for Haskell Prime regarding something like this.

Bas
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread C.M.Brown
Hi Miguel,

 See, in let or where constructs you don't have a choice; you can't do
 different things depending on whether some value is Just x or
 Nothing. Therefore, there is no need to perform pattern matching
 strictly.

This is not entirely true. This is actually one of those niches in Haskell
where the left to right is not quite the same as right to left. A let can be 
converted to a where
but the other way round may require a case introduction.

So just like you can define:

f (Just x) = x
f Nothing  = error Nothing

You can also define:

f x = g x
   where
 g (Just x) = x
 g Nothing = error Nothing

g is strict in its first argument. Declared in a let it would look like:

f x = let g x = case x of
   (Just y) - y
   Nothing - error Nothing  in g x

Again, g must be strict in its first argument.

Chris.


 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread Isaac Dupree

Chaddaï Fouché wrote:

2007/9/19, Miguel Mitrofanov [EMAIL PROTECTED]:

Now why isn't pattern matching lazy by default?  This seems odd
for a newbie since everything else is lazy by default.

It's even more confusing that pattern matching in 'let' _is_ lazy.

No, it's not.

See, in let or where constructs you don't have a choice; you can't do
different things depending on whether some value is Just x or
Nothing. Therefore, there is no need to perform pattern matching
strictly.


In other words, the pattern matching in case can't be lazy by default
since the primary purpose of case is to choose an alternative and for
that you NEED to evaluate the matched value. In let or where, the
pattern matching is only there to allow convenient deconstruction of
the value, but you don't make any choice based on the form of the
value, so you can afford to be lazy (which is the default in the
language everywhere it makes sense, it doesn't in a normal case
construct).
If you want to use your pattern matching in a case only to deconstruct
the value but not to choose an alternative, you need to specify it
using ~ .

So, IMHO, the rules on strictness of the pattern matching are
perfectly consistent and clear. You just need to reflect on the
purpose of the constructs where you use it..


Except that newtype deconstruction doesn't introduce strictness - and 
you can't necessarily see from the syntax of a pattern-match whether 
it's newtype or data.


Isaac
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread Dan Doel
On Wednesday 19 September 2007, C.M.Brown wrote:

 g is strict in its first argument. Declared in a let it would look like:

 f x = let g x = case x of
(Just y) - y
Nothing - error Nothing  in g x

 Again, g must be strict in its first argument.

Actually,

f x = let g (Just x) = x
  g Nothing  = error Nothing in g x

is a valid definition. A let expression can have multiple definitions just 
like a where clause.

-- Dan
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] GHC 6.7 on Windows / containers-0.1 package?

2007-09-19 Thread Peter Verswyvelen
Since I'm hopelessly stuck with an weird infinite loop (that consumes 0% 
CPU time!), and since I can't find the problem using trace, I wanted 
to try GHC 6.7, which seems to container a debugger (woohoo!!!). 
Currently I'm using GHC-6.6.1 on Windows.


So I grabbed ghc-6.7.20070824 (=the latest one for Windows I could find) 
and the extra-libs, compiled and installed the GLUT package (which I 
needed), but when I compile my library, I get


   Could not find module `Data.Map':
 it is a member of package containers-0.1, which is hidden

So I tried to expose it using

GHC-PKG expose containers-0.1

which worked find, because GHC-PKG list prints

d:/app/ghc/ghc-6.7.20070824\package.conf:
   Cabal-1.1.7, GLUT-2.1.1, HUnit-1.1.1, OpenGL-2.2.1,
   QuickCheck-1.0.1, Win32-2.1, array-0.1, arrows-0.2.1, base-2.1,
   bytestring-0.1, cgi-3001.1.5, containers-0.1, directory-1.0,
   fgl-5.4.1, filepath-1.0, (ghc-6.7.20070824), haskell-src-1.0.1,
   haskell98-1.0, hpc-0.5, html-1.0.1, mtl-1.0.1, network-2.0.1,
   old-locale-1.0, old-time-1.0, packedstring-0.1, parallel-1.0,
   parsec-2.0, pretty-1.0, process-1.0, random-1.0, regex-base-0.72,
   rts-1.0, stm-2.1, template-haskell-0.1, xhtml-3000.0.2

Anybody has an idea how I can continue?

Thanks (again!),
Peter


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread Isaac Dupree

C.M.Brown wrote:

Hi Miguel,


See, in let or where constructs you don't have a choice; you can't do
different things depending on whether some value is Just x or
Nothing. Therefore, there is no need to perform pattern matching
strictly.


This is not entirely true. This is actually one of those niches in Haskell
where the left to right is not quite the same as right to left. A let can be 
converted to a where
but the other way round may require a case introduction.

So just like you can define:

f (Just x) = x
f Nothing  = error Nothing

You can also define:

f x = g x
   where
 g (Just x) = x
 g Nothing = error Nothing

g is strict in its first argument. Declared in a let it would look like:

f x = let g x = case x of
   (Just y) - y
   Nothing - error Nothing  in g x

Again, g must be strict in its first argument.


or

f x = let
 g (Just x) = x
 g Nothing = error Nothing
  in g x

also works perfectly fine.  The (Just x) and Nothing are not 
let-patterns, they are function-definition-patterns, and of course are 
strict since they make a decision.



Isaac
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GHC 6.7 on Windows / containers-0.1 package?

2007-09-19 Thread Neil Mitchell
Hi Peter,

  So I grabbed ghc-6.7.20070824 (=the latest one for Windows I could find)
 and the extra-libs, compiled and installed the GLUT package (which I
 needed), but when I compile my library, I get

  Could not find module `Data.Map':
it is a member of package containers-0.1, which is hidden

All dependencies etc. have changed when going to 6.7/6.8 - you are
probably better off using 6.6.1 for now.

I also don't think that the debugger will help you track down infinite
loop style errors. You might be better off posting the code and asking
for help.

Thanks

Neil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GHC 6.7 on Windows / containers-0.1 package?

2007-09-19 Thread Stefan O'Rear
On Wed, Sep 19, 2007 at 10:24:24PM +0100, Neil Mitchell wrote:
 Hi Peter,
 
   So I grabbed ghc-6.7.20070824 (=the latest one for Windows I could find)
  and the extra-libs, compiled and installed the GLUT package (which I
  needed), but when I compile my library, I get
 
   Could not find module `Data.Map':
 it is a member of package containers-0.1, which is hidden
 
 All dependencies etc. have changed when going to 6.7/6.8 - you are
 probably better off using 6.6.1 for now.
 
 I also don't think that the debugger will help you track down infinite
 loop style errors. You might be better off posting the code and asking
 for help.

You said 0% CPU.  That's *very* important.  It means that you are using
the threaded runtime (GHCi?), and that you triggered a blackhole.  You
should be able to handle this by compiling your program with -prof (do
*not* use -threaded!), and running with +RTS -xc.  With luck, that will
give you a backtrace to the infinite loop.

PS. blackholes are a serious dark corner of GHC's execution model,
chances are better than even that if you try to use the debugger for
this you will discover a new and (for you) crippling bug.  I wouldn't
recommend it.

Stefan


signature.asc
Description: Digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread C.M.Brown
Hi Isaac


 or

 f x = let
   g (Just x) = x
   g Nothing = error Nothing
in g x


That's interesting, thanks!


Chris.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why isn't pattern matching lazy by default?

2007-09-19 Thread Felipe Almeida Lessa
On 9/19/07, C.M.Brown [EMAIL PROTECTED] wrote:
  f x = let
g (Just x) = x
g Nothing = error Nothing
 in g x
 

 That's interesting, thanks!

FYI, you may also use guards, even if you don't have a parameter. For
example, you may turn

f x = let k = if null x then 10 else head x
  in froobar $ quox k

into

f x = let k | null x= 10
| otherwise = head x
  in froobar $ quox k

Okay, this example is ugly, however it serves the purpose of
illustrating the idea =).

-- 
Felipe.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Interesting folds over bytestring lists?

2007-09-19 Thread Justin Bailey
I have a data structure which is a list of bytestrings, but externally
it looks like one big string. One of the operations I want to support
takes a section of the string, starting at some arbitrary index and
ending somewhere further down the line. In implementing the function I
came up with the two functions below, dropTo and takeTo.

In my mind, dropTo moves over the list of bytestrings until it reaches
the starting point, and then returns the rest. takeTo, in contrast,
scans over the list until it has seen enough bytes to return the
amount requested.

In both cases I am trying to share structure as much as possible in
order to avoid unnecessary copying and space leaks.

I thought these two functions were interested and am looking for
feedback, comments, improvements, etc. Thanks!

import qualified Data.ByteString as S
import qualified Data.ByteString.Lazy as L
import qualified Data.ByteString.Base as B
import Test.QuickCheck
import Data.List (foldl')
import Data.Word

dropTo :: Int - [L.ByteString] - [L.ByteString]
dropTo _ [] = []
dropTo amt strs =
  let dropTo' :: (Int, [L.ByteString]) - L.ByteString - (Int, [L.ByteString])
  dropTo' (rem, acc) ss
| rem == 0 = (0, acc)
| otherwise =
let chunks = L.toChunks ss
in
  case foldl' dropStricts (rem, chunks) chunks of
(!n, rest)
  | null rest - (n, drop 1 acc)
  | otherwise - (0, L.fromChunks rest : drop 1 acc)
  dropStricts :: (Int, [S.ByteString]) - S.ByteString - (Int,
[S.ByteString])
  dropStricts (rem, acc) str
| rem == 0 = (0, acc)
| rem - S.length str == 0 = (0, drop 1 acc)
| rem - S.length str  0 = (0, S.drop rem str : (drop 1 acc))
| otherwise = (rem - S.length str, drop 1 acc)
  (_, rest) = foldl' dropTo' (amt, strs) strs
  in
rest

takeTo :: Int - [L.ByteString] - [L.ByteString]
takeTo _ [] = []
takeTo amt strs =
  let countLazies :: (Int, Int, L.ByteString) - L.ByteString - (Int,
Int, L.ByteString)
  countLazies (rem, !total, lazyLeftover) ss
| rem == 0 = (0, total, lazyLeftover)
| otherwise =
let chunks = L.toChunks ss
in
  case foldl' countStricts (rem, 0, S.empty) chunks of
(!n, amt, strictLeftover)
  | S.null strictLeftover - (n, total + 1, L.empty)
  | otherwise - (n, total, L.fromChunks (take amt
chunks ++ [strictLeftover]))
  countStricts :: (Int, Int, S.ByteString) - S.ByteString -
(Int, Int, S.ByteString)
  countStricts (rem, !total, leftover) str
| rem == 0 = (0, total, leftover)
| rem - S.length str == 0 = (0, total + 1, S.empty)
| rem - S.length str  0 = (0, total, S.take rem str)
| otherwise = (rem - S.length str, total + 1, S.empty)
  in
case foldl' countLazies (amt, 0, L.empty) strs of
  (_, total, leftover)
| L.null leftover - take total strs
| otherwise - take total strs ++ [leftover]

prop_dropToNonEmpty :: [[Word8]] - Int - Property
prop_dropToNonEmpty strs amt =
  amt = 0  (all (not . null) strs) ==
all (not . L.null) (dropTo amt (map (L.pack) strs))

prop_dropToCorrect :: [[Word8]] - Int - Property
prop_dropToCorrect strs amt =
  let lazyStr = L.drop amt64 (toLazyBS strs)
  amt64 = fromIntegral amt
  in
amt = 0  (all (not . null) strs) ==
  (L.concat (dropTo amt (map (L.pack) strs))) == lazyStr

prop_takeToNonEmpty :: [[Word8]] - Int - Property
prop_takeToNonEmpty strs amt =
  amt = 0  (all (not . null) strs) ==
all (not . L.null) (takeTo amt (map (L.pack) strs))

prop_takeToCorrect :: [[Word8]] - Int - Property
prop_takeToCorrect strs amt =
  let lazyStr = L.take amt64 (toLazyBS strs)
  amt64 = fromIntegral amt
  in
amt = 0  (all (not . null) strs) ==
  (L.concat (takeTo amt (map (L.pack) strs))) == lazyStr

-- Functions and instances for testing purposes
toLazyBS :: [[Word8]] - L.ByteString
toLazyBS = L.concat . map L.pack

instance Arbitrary Word8 where
  arbitrary = elements [minBound .. maxBound]
  coarbitrary = undefined

main =
  do
putStrLn prop_takeToNonEmpty
quickCheck prop_takeToNonEmpty
putStrLn prop_takeToCorrect
quickCheck prop_takeToCorrect
putStrLn prop_dropToCorrect
quickCheck prop_dropToCorrect
putStrLn prop_dropToNonEmpty
quickCheck prop_dropToNonEmpty
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] length defined with foldr

2007-09-19 Thread PR Stanley

Hi
length = foldr (. n . 1 + n) 0
Any idea how to define length with foldr. The above definition 
doesn't make much sense.

Many thanks, Paul

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] length defined with foldr

2007-09-19 Thread Stefan O'Rear
On Thu, Sep 20, 2007 at 04:17:54AM +0100, PR Stanley wrote:
 Hi
 length = foldr (. n . 1 + n) 0
 Any idea how to define length with foldr. The above definition doesn't make 
 much sense.
 Many thanks, Paul

length = foldr (λ_ n → 1 + n) 0

or, in ASCII concrete syntax

length = foldr (\_ n - 1 + n) 0

Stefan


signature.asc
Description: Digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] length defined with foldr

2007-09-19 Thread Brandon S. Allbery KF8NH


On Sep 19, 2007, at 23:17 , PR Stanley wrote:


length = foldr (. n . 1 + n) 0
Any idea how to define length with foldr. The above definition  
doesn't make much sense.


Still fighting with the botched OCR?

length = foldr (\_ n - 1 + n) 0

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] length defined with foldr

2007-09-19 Thread PR Stanley



Still fighting with the botched OCR?
I am, as a matter of fact! Is that okay with you? *smile*





length = foldr (\_ n - 1 + n) 0

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Spot the difference!

2007-09-19 Thread PR Stanley

Hi
\_ n - 1 + n
\_ - (\n - 1 + n)
The outcome seems to be identical. is there a substantive difference 
between the two definitions?

The second one seems to be more expressive of the currying principle.
Any thoughts?

Thanks, Paul

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Spot the difference!

2007-09-19 Thread Brandon S. Allbery KF8NH


On Sep 20, 2007, at 0:03 , PR Stanley wrote:


\_ n - 1 + n
\_ - (\n - 1 + n)
The outcome seems to be identical. is there a substantive  
difference between the two definitions?

The second one seems to be more expressive of the currying principle.
Any thoughts?


I *think* the former is internally converted to the latter; this is  
how currying works.


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Spot the difference!

2007-09-19 Thread PR Stanley
I must confess that the use of \_ had me a little confused at first 
but thinking about it I can see that it makes perfect sense to have 
an argument or a wildcard character for any value.

Cheers, Paul



On Sep 20, 2007, at 0:03 , PR Stanley wrote:


\_ n - 1 + n
\_ - (\n - 1 + n)
The outcome seems to be identical. is there a substantive
difference between the two definitions?
The second one seems to be more expressive of the currying principle.
Any thoughts?


I *think* the former is internally converted to the latter; this is
how currying works.

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Spot the difference!

2007-09-19 Thread Brandon S. Allbery KF8NH


On Sep 20, 2007, at 0:16 , PR Stanley wrote:

I must confess that the use of \_ had me a little confused at  
first but thinking about it I can see that it makes perfect sense  
to have an argument or a wildcard character for any value.


Sure.  Remember, arguments are pattern matches in Haskell (the  
degenerate case being a variable name which is an irrefutable match  
resulting in a lambda binding).  As such, it's useful to have a  
wildcard pattern which matches irrefutably without binding.


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Spot the difference!

2007-09-19 Thread Tony Morris
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

PR Stanley wrote:
 I must confess that the use of \_ had me a little confused at first
 but thinking about it I can see that it makes perfect sense to have an
 argument or a wildcard character for any value.
 Cheers, Paul

FYI
If \_ - foo confuses you, you might wish to use const foo instead.

Tony Morris
http://tmorris.net/

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG8fizmnpgrYe6r60RAqKBAKCKQ76HMtJ8jsgJ5nmX8ECROOcirQCfQgKS
OQflRMDqHqX2TUWibG4oiB4=
=L6C4
-END PGP SIGNATURE-
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Spot the difference!

2007-09-19 Thread PR Stanley



test1 n _ = 1 + n
test2 n = \_ - 1 + n

I don't know if it's still the case, but GHC used to compile different
code for these at high optimisation levels.  The first was essentially
compiled to:

test1 = \n _ - 1+n

And the second to:

test2 = \n - let x = n+1 in \_ - x

The difference is that test1 is faster if it's usually fully applied,
test2 is fully lazy.

Fully lazy? Can you elaborate please?
Thanks, Paul

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Spot the difference!

2007-09-19 Thread ajb

G'day all.

Quoting PR Stanley [EMAIL PROTECTED]:


Fully lazy? Can you elaborate please?


Sure.  that code again:

test1 = \n _ - 1+n
test2 = \n - let x = n+1 in \_ - x

Suppose we have:

f g x = g x + g x

And we try two options:

f (test1 4) 3
f (test2 4) 3

In the first case, (1+4) will be evaluated twice.  In the second case, it
will only be evaluated once.

Cheers,
Andrew Bromage
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe