[Haskell-cafe] typeOf for polymorphic value

2009-03-25 Thread oleg
> Does anyone know of a trick to accomplish `typeOf id'? > Using something else than TypeRep as the representation, of course. Yes. The analysis of polymorphic types has been used in the inverse type-checker http://okmij.org/ftp/Haskell/types.html#de-typechecker The enclosed code compute

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-25 Thread Benja Fallenstein
On Thu, Mar 26, 2009 at 2:40 AM, Duncan Coutts wrote: > I was not being precise when I said "tests for _|_". As you point out, > the semantics of imprecise exceptions distinguishes exceptions from > bottom, however pure code cannot make that distinction and so that's why > I was lumping them toget

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-25 Thread Duncan Coutts
On Wed, 2009-03-25 at 18:14 +0100, Benja Fallenstein wrote: > On Wed, Mar 25, 2009 at 3:52 AM, Duncan Coutts > > Of course your tryArith only tests for certain kinds of _|_ value, but > > in principle the problem is the same. > > That's not *quite* how the semantics of Haskell exceptions are > de

Re: [Haskell-cafe] Re: a cabal package with both a library and executable programs

2009-03-25 Thread Duncan Coutts
On Wed, 2009-03-25 at 15:19 +0100, Achim Schneider wrote: > Manlio Perillo wrote: > > > Should I fill a feature request ticket, or this is how it is supposed > > to work? > > > I would like to be able to do that, too. I also don't want cabal to > recompile a thousand modules just for a demo progr

[Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-25 Thread Heinrich Apfelmus
Manlio Perillo wrote: > Heinrich Apfelmus ha scritto: >> >> I think you'd have had a much easier time by starting with a proper book >> right away, like Richard Bird's "Introduction to Functional Programming >> in Haskell", accompanied by Real World Haskell. > > Unfortunately, one year ago Real W

Re: [Haskell-cafe] Learning Haskell

2009-03-25 Thread Lennart Augustsson
I'm still learning. :) (And I wrote the first available Haskell compiler.) -- Lennart On Tue, Mar 24, 2009 at 4:08 AM, Tom.Amundsen wrote: > > How long did it take you to become proficient in Haskell? By that, I mean - > how long until you were just as comfortable with Haskell as you were wi

[Haskell-cafe] typeOf for polymorphic value

2009-03-25 Thread Lennart Augustsson
Using Data.Typeable.typeOf we can get a representation of the the type of a monomorphic value, for instance Prelude Data.Typeable> typeOf not Bool -> Bool But if we try using it on a polymorphic value it fails Prelude Data.Typeable> typeOf id :1:0: Ambiguous type variable `a' in the c

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-25 Thread wren ng thornton
Henning Thielemann wrote: Jonathan Cast wrote: > Xiao-Yong Jin wrote: > > > > Could you elaborate more about why this kind of breakage > > wouldn't happen if 'try' is used in an IO monad as intended? > > It would. But it would happen in IO, which is allowed to be > non-deterministic. Pure Haske

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread Thomas Hartman
> Beginner list processing code can and often does go awry when presented with > infinite lists. I didn't mean code that a beginner would write, I mean code that would be easy to understand for a beginner to read -- that is, explicit pattern matching, explicit recursion, no gratuitous use of stat

[Haskell-cafe] Re: [OT] Japanese (was: Re: about Haskell code written to be "too smart")

2009-03-25 Thread Achim Schneider
wren ng thornton wrote: > All natural languages are Thinking-complete. > No, they aren't. Falsifying the Saphir-Worph thesis, I quite often find myself incapable of expressing a certain thought, or if I succeed, come up with two or more versions in multiple different languages that mean slightly

[Haskell-cafe] Re: How to increment an Int in Haskell (stack overflow issue)

2009-03-25 Thread John Lato
> From: Tim Bauer > > I have a program that is currently blowing out the stack, >    Stack space overflow: current size 8388608 bytes. >    Use `+RTS -Ksize' to increase it. > I am pretty sure I get to the end of the computation that > increments various statistic counters (lazily?) and only > whe

[Haskell-cafe] Re: Data Structures with Haskell

2009-03-25 Thread Achim Schneider
Rohit Agrawalla wrote: > I am a beginner haskell programmer. I am interested in data > structures implementation (all from basic ones like stack, queues > etc. to advance ones like balanced binary trees, graphs etc.) in > haskell. It would be really helpful if someone can point some good > refe

[Haskell-cafe] [OT] Japanese (was: Re: about Haskell code written to be "too smart")

2009-03-25 Thread wren ng thornton
Zachary Turner wrote: On Tue, Mar 24, 2009 at 10:32 PM, wren ng thornton wrote: Both of these conclusions seem quite natural to me, even from before learning Haskell. It seems, therefore, that "naturality" is not the proper metric to discuss. It's oft overlooked, but the fact is that expressivi

Re: [Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-25 Thread Ryan Ingram
On Wed, Mar 25, 2009 at 8:25 AM, Jonathan Cast wrote: > On Wed, 2009-03-25 at 15:09 +, Simon Marlow wrote: >> the ordering that the state monad expects >> (and I can never remember which way around they are in Control.Monad.State). > > Really?  I found it obvious once I figured out it how simp

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread Dan Piponi
On Wed, Mar 25, 2009 at 12:44 PM, Thomas Hartman wrote: >> Are you saying there's a problem with this implementation? It's the > > Yes, there is actually a problem with this implementation. > However, there is something to be said for code that just looks like a > duck and quacks like a duck. It'

Re: [Haskell-cafe] Data Structures with Haskell

2009-03-25 Thread Gwern Branwen
2009/3/25 Rohit Agrawalla : I am a beginner haskell programmer. I am interested  in data structures implementation (all from basic ones like stack, queues etc. to advance ones like balanced binary trees, graphs etc.)  in haskell. It would be really helpful if someone can point some good reference

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread wren ng thornton
Dan Weston wrote: So to be clear with the terminology: inductive = good consumer? coinductive = good producer? So fusion should be possible (automatically? or do I need a GHC rule?) with inductive . coinductive Or have I bungled it? Not quite. Induction means starting from base cases and

[Haskell-cafe] Data Structures with Haskell

2009-03-25 Thread Rohit Agrawalla
I am a beginner haskell programmer. I am interested in data structures implementation (all from basic ones like stack, queues etc. to advance ones like balanced binary trees, graphs etc.) in haskell. It would be really helpful if someone can point some good references for the same. Regards , Roh

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-25 Thread Jonathan Cast
On Wed, 2009-03-25 at 22:32 +0100, Henning Thielemann wrote: > On Wed, 25 Mar 2009, Jonathan Cast wrote: > > > On Wed, 2009-03-25 at 07:39 -0400, Xiao-Yong Jin wrote: > >> > >> Could you elaborate more about why this kind of breakage > >> wouldn't happen if 'try' is used in an IO monad as intended

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-25 Thread Henning Thielemann
On Wed, 25 Mar 2009, Jonathan Cast wrote: On Wed, 2009-03-25 at 07:39 -0400, Xiao-Yong Jin wrote: Could you elaborate more about why this kind of breakage wouldn't happen if 'try' is used in an IO monad as intended? It would. But it would happen in IO, which is allowed to be non-determinis

Re: [Haskell-cafe] Learning Haskell

2009-03-25 Thread Andrew Coppin
Tom.Amundsen wrote: How long did it take you to become proficient in Haskell? By that, I mean - how long until you were just as comfortable with Haskell as you were with your strongest language at that time? I probably shouldn't even answer that. I keep thinking I only just found out about

Re: [Haskell-cafe] ANNOUNCE: WinGhci, a GUI for GHCI on Windows

2009-03-25 Thread Andrew Coppin
Pepe Gallardo wrote: Hi, I am pleased to announce the first release of WinGhci. WinGhci is a simple GUI for GHCI on Windows. It is closely based on WinHugs, and provides similar functionality. This is now #1 on my list of things that must be tried. __

Re: [Haskell-cafe] [ANN] I/O library for Windows

2009-03-25 Thread Andrew Coppin
Felix Martini wrote: Hi all, winio is an I/O library for Windows using Windows API functions and has I/O completion port support. The main goal of this library is to support Simon Marlow's new Handle API once he has added that to GHC. The library also has a compatibility module for socket functi

Re: [Haskell-cafe] [ANN] ansi-terminal, ansi-wl-pprint - ANSI terminal support for Haskell

2009-03-25 Thread Jonathan Cast
On Wed, 2009-03-25 at 21:18 +, Andrew Coppin wrote: > I'M ON WINDOWS! ;-) We've noticed... jcc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] [ANN] ansi-terminal, ansi-wl-pprint - ANSI terminal support for Haskell

2009-03-25 Thread Andrew Coppin
Max Bolingbroke wrote: These two packages allow Haskell programs to produce much richer console output by allowing colorisation, emboldening and so on. Both Unix-like (OS X, Linux) and Windows operating systems are supported (via a pure Haskell ANSI emulation layer for Windows). Examples, scree

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread wren ng thornton
Manlio Perillo wrote: The main problem, here, is that: - recursion and pattern matching are explained in every tutorial about functional programming and Haskell. This is the reason why I find them more "natural". - high level, Haskell specific, abstractions, are *not* explained in normal

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread Thomas Hartman
s/Pattern matching is awesome language feature. use it! /Pattern matching is awesome language feature. Don't be ashamed to use it! / :) 2009/3/25 Thomas Hartman : > Not only is your "simpler" function easier to read, it is also more correct. > > partitionsHubris xs ns = zipWith take ns . init $

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread Thomas Hartman
Not only is your "simpler" function easier to read, it is also more correct. partitionsHubris xs ns = zipWith take ns . init $ scanl (flip drop) xs ns partitionsBeginner :: [Int] -> [a] -> [[a]] partitionsBeginner [] _ = [] partitionsBeginner _ [] = [] partitionsBeginner (n : ns

Re: [Haskell-cafe] How to increment an Int in Haskell (stack overflow issue)

2009-03-25 Thread Don Stewart
bauertim: > I have a program that is currently blowing out the stack, >Stack space overflow: current size 8388608 bytes. >Use `+RTS -Ksize' to increase it. > I am pretty sure I get to the end of the computation that > increments various statistic counters (lazily?) and only > when I go to p

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread Thomas Hartman
Since this thread is ostensibly about haskell style, it should also be about haskell style *today*. As I think Yitz noted earlier, this is a moving target. Adoption of haskell by the masses -- moving. Skill of haskell hordes -- moving. Abstractions available as part of "idiomatic haskell", and co

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread Thomas Hartman
Oh, and incidentally, if you change to Control.Monad.State.Strict *Main> testP partitionsTooFrickinClever testP partitionsTooFrickinClever^J*** Exception: stack overflow Don't get me wrong -- I have learned a lot from this thread, and I think it would be really cool if there was a way to do this

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread Jonathan Cast
On Wed, 2009-03-25 at 12:48 -0700, Dan Weston wrote: > > However, there is something to be said for code that just looks like a > > duck and quacks like a duck. It's less likely to surprise you. > > > > So... I insist... Easy for a beginner to read == better! > > All you have said is that one b

Re: [Haskell-cafe] How to increment an Int in Haskell (stack overflow issue)

2009-03-25 Thread Daniel Fischer
Am Mittwoch 25 März 2009 20:00:40 schrieb Tim Bauer: > I have a program that is currently blowing out the stack, > Stack space overflow: current size 8388608 bytes. > Use `+RTS -Ksize' to increase it. > I am pretty sure I get to the end of the computation that > increments various statistic

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread Dan Weston
> However, there is something to be said for code that just looks like a > duck and quacks like a duck. It's less likely to surprise you. > > So... I insist... Easy for a beginner to read == better! All you have said is that one building a skyscraper will need scaffolding, blueprints, and a goo

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread Thomas Hartman
> Are you saying there's a problem with this implementation? It's the Yes, there is actually a problem with this implementation. import Data.List import Control.Monad.State import Debug.Trace.Helpers partitions [] xs = [] partitions (n:parts) xs = let (beg,end) = splitAt n xs in beg : ( cas

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread Dan Weston
So to be clear with the terminology: inductive = good consumer? coinductive = good producer? So fusion should be possible (automatically? or do I need a GHC rule?) with inductive . coinductive Or have I bungled it? Dan wren ng thornton wrote: Thomas Hartman wrote: sorry, wrong function.

Re: [Haskell-cafe] ghci + hopengl

2009-03-25 Thread Duane Johnson
Neat, thanks for that tip Peter. It looks like mkbundl does everything I do manually, and more. But just for the record, in case anyone (Scott?) wants to do it the hard way... :) 1. Download the macosx-app shell script from wxhaskell. Make it executable (i.e. "chmod a+x macosx-app") 2.

Re: [Haskell-cafe] How to increment an Int in Haskell (stack overflow issue)

2009-03-25 Thread Lennart Augustsson
Make an AState with two !Int fields and increment those. On Wed, Mar 25, 2009 at 8:00 PM, Tim Bauer wrote: > I have a program that is currently blowing out the stack, >   Stack space overflow: current size 8388608 bytes. >   Use `+RTS -Ksize' to increase it. > I am pretty sure I get to the end of

Re: [Haskell-cafe] Making videos of your project

2009-03-25 Thread Duane Johnson
Cool! Thanks, Don. I enjoyed the "show" :) Duane Johnson On Mar 24, 2009, at 2:20 AM, Don Stewart wrote: Hey guys, I've been making quick youtube videos of projects to convey what they do. Here, for example, using Tim Docker's Charts library in ghci: http://www.youtube.com/watch?v=2Lqzy

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread wren ng thornton
Thomas Hartman wrote: sorry, wrong function. should be partitions [] xs = [] partitions (n:parts) xs = let (beg,end) = splitAt n xs in beg : ( case end of [] -> [] xs -> partitions parts xs) It's not tail recursive, FWIW. The recursive expression has (:) as

[Haskell-cafe] How to increment an Int in Haskell (stack overflow issue)

2009-03-25 Thread Tim Bauer
I have a program that is currently blowing out the stack, Stack space overflow: current size 8388608 bytes. Use `+RTS -Ksize' to increase it. I am pretty sure I get to the end of the computation that increments various statistic counters (lazily?) and only when I go to print them out at the

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-25 Thread Donn Cave
Quoth Jonathan Cast : > On Wed, 2009-03-25 at 10:00 -0700, Donn Cave wrote: >> So I thought it would be interesting to explore statements like "you >> must not do this", and "pure Haskell is not allowed to be >> non-deterministic", in terms of practical effects. No one would >> make a statement

Re: [Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-25 Thread Conal Elliott
or via Arrow: swap = snd &&& fst On Wed, Mar 25, 2009 at 9:16 AM, David Menendez wrote: > On Wed, Mar 25, 2009 at 11:32 AM, Simon Marlow wrote: > > Jonathan Cast wrote: > >> > >> Define > >> > >>swap (a, b) = (b, a) > > > > ew, that's far too crude. I think you mean > > > > swap = uncurr

Re: [Haskell-cafe] Whats the use of "!"

2009-03-25 Thread Neil Mitchell
Hi A quick Hoogle for ! : http://haskell.org/hoogle/?hoogle=! Gives the first answer as: http://www.haskell.org/haskellwiki/Keywords#.21 If that isn't clear, someone should expand on it or give further links to useful resources. Thanks Neil 2009/3/25 Harsh Verma : > I have seen ! added in fro

[Haskell-cafe] Whats the use of "!"

2009-03-25 Thread Harsh Verma
I have seen ! added in front of many values, is it related to strict evaluation? Please elaborate on it. TIA, gimli _ Windows Live Messenger. Multitasking at its finest. http://www.microsoft.com/india/windows/windowslive/messenger.a

[Haskell-cafe] central european functional programming school

2009-03-25 Thread Roman Cheplyaka
Hi, I'm interested in 3rd central european functional programming school[1]. Maybe some haskellers attended previous CEFPs and want to share (or already shared) some experience? Who also is going to attend or participate in this year's CEFP? 1. http://plcportal.inf.elte.hu/en/tfp_cefp_2009/Pa

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-25 Thread Jonathan Cast
On Wed, 2009-03-25 at 10:00 -0700, Donn Cave wrote: > Quoth Jonathan Cast : > > On Wed, 2009-03-25 at 09:15 -0700, Donn Cave wrote: > > >> OK, these are interesting phenomena. From a practical point of view, > >> though, I could see someone weighing the potential costs and benefits > >> of a exce

Re: [Haskell-cafe] Re: Learning Haskell

2009-03-25 Thread jean-christophe mincke
I discovered Haskell about a year and half ago, along with F#. Beginning with both languages was relatively easy but I already had experience of FP in lisp and scheme. And some years ago I took a course in FP (learning CAML which F# is closely based on). My study of haskell went smooth up to the

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-25 Thread Benja Fallenstein
Hi Duncan and all, On Wed, Mar 25, 2009 at 3:52 AM, Duncan Coutts wrote: > On Mon, 2009-03-23 at 08:11 -0400, Xiao-Yong Jin wrote: >> > tryArith :: a -> Either ArithException a >> > tryArith = unsafePerformIO . try . evaluate > > You must not do this. It breaks the semantics of the language. > >

Re: [Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-25 Thread Jake McArthur
Simon Marlow wrote: > Jonathan Cast wrote: >> Define >> >> swap (a, b) = (b, a) > > ew, that's far too crude. I think you mean > > swap = uncurry $ flip (,) I think I would prefer something that mirrors flip more closely: swap :: ((a,b) -> c) -> (b,a) -> c swap = uncurry . flip .

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-25 Thread Donn Cave
Quoth Jonathan Cast : > On Wed, 2009-03-25 at 09:15 -0700, Donn Cave wrote: >> OK, these are interesting phenomena. From a practical point of view, >> though, I could see someone weighing the potential costs and benefits >> of a exception handler outside IO like this, and these effects might >> n

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-25 Thread Lennart Augustsson
If you think non-determinstic programs are acceptable, then you can use unsafePerformIO this way. But future versions of compilers may make them even more unpredictable, so beware. I think that if the exception handler does not look at exactly what exception was thrown, then the program will just

[Haskell-cafe] Re: Grouping - Map / Reduce

2009-03-25 Thread Gü?nther Schmidt
Dear Luke, I'm at a loss trying to figure out what is happening here, I'd sincerely appreciate it if you could find the time to give me more clues on this, I'm deeply impressed. If I think that what is happening *is* happening that would mean that this is a way to group in almost constant spac

Re: [Haskell-cafe] Re: Learning Haskell

2009-03-25 Thread Lanny Ripple
Learning the syntax, a day or two. Learning major idioms (many of which are encapsulated in modules), ongoing (it's been about two years of off and on). Sadly I can't use it for my $work language. If I could then the time available for learning haskell and paying the mortgage would not be disjoin

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-25 Thread Jonathan Cast
On Wed, 2009-03-25 at 09:15 -0700, Donn Cave wrote: > Quoth Lennart Augustsson : > > > Some examples of what might happen: > > OK, these are interesting phenomena. From a practical point of view, > though, I could see someone weighing the potential costs and benefits > of a exception handler out

Re: [Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-25 Thread Jonathan Cast
On Wed, 2009-03-25 at 15:32 +, Simon Marlow wrote: > Jonathan Cast wrote: > > On Wed, 2009-03-25 at 15:09 +, Simon Marlow wrote: > >> the ordering that the state monad expects > >> (and I can never remember which way around they are in > >> Control.Monad.State). > > > > Really? I found

Re: [Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-25 Thread David Menendez
On Wed, Mar 25, 2009 at 11:32 AM, Simon Marlow wrote: > Jonathan Cast wrote: >> >> Define >> >>    swap (a, b) = (b, a) > > ew, that's far too crude.  I think you mean > >  swap = uncurry $ flip (,) On the theme of using monads where you might not expect, swap = liftA2 (,) snd fst -- Dave Mene

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-25 Thread Donn Cave
Quoth Lennart Augustsson : > Some examples of what might happen: OK, these are interesting phenomena. From a practical point of view, though, I could see someone weighing the potential costs and benefits of a exception handler outside IO like this, and these effects might not even carry all that

Re: [Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-25 Thread Jonathan Cast
On Wed, 2009-03-25 at 03:01 +, Robin Green wrote: > On Wed, 25 Mar 2009 08:25:40 -0700 > Jonathan Cast wrote: > > > Define > > > > swap (a, b) = (b, a) > > By the way, if you want to be "too smart", there's a generalised > version of swap in Control.Category.Braided in the category-extr

Re: [Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-25 Thread Robin Green
On Wed, 25 Mar 2009 08:25:40 -0700 Jonathan Cast wrote: > Define > > swap (a, b) = (b, a) By the way, if you want to be "too smart", there's a generalised version of swap in Control.Category.Braided in the category-extras package. That might be a bit overkill though. -- Robin

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread Gregg Reynolds
2009/3/25 Zachary Turner : > > On the other hand, -certain- languages are more expressive than others.  As > an example, I personally find English far more expressive than both > Vietnamese and Japanese, yet English is far more complicated.  Japanese, for Way off topic, but for what it's worth, yo

Re: [Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-25 Thread Jake McArthur
Simon Marlow wrote: Jonathan Cast wrote: Define swap (a, b) = (b, a) ew, that's far too crude. I think you mean swap = uncurry $ flip (,) I think I would prefer something that mirrors flip more closely: swap :: ((a,b) -> c) -> (b,a) -> c swap = uncurry . flip . curry - Jak

Re: [Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-25 Thread Peter Verswyvelen
On Wed, Mar 25, 2009 at 4:09 PM, Simon Marlow wrote: > But it only works out nicely because the ordering of the components of the > pair returned by splitAt matches the ordering that the state monad expects > (and I can never remember which way around they are in Control.Monad.State). > Now you

Re: [Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-25 Thread Simon Marlow
Jonathan Cast wrote: On Wed, 2009-03-25 at 15:09 +, Simon Marlow wrote: the ordering that the state monad expects (and I can never remember which way around they are in Control.Monad.State). Really? I found it obvious once I figured out it how simple it made (>>=). With the order from Co

Re: [Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-25 Thread Jonathan Cast
On Wed, 2009-03-25 at 15:09 +, Simon Marlow wrote: > the ordering that the state monad expects > (and I can never remember which way around they are in Control.Monad.State). Really? I found it obvious once I figured out it how simple it made (>>=). With the order from Control.Monad.State (w

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-25 Thread Jonathan Cast
On Wed, 2009-03-25 at 07:39 -0400, Xiao-Yong Jin wrote: > Jonathan Cast writes: > > > On Tue, 2009-03-24 at 23:13 -0700, Donn Cave wrote: > >> Quoth Duncan Coutts : > >> > >> > You must not do this. It breaks the semantics of the language. > >> > > >> > Other people have given practical reasons

[Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-25 Thread Simon Marlow
Dan Piponi wrote: Miguel Mitrofanov wrote: takeList = evalState . mapM (State . splitAt) However, ironically, I stopped using them for pretty much the same reason that Manlio is saying. Are you saying there's a problem with this implementation? It's the only one I could just read immediatel

[Haskell-cafe] Re: Haddock GSoC project

2009-03-25 Thread Isaac Dupree
Simon Marlow wrote: > Obviously I think these tickets are important, since I wrote them :-) In > terms of priority, I think #1567 is at the top: not having this harms our > ability to reorganise and abstract things, it puts an arbitrary barrier > between packages. It's possible my perspective is

[Haskell-cafe] Re: Haddock GSoC project

2009-03-25 Thread Simon Marlow
Isaac Dupree wrote: I'm interested in being a GSoC student, and the Haddock-related tickets looked like a good place to start http://hackage.haskell.org/trac/summer-of-code/ticket/1567 http://hackage.haskell.org/trac/summer-of-code/ticket/1568 http://hackage.haskell.org/trac/summer-of-code/ticke

[Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-25 Thread Achim Schneider
Manlio Perillo wrote: > The main problem, here, is that: > - recursion and pattern matching are explained in every tutorial about >functional programming and Haskell. > >This is the reason why I find them more "natural". > Well, you're going to have a hard time writing a BASIC tutorial

[Haskell-cafe] Re: Exception handling in numeric computations

2009-03-25 Thread Xiao-Yong Jin
John Lato writes: >> Yes, I know, it's not really complicate to rewrite the above >> code.  But, what do I really gain from this rewrite? > > Apologies if this discussion has moved on, but I wanted to comment on this. > Thanks for elaborating it more. > > You gain correctness. Any functions th

[Haskell-cafe] Re: a cabal package with both a library and executable programs

2009-03-25 Thread Achim Schneider
Manlio Perillo wrote: > Should I fill a feature request ticket, or this is how it is supposed > to work? > I would like to be able to do that, too. I also don't want cabal to recompile a thousand modules just for a demo program, and don't want to see hackage being polluted by thousands of foo-lib

[Haskell-cafe] a cabal package with both a library and executable programs

2009-03-25 Thread Manlio Perillo
Hi. This example is taken from the Cabal documentation: Name:TestPackage ... Library Build-Depends: HUnit Exposed-Modules: A, B, C Executable program1 Main-Is: Main.hs Hs-Source-Dirs: prog1 Other-Modules: A, B Executable program2 Main-Is: Main.hs

Re: [Haskell-cafe] Haddock GSoC project

2009-03-25 Thread John Van Enk
Having cross-package links would be pure awesome. On Wed, Mar 25, 2009 at 10:04 AM, Isaac Dupree < m...@isaac.cedarswampstudios.org> wrote: > I'm interested in being a GSoC student, and the Haddock-related tickets > looked > like a good place to start > http://hackage.haskell.org/trac/summer-of-c

Re: [Haskell-cafe] Definition of "tail recursive" wrt Folds

2009-03-25 Thread Brent Yorgey
On Wed, Mar 25, 2009 at 05:54:17PM +1030, Mark Spezzano wrote: > > What, strictly speaking, is the definition of ”tail recursive” as opposed to > just “recursive”? A recursive function is tail recursive if the final result of the recursive call is the final result of the function itself. If the

[Haskell-cafe] Haddock GSoC project

2009-03-25 Thread Isaac Dupree
I'm interested in being a GSoC student, and the Haddock-related tickets looked like a good place to start http://hackage.haskell.org/trac/summer-of-code/ticket/1567 http://hackage.haskell.org/trac/summer-of-code/ticket/1568 http://hackage.haskell.org/trac/summer-of-code/ticket/1569 ... haddock co

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread Zachary Turner
On Tue, Mar 24, 2009 at 10:32 PM, wren ng thornton wrote: > Both of these conclusions seem quite natural to me, even from before > learning Haskell. It seems, therefore, that "naturality" is not the proper > metric to discuss. It's oft overlooked, but the fact is that expressivity > comes not from

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread Claus Reinke
The beauty of functional programming is that there doesn't have to be a conflict between those who prefer explicit and those who prefer implicit recursion. Think of them as different views on the same functions - just as with graphical visualizations, pick the view best suited to your purpose and

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread Manlio Perillo
wren ng thornton ha scritto: Manlio Perillo wrote: [...] Following directly from the Rule of Least Power, if you can get away with foreach then that's what you should use. Why? Because the less power the construct has, the fewer corner cases and generalizations a reader of the code needs to co

[Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-25 Thread Achim Schneider
"Alberto G. Corona " wrote: > However, reusability of source code and maintainability has never > been taken seriously by haskell programmers, simply because there are > no industrial projects in Haskell with dozens of people with > different skills that come and go. > Now that's a claim. In the

Re: [Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-25 Thread Manlio Perillo
Heinrich Apfelmus ha scritto: Manlio Perillo wrote: Conal Elliott ha scritto: Manlio, We live in the age of participation -- of co-education. Don't worry about text-books. Contribute to some wiki pages & blogs today that share these smart techniques with others. When I started learning Has

[Haskell-cafe] Re: generalized shuffle

2009-03-25 Thread Manlio Perillo
o...@okmij.org ha scritto: Hello! The reason is that in a project I need to extract random elements from a list (and I need to extract a lot of them), and using "normal" methods [1] seems to be rather inefficient. Note that I have used an incorrect term, sorry. What I need, in det

[Haskell-cafe] Re: Exception handling in numeric computations

2009-03-25 Thread John Lato
> Jake McArthur writes: > >> Xiao-Yong Jin wrote: >> | The problem is that there will be many functions using such >> | a function to invert a matrix, making this inversion >> | function return Either/Maybe or packing it in a monad is >> | just a big headache. >> >> I disagree. If you try to take

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-25 Thread Lennart Augustsson
Some examples of what might happen: If you have more than one possible exception in your code, you don't know which one you will get. It can vary between compilers, optimization levels, program runs, or even evaluating the same expression within one program. If you have code that have both an inf

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-25 Thread Xiao-Yong Jin
Jonathan Cast writes: > On Tue, 2009-03-24 at 23:13 -0700, Donn Cave wrote: >> Quoth Duncan Coutts : >> >> > You must not do this. It breaks the semantics of the language. >> > >> > Other people have given practical reasons why you should not but a >> > theoretical reason is that you've defined

Re: [Haskell-cafe] STM orElse semantics

2009-03-25 Thread Peter Robinson
> "Compose two alternative STM actions (GHC only). If the first action > completes without retrying then it forms the result of the orElse. > Otherwise, if the first action retries, then the second action is > tried in its place. If both actions retry then the orElse as a whole > retries." > > What

[Haskell-cafe] STM orElse semantics

2009-03-25 Thread Tom Davies
I'm not 100% clear on the behaviour of the STM function orElse. The documentation says: "Compose two alternative STM actions (GHC only). If the first action completes without retrying then it forms the result of the orElse. Otherwise, if the first action retries, then the second action is tried i

Re: [Haskell-cafe] Re: Grouping - Map / Reduce

2009-03-25 Thread Martin Huschenbett
Dear Günther, the map can't be consumed while it is constructed. At any point during its construction you don't know for any key in the map if it will appear in the not cosumed rest of the list again. This means you can't process any entry of the map because it may change later. The only point

Re: [Haskell-cafe] The votes are in!

2009-03-25 Thread Loup Vaillant
2009/3/24 John Van Enk : > If any one seconds the motion, i'm picking up this part of the thread and > putting it in the humor section of the haskell wiki. > /jve Seconded. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mai

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread Thomas Hartman
sorry, wrong function. should be partitions [] xs = [] partitions (n:parts) xs = let (beg,end) = splitAt n xs in beg : ( case end of [] -> [] xs -> partitions parts xs) t = partitions [1,2,3] [1..10] which is not quite as nice, I admit. 2009/3/25 Thomas Hart

RE: [Haskell-cafe] Are there performant mutable Arrays in Haskell?

2009-03-25 Thread Brettschneider, Matthias
> > To make a long story short, here is the library code: > > elems arr = case bounds arr of > > (_l, _u) -> [unsafeAt arr i | i <- [0 .. numElements arr - 1] > > > > And my version: > > boundedElems arr = case bounds arr of > > (_l, _u) -> [unsafeAt arr i | i <- [1737 .. 1752]] > > > >

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread Thomas Hartman
What about import Data.List partAt n xs =  let (beg,end) = splitAt n xs  in beg : ( case end of               [] -> []               xs -> partAt n xs) t = partAt 3 [1..10] It's tail recursive (I think!) and should be pretty easy to understand even for a beginner, no? 2009/3/24 Manlio Perillo

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-25 Thread Colin Adams
2009/3/24 Jonathan Cast : > On Tue, 2009-03-24 at 22:33 +0300, Eugene Kirpichov wrote: >> Pretty cool once you know what the function does, but I must admit I >> wouldn't immediately guess the purpose of the function when written in >> this way. > > I wouldn't immediately guess the purpose of the f

Re: [Haskell-cafe] Definition of "tail recursive" wrt Folds

2009-03-25 Thread 司馬泰
wikipedia is your friend... http://en.wikipedia.org/wiki/Fold_(higher-order_function) Tammo 2009/3/25 Mark Spezzano : > Hi, > > > > Just looking at the definitions for foldr and foldl I see that foldl is > (apparently) tail recursive while foldr is not. > > > > Why? > > > > Is it because foldl d

[Haskell-cafe] Definition of "tail recursive" wrt Folds

2009-03-25 Thread Mark Spezzano
Hi, Just looking at the definitions for foldr and foldl I see that foldl is (apparently) tail recursive while foldr is not. Why? Is it because foldl defers calling itself until last whereas foldr evaluates itself as it runs? What, strictly speaking, is the definition of ”tail recurs

[Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-25 Thread Heinrich Apfelmus
Dan Piponi wrote: >> Miguel Mitrofanov wrote: >>> takeList = evalState . mapM (State . splitAt) > >> However, ironically, I stopped using them for pretty >> much the same reason that Manlio is saying. > > Are you saying there's a problem with this implementation? It's the > only one I could just