Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Dan Piponi
On 8/13/07, David Roundy [EMAIL PROTECTED] wrote: Try executing: do { x - return 2; undefined; return (x*x); } in any monad you like instance Monad M where return a = M a ~(M a) = f = f a Or is that cheating? -- Dan ___ Haskell-Cafe

Re: [Haskell-cafe] Re: Re: Explaining monads

2007-08-13 Thread Dan Piponi
On 8/13/07, Benjamin Franksen [EMAIL PROTECTED] wrote: Ok, I admit defeat now ;-) Monads in general /allow/ sequencing of (certain) effects, but it is not necessary for a monad to do so. I'm sure I said that 300 or so posts ago :-) Here's an example that might help make some of this explicit.

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Dan Piponi
On 8/14/07, Jeff Polakow [EMAIL PROTECTED] wrote: One general intuition about monads is that they represent computations rather than simple (already computed) values: x :: Int -- x is an Int x :: Monad m = m Int -- x is a computation of an Int What's a computation? It

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Dan Piponi
On 8/14/07, Sebastian Sylvan [EMAIL PROTECTED] wrote: I like the very light weight analogy (which works for most practical uses of monads) that a monadic action is a recipe Many introductory programming books present the idea of a program as a recipe. Here's a recipe for computing factorials:

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Dan Piponi
On 8/14/07, Lennart Augustsson [EMAIL PROTECTED] wrote: You don't normally call x::Int a computation of an Int because there's nothing that distinguishes the value of the x from what it was before you computed it. Can you spell out exactly what you mean by this? So I prefer to regard x as a

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Dan Piponi
On 8/14/07, Sebastian Sylvan [EMAIL PROTECTED] wrote: On 14/08/07, Dan Piponi [EMAIL PROTECTED] wrote: Where do monads come in? Well I would try to distinguish between code that we write to compute values, and values which represent monadic actions when coming up with analogies. How would

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Dan Piponi
On 8/14/07, Sebastian Sylvan [EMAIL PROTECTED] wrote: Well that's easy, don't use the recipe analogy to explain code, use it for monadic values exclusively, and you avoid the confusion entirely! I don't think it's that complicated. It certainly is complicated. I think I have a good grasp of

Re: [Haskell-cafe] Why monad tutorials don't work

2007-08-14 Thread Dan Piponi
On 8/14/07, Dan Weston [EMAIL PROTECTED] wrote: Conor McBride and Ross Paterson said it best in the introduction to their paper Applicative programming with effects [1]: As von Neumann said: Young man, in mathematics you don't understand things, you just get used to them. Getting used to

Re: [Haskell-cafe] Re: Re[2]: Why monad tutorials don't work

2007-08-15 Thread Dan Piponi
On 8/15/07, Andy Gimblett [EMAIL PROTECTED] wrote: I assumed he was just trying not to sing the Spider Pig song. I've been banned from singing that around the house. And the cat version. But I was mainly thinking about how the physicist's definition of tensor needn't be accepted as an

Re: [Haskell-cafe] Bathroom reading

2007-08-15 Thread Dan Piponi
On 8/14/07, Dougal Stanton [EMAIL PROTECTED] wrote: I'm looking for cool but mind-bending examples of functional brilliance. One of my favourite examples is: http://citeseer.ist.psu.edu/hinze99functional.html Anyone who studies binomial heaps is struck by the similarity to binary arithmetic.

Re: [Haskell-cafe] Re: Re[2]: Why monad tutorials don't work

2007-08-15 Thread Dan Piponi
On 8/15/07, Dan Weston [EMAIL PROTECTED] wrote: You too could have invented Universal Algebra and Category Theory. I nominate Dan Piponi to write it and eagerly await its release! I've already started on it. Well, that's not the exact title and subject. And as an example I'll probably use

Re: [Haskell-cafe] Remember the future

2007-08-17 Thread Dan Piponi
On 8/17/07, Andrew Coppin [EMAIL PROTECTED] wrote: I've seen comments in various places that monads allow you to borrow things from the future. That sounds completely absurd to me... can anybody explain? Suppose you buy into the notion that monads sequence actions. Then consider the following

Re: [Haskell-cafe] Remember the future

2007-08-17 Thread Dan Piponi
On 8/17/07, Dan Piponi [EMAIL PROTECTED] wrote: On 8/17/07, Andrew Coppin [EMAIL PROTECTED] wrote: That sounds completely absurd to me... can anybody explain? Except...you can switch on ghc's special time travel features... On reflection I decided my example isn't very convincing. For one

Re: [Haskell-cafe] Remember the future

2007-08-18 Thread Dan Piponi
On 8/18/07, Andrew Coppin [EMAIL PROTECTED] wrote: Surely all this means is that the magical mdo keyword makes the compiler arbitrarily reorder the expression...? What mdo actually does is described here: http://www.cse.ogi.edu/PacSoft/projects/rmb/mdo.pdf My last example desugars to: test =

[Haskell-cafe] Using Apple Spotlight to search for .hs and .lhs files

2007-08-18 Thread Dan Piponi
This isn't really a Haskell question but I'm guessing some Haskell hackers have a solution. MacOS X's Spotlight doesn't seem to be able to search for text in .lhs and .hs files. But it can find text in .txt files. Is there a way of getting Spotlight to treat .lhs and .hs files like .txt files so I

Re: [Haskell-cafe] Tying the knot with unknown keys

2007-08-20 Thread Dan Piponi
On 8/20/07, David Ritchie MacIver [EMAIL PROTECTED] wrote: I was playing with some code for compiling regular expressions to finite state machines and I ran into the following problem. I've met exactly the same problem myself and you got me interested in it again. I think the tricky part isn't

Re: [Haskell-cafe] quoting in Haskell

2007-08-27 Thread Dan Piponi
On 8/27/07, Peter Verswyvelen [EMAIL PROTECTED] wrote: Look at Template Haskell. Gee coming from C++ that was the last thing I expected templates to do. It seems a bit more powerful in Haskell though! There's much in common between C++ template metaprogramming and template Haskell - they

Re: [Haskell-cafe] Haskell on the Playstation 3? :-)

2007-08-29 Thread Dan Piponi
On 8/29/07, Hugh Perkins [EMAIL PROTECTED] wrote: Well, a quick google for are graphics cards turing complete? suggests that some nVidia cards are Turing complete http://developer.nvidia.com/object/cuda.html It's a C compiler with multiprocessor streaming extensions that targets nvidia cards.

Re: [Haskell-cafe] let and fixed point operator

2007-08-30 Thread Dan Piponi
On 8/30/07, Peter Hercek [EMAIL PROTECTED] wrote: f x = let x = x * scale in let x = x + transform in g x Why are you trying to call three different things by the same name 'x' in one tiny block of code? That's very confusing and makes it hard to reason equationally about the code.

Re: [Haskell-cafe] let and fixed point operator

2007-08-30 Thread Dan Piponi
On 8/30/07, Andrew Coppin [EMAIL PROTECTED] wrote: Obviously you might very well have *meant* to write x = f x. But would it be possible to add some kind of optional compiler warning to find such assignments? The thing that convinced me to learn Haskell in the first place was the fact that you

Re: [Haskell-cafe] let and fixed point operator

2007-08-30 Thread Dan Piponi
On 8/30/07, Andrew Coppin [EMAIL PROTECTED] wrote: Yeah, but... programs aren't like mathematics. I know people claim that they are, but they aren't. But the raison d'etre of Haskell is to make programming more like mathematics. That motivates everything from the fact that it's a declarative

Re: [Haskell-cafe] let and fixed point operator

2007-08-30 Thread Dan Piponi
On 8/30/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dan Piponi writes: In Haskell, there is no box. Well, there are boxes... But there also thunks and latent, yet-unevaluated graphs... But the point of Haskell is to provide an abstraction that hides these details from you. (Though

Re: [Haskell-cafe] [Off topic] Proving an impossibility

2007-09-04 Thread Dan Piponi
On 9/3/07, Vimal [EMAIL PROTECTED] wrote: Hi In my Paradigms of Programming course, my professor presents this piece of code: while E do S if F then break end T end This is seriously offtopic but kinda fun anyway... There's a nice formalism for investigating this kind of

Re: [Haskell-cafe] Extending the idea of a general Num to other types?

2007-09-05 Thread Dan Piponi
On 9/5/07, Ketil Malde [EMAIL PROTECTED] wrote: On Wed, 2007-09-05 at 08:19 +0100, Simon Peyton-Jones wrote: Error message from GHCi: test/error.hs:2:8: No instance for (Num String) arising from use of `+' at test/error.hs:2:8-17 Possible fix: add an instance

Re: [Haskell-cafe] turning an imperative loop to Haskell

2007-09-06 Thread Dan Piponi
On 9/6/07, Dougal Stanton [EMAIL PROTECTED] wrote: On 06/09/07, Sebastian Sylvan [EMAIL PROTECTED] wrote: [2,3,4,9,16,29,54,99,182,335] -- what's this? Two times this: http://www.research.att.com/~njas/sequences/A000213 plus this: http://www.research.att.com/~njas/sequences/A001590 plus two

Re: [Haskell-cafe] ANNOUNCE: xmonad 0.3

2007-09-06 Thread Dan Piponi
On 9/5/07, Max Vasin [EMAIL PROTECTED] wrote: 2007/9/5, Peter Verswyvelen [EMAIL PROTECTED]: Looks really nice, but if I understand it correctly it is specific for X, so does not work on Windows? This kind of programs is impossible in Windows. Of cause you can use X server for Windows and

Re: [Haskell-cafe] Can somebody give any advice for beginners?

2007-09-11 Thread Dan Piponi
On 9/11/07, Andrew Coppin [EMAIL PROTECTED] wrote: you can fall down a monad and not be able to escape... It's not so bad. It's in the nature of monads that after you've fallen in once, you can never get trapped any deeper. -- Dan ___ Haskell-Cafe

Re: [Haskell-cafe] Re: Is take behaving correctly?

2007-09-12 Thread Dan Piponi
On 9/12/07, PR Stanley [EMAIL PROTECTED] wrote: The same should apply to head and tail. head or tail of [] should be Disagree, strongly. Its not even possible for head, What's the logic behind this? You don't need anything sophisticated for this. What possible total function could have

Re: [Haskell-cafe] Re: Type-Marking finite/infinte lists?

2007-09-16 Thread Dan Piponi
On 9/16/07, apfelmus [EMAIL PROTECTED] wrote: But unfortunately, finiteness is a special property that the type system cannot guarantee. The above type signature for cons doesn't work since the following would type check bad :: a - List Nonempty Finite a bad x = let xs = cons x xs in

Re: [Haskell-cafe] Desugaring of infix operators is (always?) the wrong way round

2007-09-25 Thread Dan Piponi
On 9/25/07, Brian Hulley [EMAIL PROTECTED] wrote: ...I seem to dimly recall that there is a natural language somewhere that also uses it but I can't remember which one. Every permutation of [S,V,O] appears in 'nature': http://en.wikipedia.org/wiki/Word_order. Also, a problem might be that it

Re: [Haskell-cafe] unsafePerformIO: are we safe?

2007-09-26 Thread Dan Piponi
On 9/26/07, Lennart Augustsson [EMAIL PROTECTED] wrote: Things can go arbitrarily wrong if you misuse unsafePerformIO, you can even subvert the type system. So...if I was in a subversive kind of mood (speaking hypothetically), what would I have to do? -- Dan On 9/26/07, Jorge Marques

Re: [Haskell-cafe] Type-level arithmetic

2007-10-06 Thread Dan Piponi
On 10/6/07, Andrew Coppin [EMAIL PROTECTED] wrote: I've seen quite a few people do crazy things to abuse the Haskell type system in order to perform arithmetic in types. How did you know precisely what I was doing at this moment in time? Stuff the type system was never ever intended to do.

Re: [Haskell-cafe] pi

2007-10-09 Thread Dan Piponi
On 10/9/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: So, you assume that acos should have a *default* implementation in the Floating class? Propose it, please. I don't think the proposal makes any such assumption. It implies only that *if* you provide acos, pi will be provided for you

Re: [Haskell-cafe] pi

2007-10-09 Thread Dan Piponi
On 10/9/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Yes, sorry, I slipped... I was so against the acos(-1) /or atan(...)/ solution, that I wrote anything... +1, Honest -- Dan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] pi

2007-10-10 Thread Dan Piponi
Jules Bean said: If it is true of many Floating instances that (atan 1 * 4) is an accurate way to calculate pi (and it appears to be 'accurate enough' for Float and Double, on my computer) then adding it as a default doesn't appear to do any harm. Maybe this is the wrong point of view, but I

Re: [Haskell-cafe] Re: Type-level arithmetic

2007-10-12 Thread Dan Piponi
Steve said: How, then, is that any different from a general-purpose programming language? You're just drawing the line in the sand in a different place. In a way it is like drawing a line in sand. But that's a useful thing to do for a bunch of reasons. (1) When developing code, you'd like to

Re: [Haskell-cafe] Re: Type-level arithmetic

2007-10-12 Thread Dan Piponi
On 10/12/07, Brandon S. Allbery KF8NH [EMAIL PROTECTED] wrote: He wants to write entire programs in the type system, something like the crazies who write programs in C++ templates such that template expansion does all the work at compile time Crazies? :-)

Re: [Haskell-cafe] Pixel plotter

2007-10-14 Thread Dan Piponi
Andrew said: Oh, and the irony of using OpenGL (an API of unimaginable complexity) just to write pixels to the screen. Isn't that kind of like using a thermonuclear device to crack a nut? Saying that using OpenGL to write pixels to the screen is like using a thermonuclear device to crack a

Re: [Haskell-cafe] Let's do ListT right, finally

2007-10-14 Thread Dan Piponi
On 10/14/07, Yitzchak Gale [EMAIL PROTECTED] wrote: Not very much, I suspect. That monad really is broken - it's not a monad at all. Depending on your point of view, ListT isn't broken. It correctly transforms commutative monads into monads. The problem is that you can't express commutative

Re: [Haskell-cafe] Let's do ListT right, finally

2007-10-14 Thread Dan Piponi
On 10/14/07, Yitzchak Gale [EMAIL PROTECTED] wrote: Interesting. What do you mean by a commutative monad? It can't be a monad with some sort of additional commutative law, because the old ListT doesn't even satisfy the monad laws. Or does it in some sense? If m is a commutative monad, then

[Haskell-cafe] Functional Programming Books

2007-10-16 Thread Dan Piponi
I was just putting together my Amazon wish list and was wondering if there are any great books on Haskell and/or functional programming that people think are must-reads. Okasaki's Purely Functional Programming, Pierce's Types and Programming Languages are frequent recommendations. Smullyan's To

Re: [Haskell-cafe] Do you trust Wikipedia?

2007-10-17 Thread Dan Piponi
The mathematics is probably the most reliable part of Wikipedia. -- Dan On 10/17/07, PR Stanley [EMAIL PROTECTED] wrote: Hi Do you trust mathematical materials on Wikipedia? Paul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] Re: [Haskell] Image manipulation

2007-10-30 Thread Dan Piponi
the potential for a nice and efficient image processing library that inherits its laziness directly from Haskell. On 10/30/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dan Piponi adds to a short exchange: jerzy.karczmarczuk: [iso-8859-1] Bj�rn Wikstr�m writes: Hi! I have lots and lots

Re: [Haskell-cafe] Re: Why can't Haskell be faster?

2007-10-31 Thread Dan Piponi
On 10/31/07, Neil Mitchell [EMAIL PROTECTED] wrote: in the long run Haskell should be aiming for equivalence with highly optimised C. Really, that's not very ambitious. Haskell should be setting its sights higher. :-) When I first started reading about Haskell I misunderstood what currying was

Re: [Haskell-cafe] ARM back end?

2007-11-02 Thread Dan Piponi
On 11/2/07, Greg Fitzgerald [EMAIL PROTECTED] wrote: Anybody know of an ARM back end for any of the Haskell compilers? This version of hugs worked on my (ARM based) NSLU2: http://ipkgfind.nslu2-linux.org/details.php?package=hugsofficial=format= - Dan

Re: [Haskell-cafe] Fibbonachi numbers algorithm work TOO slow.

2007-11-07 Thread Dan Piponi
There are some nice formulae for the Fibonacci numbers that relate f_m to values f_n where n is around m/2. This leads to a tolerably fast recursive algorithm. Here's a complete implementation: fib 0 = 0 fib 1 = 1 fib 2 = 1 fib m | even m = let n = m `div` 2 in fib n*(fib (n-1)+fib (n+1))

[Haskell-cafe] Haskell performance question

2007-11-08 Thread Dan Piponi
I see lots of shootout examples where Haskell programs seem to perform comparably with C programs, but I find it hard to reproduce anything like those figures when testing with my own code. So here's a simple case: I have this C program: #include stdio.h #define n 1 double a[n]; int

Re: [Haskell-cafe] Haskell performance question

2007-11-08 Thread Dan Piponi
On Nov 8, 2007 2:48 PM, Duncan Coutts [EMAIL PROTECTED] wrote: You really do not need happy to build ghc. Just ignore the extralibs tarball. Well that was the crucial fact I needed. 6.8.1 is now built. ghci doesn't work, it complains about an unknown symbol '_environ' in HSbase-3.0.0.0.o but I

Re: [Haskell-cafe] Haskell performance question

2007-11-08 Thread Dan Piponi
On Nov 8, 2007 11:34 AM, Jason Dusek [EMAIL PROTECTED] wrote: Can you show us your compilation options and timings? I was simply using -O3. I tried a bunch of other flags (copied from the shootout examples) but they made no appreciable difference. I was getting about 1.5s for the Haskell

Re: [Haskell-cafe] Haskell performance question

2007-11-08 Thread Dan Piponi
Bulat, The strictness gave me something like a 10% performance increase making the Haskell code more than 10 times slower than the C. Is this the right type of array to use for performance? -- Dan On Nov 8, 2007 10:36 AM, Bulat Ziganshin [EMAIL PROTECTED] wrote: Hello Dan, Thursday, November

Re: [Haskell-cafe] Haskell performance question

2007-11-08 Thread Dan Piponi
Mikhail, main = do print $ foldl' (+) 0 $ take 1 [1.0,1.0..] works 10 times faster than your C version. You just need to adapt to the radically different style of programming. My wasn't intended to represent the problem that I'm trying to solve, but the approach I want to take.

Re: [Haskell-cafe] Haskell performance question

2007-11-08 Thread Dan Piponi
On Nov 8, 2007 11:24 AM, Thomas Schilling [EMAIL PROTECTED] wrote: Wow. You should *really* try using GHC 6.8.1: I was hoping you weren't going to say that :-) As soon as I find a suitable 64-bit Intel binary for MacOSX, or can bootstrap my way out of happy needing happy in my attempted source

Re: [Haskell-cafe] Haskell performance question

2007-11-08 Thread Dan Piponi
On Nov 8, 2007 11:36 AM, Paul Brown [EMAIL PROTECTED] wrote: All that said, I'm not sure where I got the GHC that I used to build the 6.6.1 via MacPorts; I think it shipped with MacOS once upon a time. sudo port install ghc . . . configure: error: GHC is required unless bootstrapping from .hc

Re: [Haskell-cafe] Haskell performance question

2007-11-08 Thread Dan Piponi
On Nov 8, 2007 12:16 PM, Don Stewart [EMAIL PROTECTED] wrote: If you can post the code somewhere, that would be great, with examples of how to reproduce your timings. The code is exactly what I posted originally (but nore that n is 10 times larger in the C code). I compiled using ghc -O3 -o

Re: [Haskell-cafe] Haskell performance question

2007-11-08 Thread Dan Piponi
On Nov 8, 2007 12:36 PM, Don Stewart [EMAIL PROTECTED] wrote: dpiponi: Can you start by retrying with flags from the spectral-norm benchmark: http://shootout.alioth.debian.org/gp4/benchmark.php?test=spectralnormlang=ghcid=0 Actually, that was my starting point for investigating how to

Re: Re[2]: [Haskell-cafe] Haskell performance question

2007-11-09 Thread Dan Piponi
On Nov 8, 2007 10:28 PM, Bulat Ziganshin [EMAIL PROTECTED] wrote: just for curiosity, can you try to manually unroll loop and see results? I don't get any noticeable performance change when I unroll the loop by 2 by hand. I suspect that on a modern CPU loop unrolling probably isn't that much

Re: [Haskell-cafe] Sinus in Haskell

2007-11-09 Thread Dan Piponi
On Nov 9, 2007 11:30 AM, Brent Yorgey [EMAIL PROTECTED] wrote: More generally, this is due to the fact that floating-point numbers can only have finite precision This popped up on reddit recently: http://blogs.sun.com/jag/entry/transcendental_meditation . Interestingly, AMD did apparently

Re: [Haskell-cafe] Somewhat random history question - chicken and egg

2007-11-11 Thread Dan Piponi
This isn't a question specific to ghc. In general, the process of bootstrapping compilers and porting them to new platforms can be described by T-diagrams. When I did a web search on T-diagrams the first hit I found,

Re: [Haskell-cafe] Weird ghci behaviour?

2007-11-12 Thread Dan Piponi
... linking ... done. Ok, modules loaded: Main. Prelude Main main 1 Prelude Main x interactive:1:0: Not in scope: `x' Prelude Main Leaving GHCi. --- On Jul 23, 2007 10:46 AM, Dan Piponi [EMAIL PROTECTED] wrote: Ian said: Can you please give

Re: [Haskell-cafe] Re: Weird ghci behaviour?

2007-11-12 Thread Dan Piponi
On Nov 12, 2007 1:59 PM, Henning Thielemann [EMAIL PROTECTED] wrote: See http://www.haskell.org/ghc/docs/latest/html/users_guide/interactive-evaluation.html I guess the key sentence is: For technical reasons, GHCi can only support the *-form for modules which are interpreted, so compiled

Re: [Haskell-cafe] Re: Weird ghci behaviour?

2007-11-13 Thread Dan Piponi
On Nov 13, 2007 3:00 AM, Simon Peyton-Jones [EMAIL PROTECTED] wrote: Dan, can you suggest any words we could add to the documentation that would have prevented you stumbling? I guess the thing that would have helped best would have been an error message like 'x' not in scope,

Re: [Haskell-cafe] let vs. where

2007-11-13 Thread Dan Piponi
On Nov 13, 2007 1:24 PM, Ryan Ingram [EMAIL PROTECTED] wrote: I tend to prefer where, but I think that guards function declarations are more readable than giant if-thens and case constructs. Up until yesterday I had presumed that guards only applied to functions. But I was poking about in the

Re: [Haskell-cafe] Re: Hit a wall with the type system

2007-11-29 Thread Dan Piponi
On Nov 28, 2007 9:20 PM, Chris Smith [EMAIL PROTECTED] wrote: I intend to naively treat each function as being from the reals to the reals, and then take advantage of the fact (which is proven by the type system in the code I posted) that when the derivative is evaluated at integer inputs for

Re: [Haskell-cafe] Re: Re: Hit a wall with the type system

2007-11-29 Thread Dan Piponi
Chris, So I want the parameter to be more restricted. No one is going to write a function that *only* works on AD types. But exporting AD doesn't force people to write functions that work on AD types, people can write whatever functions they like. They're only constrained if they want to pass

Re: [Haskell-cafe] Re: Re: Re: Hit a wall with the type system

2007-11-29 Thread Dan Piponi
Chris, I could change my implementation; I could use Jerzy's implementation...launch Mathematica... But all of these could be implemented by introducing a different type constructor called AD for each one. You could switch the implementation of AD on the user and they wouldn't have to change a

Re: [Haskell-cafe] do

2007-12-03 Thread Dan Piponi
On Dec 3, 2007 1:09 PM, Denis Bueno [EMAIL PROTECTED] wrote: I don't think I can conclude that there are *no* reasons to teach the do-notation first. I just think that it is more instructive to teach it later. It's standard in mathematics teaching, when introducing a mathematical structure

Re: [Haskell-cafe] Re: do

2007-12-03 Thread Dan Piponi
On Dec 3, 2007 3:54 PM, Ben Franksen [EMAIL PROTECTED] wrote: I don't buy this. As has been noted by others before, IO is a very special case, in that it can't be defined in Haskell itself, and there is no evaluation function runIO :: IO a - a. I'm not sure what a function of type m a - a has

[Haskell-cafe] Looking for smallest power of 2 = Integer

2007-12-03 Thread Dan Piponi
Is there anything in any of the interfaces to Integer that will allow me to quickly find the highest bit set in an Integer? If not, does anyone have any recommendations for how to do it efficiently. There are some obvious things that come to mind but which might involve quite a bit of useless

Re: [Haskell-cafe] IO is a bad example for Monads [was: do]

2007-12-03 Thread Dan Piponi
On Dec 3, 2007 6:36 PM, Ben Franksen [EMAIL PROTECTED] wrote: then the special features of IO will remain associated with monads in general, leading to a whole jumble of completely wrong ideas about them. As I only learnt about monads a couple of years ago, the process is still fresh in my

Re: [Haskell-cafe] Looking for smallest power of 2 = Integer

2007-12-03 Thread Dan Piponi
On Dec 3, 2007 9:10 PM, Don Stewart [EMAIL PROTECTED] wrote: Is there anything in any of the interfaces to Integer that will allow me to quickly find the highest bit set in an Integer? Well, you could use testBit, which is pretty efficient, But testBit tests only one bit at a time. To prove

Re: [Haskell-cafe] Looking for smallest power of 2 = Integer

2007-12-03 Thread Dan Piponi
On Dec 3, 2007 9:32 PM, Sterling Clover [EMAIL PROTECTED] wrote: if all else fails, be determined by unpacking it into the primitives, which are (# Int#, ByteArr# #) with the Int# as the number of limbs of the integer, as well as its sign. That's the answer I'm looking for, thanks. -- Dan

Re: [Haskell-cafe] Looking for largest power of 2 = Integer

2007-12-04 Thread Dan Piponi
On Dec 3, 2007 10:05 PM, David Benbennick [EMAIL PROTECTED] wrote: Could you please post your code here when you're done? I'd be interested to see the final result. This is just experimental code I'm playing with in order to implement exact real arithmetic, so there'll never be a final result

Re: [Haskell-cafe] Looking for largest power of 2 = Integer

2007-12-04 Thread Dan Piponi
There's a bit of work required to make this code good enough for general consumption, and I don't know much about Haskell internals. (1) What is the official way to find the size of a word? A quick look at 6.8.1's base/GHC/Num.lhs reveals that it uses a #defined symbol. (2) Is it safe to assume

Re: [Haskell-cafe] IO is a bad example for Monads

2007-12-10 Thread Dan Piponi
On Dec 10, 2007 4:51 AM, Daniel Fischer [EMAIL PROTECTED] wrote: Am Montag, 10. Dezember 2007 10:36 schrieb Ketil Malde: Daniel Fischer [EMAIL PROTECTED] writes: Various other people write: ... lots of talk about monads and IO ... When someone comes to me and says I have this Python

Re: [Haskell-cafe] IO is a bad example for Monads

2007-12-10 Thread Dan Piponi
On Dec 10, 2007 11:00 AM, Henning Thielemann [EMAIL PROTECTED] wrote: Does Haskell need quickdirty hackers? The question isn't Does Haskell need quickdirty hackers? It's would we get better software (using your favourite metric) if we put Haskell into the hands of quick and dirty hackers?. I

Re: [Haskell-cafe] #haskell works

2007-12-14 Thread Dan Piponi
On Dec 14, 2007 12:12 PM, Andrew Coppin [EMAIL PROTECTED] wrote: Today, with a few import statements and compiler switches, the exact same code takes 0.05 seconds. Tomorrow, who knows? Maybe I'm being overly optimistic, but... ;-) There have been some great improvements in array handling

[Haskell-cafe] Suitable structure to represents lots of similar lists

2010-04-07 Thread Dan Piponi
I have a situation where I have a bunch of lists and I'll frequently be making new lists from the old ones by applying map and filter. The map will be applying a function that's effectively the identity on most elements of the list, and filter will be using a function that usually gives True. This

Re: [Haskell-cafe] Nomic game in Haskell

2010-04-15 Thread Dan Piponi
Dupont asked: do you know Nomic? It's a fabulous and strange game where you have the right to change the rules in the middle of the game! I know nomic, but as has been pointed out, it's too wide-ranging to be captured in Haskell. So how about a game played in the Haskell type system where

[Haskell-cafe] Re: Nomic game in Haskell

2010-04-15 Thread Dan Piponi
On Thu, Apr 15, 2010 at 4:58 PM, Ashley Yakeley ash...@semantic.org wrote: type Board a b c d e f g h i =  Either (Three a b c)  (Either (Three d e f)  (Either (Three g h i)  (Either (Three a d g)  (Either (Three b e h)  (Either (Three c f i)  (Either (Three a e i)  (Either (Three c e g)

Re: [Haskell-cafe] Suggestions For An Intro To Monads Talk.

2010-08-03 Thread Dan Piponi
On Tue, Aug 3, 2010 at 2:51 PM, aditya siram aditya.si...@gmail.com wrote: I am doing an Intro To Monads talk in September [1]. ...what would you stay away from. Some things to stay away from: http://byorgey.wordpress.com/2009/01/12/abstraction-intuition-and-the-monad-tutorial-fallacy/

Re: [Haskell-cafe] what are the points in pointsfree?

2006-12-16 Thread Dan Piponi
'Point free' is standard mathematical terminology for nothing more than the style of defining functions without making direct reference to the elements the functions act on. This style is exemplified by category theory and the reason it's called 'point free' rather than 'element free' is that

Re: [Haskell-cafe] Strange type behavior in GHCi 6.4.2

2006-12-19 Thread Dan Piponi
On 12/2/06, Chris Kuklewicz [EMAIL PROTECTED] wrote: Grady Lemoine wrote: I've been playing around with Dan Piponi's work on automatic differentiation... I played with such things, as seen on the old wiki: http://haskell.org/hawiki/ShortExamples_2fSymbolDifferentiation I missed this while I

Re: [Haskell-cafe] Haskell Side Effect

2006-12-20 Thread Dan Piponi
On 12/20/06, Bernie Pope [EMAIL PROTECTED] wrote: (Since learning Haskell, I can now count in Spanish! See: one in Spanish, ... Ashley Yakeley) in Spanish I notice you're using the assumption that Spanish is a Monad so that Double Spanish can be mapped back into Spanish.

Re: [Haskell-cafe] Re: IO in lists

2007-01-22 Thread Dan Piponi
Magnus Therning asked: but how do I go about creating a finite list, e.g. a list that ends as soon as 'q' is pressed? A slightly different approach that doesn't use anything unsafe: What you want is to return something like an IO [Char] but it needs to be able to interleave IO. A list of

Re: [Haskell-cafe] Re: IO in lists

2007-01-23 Thread Dan Piponi
On 1/23/07, Yitzchak Gale [EMAIL PROTECTED] wrote: You have written a great explanation of how ListT works by writing out its definitions in an interesting way! I put quite a bit of time into understanding why the old ListT isn't a monad [1]. But I thought I didn't yet understand the new one.

Re: [Haskell-cafe] Re: IO in lists

2007-01-23 Thread Dan Piponi
Yitzchak, Hmm, I thought it was the old one... No, definitely the new one. The old one is: newtype ListT m a = ListT { runListT :: m [a] } which treats the entire list as one uninterleavable lump. The new one is: data MList' m a = MNil | a `MCons` MList m a type MList m a = m (MList' m

Re: [Haskell-cafe] Is Excel the most used -- and fucntional -- programming lanuage on Earth?

2007-01-30 Thread Dan Piponi
On 1/30/07, Lennart Augustsson [EMAIL PROTECTED] wrote: Excel is what I like to call a 0:th order functional language, i.e., you can't even define functions, just values. :) Every cell with an expression in Excel is a function. The problem is that the domains and codomains of these functions

Re: [Haskell-cafe] Is Excel the most used -- and fucntional -- programming lanuage on Earth?

2007-01-31 Thread Dan Piponi
On 1/31/07, Lennart Augustsson [EMAIL PROTECTED] wrote: I think you're using a somewhat non-standard definition of function. let x = 5 y = x + 2 z = x * y ... Would you call y and z functions? Ah...we don't disagree on what a function is, I'm just parsing spreadsheets

Re: [Haskell-cafe] Re: How did you stumble on Haskell?

2007-02-06 Thread Dan Piponi
I've always found recursive solutions to problems elegant and I've always been fed up of people telling me that I should rewrite recursive solutions iteratively. (Annoying as it is, many people do that.) I complained about this on K5 and solicited some opinions from others on whether or not they

Re: [Haskell-cafe] Proposal: simple interface to libraries Haddock

2007-03-02 Thread Dan Piponi
dmhouse said: Hoogle might give me two dozen results when I roughly know the name of a function, but this isn't what I want. Agreed. I would *love* to have the interface you propose and I think it would make a significant difference to the ease of writing Haskell code. -- Dan

Re: [Haskell-cafe] A question about monad laws

2008-02-11 Thread Dan Piponi
IOn Feb 11, 2008 9:46 AM, Miguel Mitrofanov [EMAIL PROTECTED] wrote: It's well known that ListT m monad violates this law in general (though it satisfies it for some particular monads m). For example, I went through this example in quite a bit of detail a while ago and wrote it up here:

Re: [Haskell-cafe] Functional programmer's intuition for adjunctions?

2008-03-04 Thread Dan Piponi
Edsko asked: Is there an intuition that can be used to explain adjunctions to functional programmers, even if the match isn't necessary 100% perfect (like natural transformations and polymorphic functions?). I think there's a catch because many interesting examples of adjunctions involve

Re: [Haskell-cafe] IO () and IO [()]

2008-03-10 Thread Dan Piponi
On Mon, Mar 10, 2008 at 3:11 PM, Paulo J. Matos [EMAIL PROTECTED] wrote: I would like to know if in fact there's any difference in practice between (), [()], i.e. if in practice the difference matters. The type [()] is very similar to the type Integer and it's quite different from () because

Re: [Haskell-cafe] [GSoC] A data parallel physics engine

2008-03-12 Thread Dan Piponi
2008/3/12 Jed Brown [EMAIL PROTECTED]: It would be a shame to ...miss the very important point that a matrix is nothing more than a linear transformation between finite dimensional spaces. I rate this obvious seeming fact as one of the most important things I've learnt about numerical

Re: [Haskell-cafe] [GSoC] A data parallel physics engine

2008-03-12 Thread Dan Piponi
On Wed, Mar 12, 2008 at 2:33 PM, Andrew Coppin [EMAIL PROTECTED] wrote: Hanging around here, you really feel like you're at the cutting edge of... something... heh. Another approach isn't to target a CUDA back end for Haskell but to write an array library that builds computations that can

Re: [Haskell-cafe] Type system

2008-03-14 Thread Dan Piponi
On Fri, Mar 14, 2008 at 11:50 AM, Andrew Coppin [EMAIL PROTECTED] wrote: Haskell has an expressive and powerful type system - which I love. It also has a seemingly endless list of weird and obscure type system extensions...And yet, none of this happens in any other programming language I've

Re: [Haskell-cafe] Re: Function Precedence

2008-04-02 Thread Dan Piponi
On Tue, Apr 1, 2008 at 2:07 PM, PR Stanley [EMAIL PROTECTED] wrote: All you'd have to do is to give the inner most function the highest precdence What's the innermost function in f g x here? test :: (a - b - c) - a - b - c test f g x = f g x -- Dan

Re: [Haskell-cafe] MonadPlus

2008-05-09 Thread Dan Piponi
Andrew asked, ...so it's a kind of choice operator? Run all actions until you get to one that succeeds and return the result from that? The eternal bit of trickiness for Haskell is that type classes group often together things that people don't immediately see as similar - monads probably

Re: [Haskell-cafe] MonadPlus

2008-05-09 Thread Dan Piponi
Miguel said: Well, that's the whole point of mathematics, isn't it? Abstraction is common to mathematics and computing. But in computing the abstraction often follows lines that seem obvious. For example a GUI library might have a Widget class and people can immediately identify various regions

Re: [Haskell-cafe] Copy on read

2008-05-13 Thread Dan Piponi
On Sat, May 10, 2008 at 7:20 AM, Neil Mitchell [EMAIL PROTECTED] wrote: Jurriaan Hage and Stefan Holdermans. Heap recycling for lazy languages. In John Hatcliff, Robert Glück, and Oege de Moor, editors, _Proceedings of the 2008 ACM SIGPLAN Symposium on Partial Evaluation and

  1   2   3   >