Re: [Haskell-cafe] Is there a nicer way to do this?

2008-07-06 Thread Ketil Malde
Don Stewart <[EMAIL PROTECTED]> writes: >>> splitAt n xs = (take n xs, drop n xs) >> Thanks. That is odd, though. It makes me wonder what to expect re >> optimization. Would the compiler/runtime know that splitAt could be >> done in a single pass? > Not with that definition. It would requ

[Haskell-cafe] Ode from a Haskeller to a Schemer [Was: Re: Santana on my evil ways]

2008-07-06 Thread Benjamin L . Russell
On Fri, 4 Jul 2008 15:43:38 -0400, "John D. Ramsdell" <[EMAIL PROTECTED]> wrote: >My son's nickname is Rama, so let me adopt it. I am a functional >programmer, even when I use languages such as C. Scheme facilitated >my development into a functional programmer, however, I appreciate the >benefit

Re: [Haskell-cafe] Type families versus functional dependencies question

2008-07-06 Thread Manuel M T Chakravarty
Alexey Rodriguez: On Fri, Jul 4, 2008 at 5:03 AM, Manuel M T Chakravarty <[EMAIL PROTECTED] > wrote: The problem is that blah's type is ambiguous, as f does only occur as an argument to the type family. If you'd define class Blah f a where blah :: a -> f -> T f f a (and change the r

Re: [Haskell-cafe] OpenSSL.Digest linking error: EVP_mdc2

2008-07-06 Thread Donn Cave
Quoth "Ken Takusagawa" <[EMAIL PROTECTED]>: | $ ghc --make test-hopenssl.hs -lcrypto | [1 of 1] Compiling Main ( test-hopenssl.hs, test-hopenssl.o ) | Linking test-hopenssl ... | /tmp/ken/lib/hopenssl-1.0/ghc-6.8.2/libHShopenssl-1.0.a(Digest.o): In | function `s2O8_info': | (.text+0xf

[Haskell-cafe] not for me, guv!

2008-07-06 Thread Evan Laforge
So I wrote a big email about this mysterious message I was getting, but then after some research and poking and debugging tracked it down to a dangling pointer in C that was causing a callback to point to an invalid address, which somehow worked anyway 99% of the time. That all said, I'm not total

Re: [Haskell-cafe] The state of database libraries

2008-07-06 Thread Don Stewart
prb: > > On Jul 4, 2008, at 7:54 AM, Chris Eidhof wrote: > > >1. hdbc. I'd like to connect to MySQL, so I need the ODBC backend. I > >couldn't get this to work under OS X, while I installed myodbc, > >which seems to be broken. > > FWIW, I've had good luck with the SQLite3 bindings for HDBC o

[Haskell-cafe] OpenSSL.Digest linking error: EVP_mdc2

2008-07-06 Thread Ken Takusagawa
I'm using hopenssl 1.0 from hackage. What am I doing wrong here? $ cat test-hopenssl.hs import OpenSSL.Digest main=undefined $ ghc --make test-hopenssl.hs -lcrypto [1 of 1] Compiling Main ( test-hopenssl.hs, test-hopenssl.o ) Linking test-hopenssl ... /tmp/ken/lib/hopenssl-1.0/ghc-

Re: [Haskell-cafe] The state of database libraries

2008-07-06 Thread Paul Brown
On Jul 4, 2008, at 7:54 AM, Chris Eidhof wrote: 1. hdbc. I'd like to connect to MySQL, so I need the ODBC backend. I couldn't get this to work under OS X, while I installed myodbc, which seems to be broken. FWIW, I've had good luck with the SQLite3 bindings for HDBC on MacOS X. I had a

Re: [Haskell-cafe] Associative Commutative Unification

2008-07-06 Thread Don Stewart
ramsdell0: > I'd like to write an obviously correct implementation of a unifier, a > program that when given two terms, finds a substitution that makes the > two terms equal. The phrase "obviously correct" is meant to imply > that the clarity of the code trumps efficiency. As near as I can > tell

[Haskell-cafe] Associative Commutative Unification

2008-07-06 Thread John D. Ramsdell
I'd like to write an obviously correct implementation of a unifier, a program that when given two terms, finds a substitution that makes the two terms equal. The phrase "obviously correct" is meant to imply that the clarity of the code trumps efficiency. As near as I can tell, high performance un

Re: [Haskell-cafe] extensible data types in Haskell?

2008-07-06 Thread Don Stewart
princedpw: > Hi all, > > SML conveniently contains the type "exn" which is an instance of an > "extensible data type". In other words, unlike normal data types that > are "closed" (can't admit new constructors once defined), SML's exn > type is "open," allowing programmers to keep adding new alte

Re: [Haskell-cafe] Is there anything manifestly stupid about this code?

2008-07-06 Thread Derek Elkins
To answer the question in your subject, yes! We have a complex type. Not only does that make the code simpler and more obvious and idiomatic, but it's also more efficient because for this use you'd really prefer a strict pair type for "Point", and complex is strict in it's components. On Sun, 200

[Haskell-cafe] Is there anything manifestly stupid about this code?

2008-07-06 Thread Michael Feathers
Decided a while ago to write some code to calculate the Mandelbrot set using the escape iterations algorithm. Discovered after mulling it about that I could just built it as an infinite list of infinite lists and then extract any rectangle of values that I wanted: type Point = (Double, Doub

Re: [Haskell-cafe] Is there a nicer way to do this?

2008-07-06 Thread Don Stewart
mfeathers: > Don Stewart wrote: > >mfeathers: > >> > >>segment :: Int -> [a] -> [[a]] > >>segment 0 _ = [] > >>segment _ [] = [] > >>segment n x = (take n x) : segment n (drop n x) > > > >The first set of parens can go, > > > > segment n x = take n x : segment n (drop n x) > > > >>I did a version

Re: [Haskell-cafe] Is there a nicer way to do this?

2008-07-06 Thread Evan Laforge
On Sun, Jul 6, 2008 at 5:25 PM, John Hamilton <[EMAIL PROTECTED]> wrote: > On Sun, Jul 6, 2008 at 16:45, Michael Feathers <[EMAIL PROTECTED]> wrote: >> >> >> segment :: Int -> [a] -> [[a]] >> segment 0 _ = [] >> segment _ [] = [] >> segment n x = (take n x) : segment n (drop n x) >> >> >> I did a v

[Haskell-cafe] extensible data types in Haskell?

2008-07-06 Thread David Walker
Hi all, SML conveniently contains the type "exn" which is an instance of an "extensible data type". In other words, unlike normal data types that are "closed" (can't admit new constructors once defined), SML's exn type is "open," allowing programmers to keep adding new alternatives as often as th

Re: [Haskell-cafe] Is there a nicer way to do this?

2008-07-06 Thread John Hamilton
On Sun, Jul 6, 2008 at 16:45, Michael Feathers <[EMAIL PROTECTED]> wrote: > > > segment :: Int -> [a] -> [[a]] > segment 0 _ = [] > segment _ [] = [] > segment n x = (take n x) : segment n (drop n x) > > > I did a version of this which used splitAt but I wasn't sure whether it was > going to buy me

Re: [Haskell-cafe] Is there a nicer way to do this?

2008-07-06 Thread Don Stewart
mfeathers: > > > segment :: Int -> [a] -> [[a]] > segment 0 _ = [] > segment _ [] = [] > segment n x = (take n x) : segment n (drop n x) The first set of parens can go, segment n x = take n x : segment n (drop n x) > > I did a version of this which used splitAt but I wasn't sure whether it

[Haskell-cafe] Is there a nicer way to do this?

2008-07-06 Thread Michael Feathers
segment :: Int -> [a] -> [[a]] segment 0 _ = [] segment _ [] = [] segment n x = (take n x) : segment n (drop n x) I did a version of this which used splitAt but I wasn't sure whether it was going to buy me anything re performance that would justify its ugliness. Michael _

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Brandon S. Allbery KF8NH
On 2008 Jul 6, at 16:47, Tony Morris wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Feathers wrote: zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches) groundSpeeds headings (map windShift headings) (regulations !! 2) (foldr (\|/) (tail pathDistances)) [ghy x

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Michael Feathers
Andrew Wagner wrote: Wow. Where did you come up with the stack trace? That's...impressive. Pulled it from a blog. I was actually looking for a creepy VB4 or VB5 stack trace I saw years ago that ripped through their dynamic type resolution layer. Now that would've been funny. :-) Michael

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Michael Feathers
Don Stewart wrote: I win, almost ... 13:13:18 dolio: yeah, it was ... almost ... an April 1 style post :) And yes, this was truly shocking on a number of levels. However, we have people doing a lot of weird things with Haskell these days, so its not as absurd that someone would be hacki

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Andrew Wagner
Wow. Where did you come up with the stack trace? That's...impressive. On Sun, Jul 6, 2008 at 5:07 PM, Don Stewart <[EMAIL PROTECTED]> wrote: > I win, almost ... > >13:13:18 dolio: yeah, it was ... almost ... an April 1 style post > > :) > > And yes, this was truly shocking on a number of leve

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Don Stewart
I win, almost ... 13:13:18 dolio: yeah, it was ... almost ... an April 1 style post :) And yes, this was truly shocking on a number of levels. However, we have people doing a lot of weird things with Haskell these days, so its not as absurd that someone would be hacking up a zip12 for an a

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Michael Feathers
Sorry guys. I was just bored on a Sunday afternoon so I thought I'd type up a little joke. I thought to myself "Gee, how outrageous can I make it?" 1) Using and debugging a zip12 function. 2) That fails only on 'take 5' (Brubeck fans take note) 3) Has some absurd arguments like (nub . nub)

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Tony Morris
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Feathers wrote: > > > I have some code that looks like this and I'm having trouble with > it: > > > zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd > geoCaches) groundSpeeds headings (map windShift headings) > (regulations !! 2) (f

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Paul Visschers
You're zipping 12 lists here, so how about testing each list individually? This will narrow down the problem considerably. Michael Feathers wrote: > > > I have some code that looks like this and I'm having trouble with it: > > > zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoC

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Don Stewart
mfeathers: > > > I have some code that looks like this and I'm having trouble with it: > > > zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches) > groundSpeeds headings (map windShift headings) (regulations !! 2) > (foldr (\|/) (tail pathDistances)) [ghy x | x <- [1..],

[Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Michael Feathers
I have some code that looks like this and I'm having trouble with it: zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches) groundSpeeds headings (map windShift headings) (regulations !! 2) (foldr (\|/) (tail pathDistances)) [ghy x | x <- [1..], full x] (nub . nub) arri