[Haskell-cafe] ANN: Finance-Quote-Yahoo 0.5.0

2008-02-08 Thread brad clawsie
a new version of Finance-Quote-Yahoo has been uploaded to hackage that breaks an api of the previous version for getting bulk historical quote information. specifically, notice this updated type signature: getHistoricalQuote :: QuoteSymbol -> Day -> Day -> QuoteFrequency -> IO (Maybe [HistoricalQ

Re: [Haskell-cafe] Create a list without duplicates from a list with duplicates

2008-02-08 Thread Stuart Cook
On Sat, Feb 9, 2008 at 7:36 AM, Dan Weston <[EMAIL PROTECTED]> wrote: > If order is important, the new bijective Data.Bimap class > http://code.haskell.org/~scook0/haddock/bimap/Data-Bimap.html > may be your best bet (I haven't yet tried it myself). Let me try: nub :: (Ord a) => [a] -> [a]

Re: [Haskell-cafe] Slightly Offtopic in Part

2008-02-08 Thread Dan Weston
It should be emphasized that a type needs to be inhabited by (at least one) *total* function to prove a theorem. Otherwise, you could have the following partial function purporting to prove the phony theorem that "A or B implies A": phony :: Either a b -> a phony (Left a) = a Dan Dan Weston

Re: [Haskell-cafe] Slightly Offtopic in Part

2008-02-08 Thread Dan Weston
For more details, look for a function called "orElim" in the write-up http://www.thenewsh.com/~newsham/formal/curryhoward/ Dan Ryan Ingram wrote: I'm assuming you mean the rule described in http://en.wikibooks.org/wiki/Formal_Logic/Sentential_Logic/Inference_Rules type Disj a b = Either a b

Re: [Haskell-cafe] GHC + interactive input/output

2008-02-08 Thread Jonathan Cast
On 8 Feb 2008, at 6:50 PM, Jonathan Cast wrote: On 8 Feb 2008, at 6:34 PM, Ryan Ingram wrote: import System.IO myGetLine = hFlush stdout >> getLine That fixes this issue, certainly (although it's superfluous; my program really does contain only a single call to getLine)... Nevertheless,

Re: [Haskell-cafe] Slightly Offtopic in Part

2008-02-08 Thread Stefan O'Rear
On Fri, Feb 08, 2008 at 06:47:51PM -0800, Ryan Ingram wrote: > I'm assuming you mean the rule described in > http://en.wikibooks.org/wiki/Formal_Logic/Sentential_Logic/Inference_Rules > > > type Disj a b = Either a b > > > disj_elim :: Disj a b -> (a -> c) -> (b -> c) -> c > > disj_elim (Left a)

Re: [Haskell-cafe] Slightly Offtopic in Part

2008-02-08 Thread Dan Licata
Out of context (am I missing some earlier part of this thread?) I'm not entirely sure what you mean. Are you're talking about the disjunction elim rule in intuitionistic natural deduction: Gamma |- A + B Gamma, A |- C Gamma, B |- C -- G

Re: [Haskell-cafe] GHC + interactive input/output

2008-02-08 Thread Jonathan Cast
On 8 Feb 2008, at 6:34 PM, Ryan Ingram wrote: import System.IO myGetLine = hFlush stdout >> getLine That fixes this issue, certainly (although it's superfluous; my program really does contain only a single call to getLine)... Nevertheless, it would be nice to at least have it in the stand

Re: [Haskell-cafe] Slightly Offtopic in Part

2008-02-08 Thread Ryan Ingram
I'm assuming you mean the rule described in http://en.wikibooks.org/wiki/Formal_Logic/Sentential_Logic/Inference_Rules > type Disj a b = Either a b > disj_elim :: Disj a b -> (a -> c) -> (b -> c) -> c > disj_elim (Left a) a2c b2c = a2c a > disj_elim (Right b) a2c b2c = b2c b If you know "either

Re: [Haskell-cafe] GHC + interactive input/output

2008-02-08 Thread Ryan Ingram
import System.IO myGetLine = hFlush stdout >> getLine -- ryan On 2/8/08, Jonathan Cast <[EMAIL PROTECTED]> wrote: > On 8 Feb 2008, at 5:29 PM, Philip Weaver wrote: > > > GHC certain *could* do this, but it's arguably not the right thing > > to do. For performance, the operating system buffers

[Haskell-cafe] Slightly Offtopic in Part

2008-02-08 Thread PR Stanley
Hi folks The disjunction elimination rule: I've been trying to make sense of it and I think I have had some success; however, it's far from adequate. I wonder, is there a way of demonstrating it in Haskell? A code frag with a jargon-free explanation would be mucho appreciated. Cheers, Paul __

Re: [Haskell-cafe] GHC + interactive input/output

2008-02-08 Thread Jonathan Cast
On 8 Feb 2008, at 5:29 PM, Philip Weaver wrote: GHC certain *could* do this, but it's arguably not the right thing to do. For performance, the operating system buffers writes until it is ready to write large chunks at a time. If you do not want this behavior, change the buffering mode fro

Re: [Haskell-cafe] Re: Implementing fixed-sized vectors (using datatype algebra?)

2008-02-08 Thread Bjorn Buckwalter
On Feb 6, 2008 8:47 PM, Alfonso Acosta <[EMAIL PROTECTED]> wrote: > On Feb 7, 2008 2:30 AM, Bjorn Buckwalter <[EMAIL PROTECTED]> wrote: > > Ok. Is this what people want -- one big hold-all library with > > everything, as opposed to smaller more specialized packages? I guess I > > can see advantages

Re: [Haskell-cafe] GHC + interactive input/output

2008-02-08 Thread Philip Weaver
GHC certain *could* do this, but it's arguably not the right thing to do. For performance, the operating system buffers writes until it is ready to write large chunks at a time. If you do not want this behavior, change the buffering mode from its default. - Phil On Feb 8, 2008 5:07 PM, Jonathan

Re: [Haskell-cafe] GHC + interactive input/output

2008-02-08 Thread Jonathan Cast
On 8 Feb 2008, at 4:50 PM, Brandon S. Allbery KF8NH wrote: On Feb 8, 2008, at 19:41 , Philip Weaver wrote: Your "gsi> " is buffered because there's no newline at the end. To flush the buffer and force it to be printed immediately, use 'hFlush' from the System.IO library, or use 'hSetBuffe

Re: [Haskell-cafe] GHC + interactive input/output

2008-02-08 Thread Brandon S. Allbery KF8NH
On Feb 8, 2008, at 19:41 , Philip Weaver wrote: Your "gsi> " is buffered because there's no newline at the end. To flush the buffer and force it to be printed immediately, use 'hFlush' from the System.IO library, or use 'hSetBuffering' from that same library: http://haskell.org/ghc/docs/l

Re: [Haskell-cafe] I love purity, but it's killing me.

2008-02-08 Thread Don Stewart
tomahawkins: > On 2/8/08, Emil Axelsson <[EMAIL PROTECTED]> wrote: > > I know of a few of ways to express sharing in a pure language: > > > > 1) "Observable sharing", which, in general, is unsafe. > > 2) Using Template Haskell > > 3) Matthew Naylor has done some work on "expressible sharing", which

Re: [Haskell-cafe] GHC + interactive input/output

2008-02-08 Thread Philip Weaver
Your "gsi> " is buffered because there's no newline at the end. To flush the buffer and force it to be printed immediately, use 'hFlush' from the System.IO library, or use 'hSetBuffering' from that same library: http://haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html I believe you c

[Haskell-cafe] GHC + interactive input/output

2008-02-08 Thread Jonathan Cast
$ cat > foo.c #include int main() { char s[1024]; printf("gsi> "); gets(s); printf("%s\n", s); return 0; } $ make foo cc gsi.c -o gsi $ ./foo warning: this program uses gets(), which is unsafe. gsi> hello hello $ cat > foo.hs main = do putStr "gsi> " s <- getLine putStrLn s

Re: [Haskell-cafe] I love purity, but it's killing me.

2008-02-08 Thread Tom Hawkins
On 2/8/08, Emil Axelsson <[EMAIL PROTECTED]> wrote: > I know of a few of ways to express sharing in a pure language: > > 1) "Observable sharing", which, in general, is unsafe. > 2) Using Template Haskell > 3) Matthew Naylor has done some work on "expressible sharing", which has > 4) Use a monad (bu

[Haskell-cafe] Re: Implementing fixed-sized vectors (using datatype algebra?)

2008-02-08 Thread Aaron Denney
On 2008-02-05, Alfonso Acosta <[EMAIL PROTECTED]> wrote: > On Feb 5, 2008 4:10 PM, Henning Thielemann ><[EMAIL PROTECTED]> wrote: >> >> On Fri, 1 Feb 2008, Aaron Denney wrote: >> >> > On 2008-02-01, Bjorn Buckwalter <[EMAIL PROTECTED]> wrote: >> > > If Naturals had been sufficient for me I wouldn't

Re: [Haskell-cafe] Re: problem with collection (container) class

2008-02-08 Thread Daniel Fischer
Am Freitag, 8. Februar 2008 22:14 schrieb Ben Franksen: > If it's a bug then it is probably in 6.6.1 too, it just gets hidden by the > fact that in 6.6.1 the -fglasgow-exts extensions cannot be activated > separately. If you enable one of them, you get them all. > Thanks for the info, didn't know t

[Haskell-cafe] Re: question concerning ANSI "void *"

2008-02-08 Thread Ben Franksen
Galchin Vasili wrote: > Let's take a concrete but "made up" case .. suppose we want to call > through to pthread_create and pass the (void *) argument to pthread_create > which in turn gets interpreted by the pthread that is launched. How would > one populate the C struct that is passed to the lau

[Haskell-cafe] Re: problem with collection (container) class

2008-02-08 Thread Ben Franksen
Daniel Fischer wrote: > {-# LANGUAGE MultiParamTypeClasses #-} > {-# LANGUAGE FunctionalDependencies #-} > {- # LANGUAGE FlexibleInstances # -} > module Leandro where > > data Abb a b = Branch a b (Abb a b) (Abb a b) | Leaf > > data ListAssoc a b = Node a b (ListAssoc a b) | Empty > > class Cont

[Haskell-cafe] Fwd: [pdxfunc] pdxfunc meeting: Monday, February 11, 7pm, CubeSpace (Portland, OR)

2008-02-08 Thread Justin Bailey
-- Forwarded message -- From: Igal Koshevoy <[EMAIL PROTECTED]> Date: Feb 8, 2008 12:01 PM Subject: [pdxfunc] pdxfunc meeting: Monday, February 11, 7pm, CubeSpace To: Igal Koshevoy <[EMAIL PROTECTED]> Join us at the next meeting of pdxfunc, the Portland Functional Programming Stud

Re: [Haskell-cafe] Create a list without duplicates from a list with duplicates

2008-02-08 Thread Tillmann Rendel
Dan Weston wrote: Meanwhile, here is a hand-rolled solution to order-preserving nubbing: > import Data.List(groupBy,sortBy,sort) > import Data.Maybe(listToMaybe) > > efficientNub :: (Ord a) => [a] -> [a] > efficientNub = flip zip [0..]-- carry along index > >>> sort

Re: [Haskell-cafe] Re: threads + IORefs = Segmentation fault?

2008-02-08 Thread David Roundy
On Fri, Feb 08, 2008 at 10:46:25AM +, Simon Marlow wrote: > (I'm a bit behind with haskell-cafe, sorry for not seeing this sooner...) No problem! > Yes, that should all be fine, because the IORef is only modified from one > thread, and read from the other(s). If you were modifying the IORe

Re: [Haskell-cafe] Re: Implementing fixed-sized vectors (using datatype algebra?)

2008-02-08 Thread Dan Weston
Brandon S. Allbery KF8NH wrote: On Feb 8, 2008, at 11:14 , Stefan Monnier wrote: You seem to write 12 as 1 :+ 2 instead of () :+ 1 :+ 2. But I think, the latter representation should probably be prefered. (...) How 'bout treating :+ as similar to `append' rather than similar to `cons'? Bas

Re: [Haskell-cafe] Re: Implementing fixed-sized vectors (using datatype algebra?)

2008-02-08 Thread Dan Weston
Dan Weston wrote: Brandon S. Allbery KF8NH wrote: On Feb 8, 2008, at 11:14 , Stefan Monnier wrote: You seem to write 12 as 1 :+ 2 instead of () :+ 1 :+ 2. But I think, the latter representation should probably be prefered. (...) How 'bout treating :+ as similar to `append' rather than simil

Re: [Haskell-cafe] question concerning ANSI "void *"

2008-02-08 Thread Adam Langley
On Feb 8, 2008 10:57 AM, Galchin Vasili <[EMAIL PROTECTED]> wrote: > basically I am trying to implement ioctl for the Posix library .. so a > possible signtaure would be: > > fdIoctl :: Fd -> Int -> Ptr Word 8 -> IO( Ptr Word8) Ah, ok. You could cover many of the ioctls (the ones which only t

Re: [Haskell-cafe] Create a list without duplicates from a list with duplicates

2008-02-08 Thread Dan Weston
As noted, (Data.Set.toList . Data.Set.fromList) is the best traditional solution if you don't care about order (or Data.Set.toAscList for a sorted result). If order is important, the new bijective Data.Bimap class http://code.haskell.org/~scook0/haddock/bimap/Data-Bimap.html may be your best be

Re: [Haskell-cafe] question concerning ANSI "void *"

2008-02-08 Thread Galchin Vasili
basically I am trying to implement ioctl for the Posix library .. so a possible signtaure would be: fdIoctl :: Fd -> Int -> Ptr Word 8 -> IO( Ptr Word8) Vasili On 2/8/08, Galchin Vasili <[EMAIL PROTECTED]> wrote: > > a couple of concrete examples: > > typedef struct {char a; int b; char st

Re: [Haskell-cafe] question concerning ANSI "void *"

2008-02-08 Thread Galchin Vasili
a couple of concrete examples: typedef struct {char a; int b; char str[8]} type1; typedef struct {long c; char d} type2; So to pthread_create (just an example function) we could be passing a struct of type1 or a struct of type2 .. i.e. arbitrary length and content ... I am trying to better under

Re: [Haskell-cafe] :i and :t give different types

2008-02-08 Thread Chad Scherrer
On Feb 8, 2008 9:55 AM, Simon Peyton-Jones <[EMAIL PROTECTED]> wrote: > I have not been following closely but if Don thinks there's a bug there > probably is. Can someone submit a bug report pls? Better still a patch! :-) > > Simon Ok, I filed a bug report. _

RE: [Haskell-cafe] :i and :t give different types

2008-02-08 Thread Simon Peyton-Jones
I have not been following closely but if Don thinks there's a bug there probably is. Can someone submit a bug report pls? Better still a patch! :-) Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Don Stewart | Sent: 07 February 2008 19:58 | T

Re: [Haskell-cafe] question concerning ANSI "void *"

2008-02-08 Thread Adam Langley
On Feb 8, 2008 9:13 AM, Galchin Vasili <[EMAIL PROTECTED]> wrote: > Let's take a concrete but "made up" case .. suppose we want to call through > to pthread_create and pass the (void *) argument to pthread_create which in > turn gets interpreted by the pthread that is launched. How would one > popu

Re: [Haskell-cafe] question concerning ANSI "void *"

2008-02-08 Thread Galchin Vasili
Let's take a concrete but "made up" case .. suppose we want to call through to pthread_create and pass the (void *) argument to pthread_create which in turn gets interpreted by the pthread that is launched. How would one populate the C struct that is passed to the launched pthread keeping in mind t

Re: [Haskell-cafe] Re: Implementing fixed-sized vectors (using datatype algebra?)

2008-02-08 Thread Brandon S. Allbery KF8NH
On Feb 8, 2008, at 11:14 , Stefan Monnier wrote: You seem to write 12 as 1 :+ 2 instead of () :+ 1 :+ 2. But I think, the latter representation should probably be prefered. (...) How 'bout treating :+ as similar to `append' rather than similar to `cons'? Basically treat :+ as taking 2 num

[Haskell-cafe] Re: Implementing fixed-sized vectors (using datatype algebra?)

2008-02-08 Thread Stefan Monnier
>> > You seem to write 12 as 1 :+ 2 instead of () :+ 1 :+ 2. But I think, the >> > latter representation should probably be prefered. With it, :+ always >> > has a number as its left argument and a digit as its right. Without the >> > () :+ we get ugly exceptional cases. >> > You can see this, f

Re: [Haskell-cafe] User groups meeting all over the world

2008-02-08 Thread njbartlett
Hi Neil, London HUG is not on the list because we're not meeting in the next two weeks. Rest assured we are on the wiki page though. On that note, I am looking again for topics and speaker for the next full meeting at City University. It will likely be in the middle of March. If anybody has ideas

Re: [Haskell-cafe] Re: Implementing fixed-sized vectors (using datatype algebra?)

2008-02-08 Thread Wolfgang Jeltsch
Am Donnerstag, 7. Februar 2008 16:31 schrieben Sie: > On Feb 7, 2008 4:16 PM, Wolfgang Jeltsch <[EMAIL PROTECTED]> wrote: > […] > > You seem to write 12 as 1 :+ 2 instead of () :+ 1 :+ 2. But I think, the > > latter representation should probably be prefered. With it, :+ always > > has a number

Re: [Haskell-cafe] I love purity, but it's killing me.

2008-02-08 Thread Tim Chevalier
On 2/8/08, Matthew Naylor <[EMAIL PROTECTED]> wrote: > it in for an efficient program. However, to my knowledge, it is an > unwritten rule of Haskell compilers that sharing *is* preserved, and > that they do perform *graph* reduction. Clean, a similar language to I'm not sure that programmers ou

Re: [Haskell-cafe] Mutable arrays

2008-02-08 Thread Chaddaï Fouché
Sorry for the french, I was a little bit confused... On 08/02/08, Chaddaï Fouché <[EMAIL PROTECTED]> wrote : After I changed John's code so that it worked on the same dataset as mine, I could benchmark both of them : My solution is a bit faster (but that's a very tiny difference and to be expected

Re: [Haskell-cafe] Mutable arrays

2008-02-08 Thread Chaddaï Fouché
Après avoir un peu manipulé la solution de John pour qu'elle fasse la même chose que la mienne, je peux affirmer qu'elle est légèrement moins rapide (c'est infime et normal vu que ses leftFold passent plus d'informations), mais que les deux solutions ont au moins cet avantage d'être rapides (2s sur

Re: [Haskell-cafe] Best practice for embedding files in a GHC-compiled tool?

2008-02-08 Thread Reinier Lamers
Op 7-feb-2008, om 13:53 heeft Dave Bayer het volgende geschreven: Under this extreme hypothesis, how do I embed a compressed tar file into a single file command line tool written in Haskell and compiled by GHC? Hack up a shell script or a small Haskell program to automatically generate a

Re: [Haskell-cafe] User groups meeting all over the world

2008-02-08 Thread Neil Mitchell
Hi > Fun in the afternoonLondon/UKFebruary 12 Fun in the afternoon is great, but its not really a user group - it is still primarily an academic event, although is open to everyone. There is LUG, which is the London Haskell Users Group, which should definately be

Re: [Haskell-cafe] Create a list without duplicates from a list with duplicates

2008-02-08 Thread Felipe Lessa
2008/2/8 Jed Brown <[EMAIL PROTECTED]>: > Look at Data.List: > > nub :: (Eq a) => [a] -> [a] > nub = nubBy (==) > > nubBy :: (a -> a -> Bool) -> [a] -> [a] > nubBy eq [] = [] > nubBy eq (x:xs) = x : nubBy eq (filter (\ y -> not (eq x y)) xs) And then there's also sort :: (Ord a) => [a] -> [a]

Re: [Haskell-cafe] Haskell maximum stack depth

2008-02-08 Thread Neil Mitchell
Hi > Yes, though testing stackGobbler with a large enough data set could > be problematic for the very reason we've been discsussing. Yes you are sure, or yes you tested and the results show than neilGobbler is x% slower and consume y% more memory on specific test n? > But let's say your hypothe

Re: [Haskell-cafe] Create a list without duplicates from a list with duplicates

2008-02-08 Thread Jed Brown
On 8 Feb 2008, [EMAIL PROTECTED] wrote: > Hallo! > > Let's suppose I have a list [a,b,c,d,c,d]. I'd like to write > a function that returns a new list without duplicates (in > the example [a,b,c,d]). How can I do that? What is the most > general way? I'd like to use the same function for a list o

[Haskell-cafe] Create a list without duplicates from a list with duplicates

2008-02-08 Thread [EMAIL PROTECTED]
Hallo! Let's suppose I have a list [a,b,c,d,c,d]. I'd like to write a function that returns a new list without duplicates (in the example [a,b,c,d]). How can I do that? What is the most general way? I'd like to use the same function for a list of Int or String or some other user defined data type.

Re: [Haskell-cafe] I love purity, but it's killing me.

2008-02-08 Thread Matthew Naylor
Hi, (Warning: longish message!) There is some concern, and rightly so, that observable sharing is dangerous, and that your Haskell program will explode if you use it, and perhaps even that anyone who uses it is "dirty" and should be sent to matron's for a good scrubbing! However, when used "safe

[Haskell-cafe] Re: threads + IORefs = Segmentation fault?

2008-02-08 Thread Simon Marlow
David Roundy wrote: I'm working on some new progress-reporting code for darcs, and am getting segmentation faults! :( The code uses threads + an IORef global variable to do this (with lots of unsafePerformIO). So my question for the gurus who know more about this than I do: is this safe? I th

Re: [Haskell-cafe] Draft chapters of "Real World Haskell" now publicly available

2008-02-08 Thread Wolfgang Jeltsch
Am Donnerstag, 7. Februar 2008 18:33 schrieben Sie: > Interesting. Thanks for the reply. > > It might be nice to have some performance benchmarks for all these > experimental systems, so we can compare them. I think, the most important thing is the asymptotical time behavior, e.g., whether the ti

Re: [Haskell-cafe] FP and Quality

2008-02-08 Thread Dougal Stanton
On 07/02/2008, Benjamin L. Russell <[EMAIL PROTECTED]> wrote: > - text follows immediately after this line - > Haskell vs. Ada vs. C++ vs. Awk vs. ... An Experiment > in Software Prototyping Productivity (1994), > by Paul Hudak and Mark P. Jones: > http://citeseer.ist.psu.edu/41732.html T

Re: [Haskell-cafe] I love purity, but it's killing me.

2008-02-08 Thread Henning Thielemann
On Fri, 8 Feb 2008, Tom Hawkins wrote: > I've been programming with Haskell for a few years and love it. One > of my favorite applications of Haskell is using for domain specific > languages. However, after designing a handful of DSLs, I continue to > hit what appears to be a fundamental hurdle

Re: [Haskell-cafe] I love purity, but it's killing me.

2008-02-08 Thread Bulat Ziganshin
Hello Tom, Friday, February 8, 2008, 9:33:35 AM, you wrote: > The process of converting an expression tree to a graph uses either Eq > or Ord (either derived or a custom instance) to search and build a set > of unique nodes to be ordered for execution. in similar situation, i've added hash field