Re: [Haskell-cafe] implementing a csv reader

2006-08-23 Thread Andy Elvey
On Tue, 2006-08-22 at 11:59 +0200, Tamas K Papp wrote:
 On Tue, Aug 22, 2006 at 11:26:45AM +0200, Henning Thielemann wrote:
 
See also
   http://www.xoltar.org/languages/haskell.html
   http://www.xoltar.org/languages/haskell/CSV.hs
 
 Thanks.  Haskell is incredibly neat ;-)
 
 Now I need to find something else for practice.  Is there anything
 related to data analysis/statistics that is lacking is Haskell? 
 
 Best,
 
 Tamas

Maybe a crosstab app? Say, read in some csv data and do a crosstab of
it. 

I was looking at doing one myself quite a while back, but I'm an
*ultra-newbie* when it comes to Haskell, and such an app would be a real
handful for me... :-) 

I don't know if it'll help at all (as Python is very different to
Haskell) but here's a link to a Python recipe which does this - 

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/334695

A Haskell equivalent would (imo) be a *great* example/appetiser for
Haskell. Very useful for newbies too, as even for a simple thing like
reading data line-by-line, it's really useful to have an
easy-to-understand example. A crosstab app mightn't be that easy to
_do_, but I think it would be easy to understand.  

Just my 2c worth ...
- Andy  




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


Re: [Haskell-cafe] Re: type synonym liberalization (was class [] proposal)

2006-08-23 Thread Bulat Ziganshin
Hello Arie,

Wednesday, August 23, 2006, 2:54:54 AM, you wrote:

 With the proper interpretation, type synonyms like
 type ABlockStream = BlockStream b = b
 type AMemoryStream = MemoryStream m = m

 How does your proposal compare to introducing existential types proper? As in

   type ABlockStream = exists b. BlockStream b = b

existential variables pack dictionary inside the data item (object)
itself, like in the OOP languages. so this the _semantic_ change.
Brandon's idea is just _syntax_ sugar, one of the possible ways to
simplify writing of signatures for regular Haskell polymorphic
functions, what pass dictionaries apart of objects

read the http://haskell.org/haskellwiki/OOP_vs_type_classes
and look for existential there


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


RE: [Haskell-cafe] Re: Memoizing longest-common-subsequence

2006-08-23 Thread Bayley, Alistair
 From: Jared Updike [mailto:[EMAIL PROTECTED] 
 
 Thanks for posting the code. It works on pretty large data sets (for
 example, a thousand Strings each) and I have a hunch that if I use
 Data.ByteString it would even work fast enough on my quarter meg text
 files (split on words, ~40,000 and ~50,000 words each) to use in place
 of GNU sdiff or diff. Did you use FastPackedString or ByteString to
 get performance you alluded to?


You'll notice that the primary interface is:
  diff :: Eq a = [a] - [a] - [Modification a]

So it's not optimised for any kind of String input.

The performance I'm alluding to is not something I've tested with any rigor, or 
even metrics to support. I simply needed to compare a couple of large text 
files which GNU diff didn't handle (I think when the input is over a certain 
size it breaks it into chunks and diffs the chunks). I tried this code, and it 
did the job in a reasonable time (my PC has 1G of memory, and that helps when 
the input lists have to reside entirely in memory). That was using naïve 
String-IO too, so there might well be some mileage in a FPS-specific 
implementation.

I profiled the code by generating large inputs in memory, and then invoking the 
various interfaces, so as to isolate the testing from IO performance. And that 
was just to find the performance hotspots in the algorithm, not to compare 
against other diff implementations.

Alistair
*
Confidentiality Note: The information contained in this message,
and any attachments, may contain confidential and/or privileged
material. It is intended solely for the person(s) or entity to
which it is addressed. Any review, retransmission, dissemination,
or taking of any action in reliance upon this information by
persons or entities other than the intended recipient(s) is
prohibited. If you received this in error, please contact the
sender and delete the material from any computer.
*
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re[2]: class [] proposal Re: [Haskell-cafe] One thought: Num to 0as ? to list?

2006-08-23 Thread Malcolm Wallace
  it's because you not programmed a lot with type classes. if you
  start, you will soon realize that type signatures with classes are
  just unreadable. just look at sources of my streams library
 
 copyStream :: (BlockStream h1, BlockStream h2, Integral size)
= h1 - h2 - size - IO ()

I know this is probably just a personal preference, but I have to say
that this syntax (the canonical Haskell'98 one) is by far the most
readable and instantly clear of any of the alternatives that have been
suggested in this thread:

copyStream :: BlockStream* - BlockStream** - Integral - IO ()

Here you have invented a new notation for type variables (* and **),
when we already have a perfectly good one.

copyToMemoryStream :: BlockStream - MemoryStream - Integral - IO ()

Whereas here, the lack of any type variable means I am no longer aware
that overloading is going on.  This is likely to discourage the reuse of
this code fragment, rather than encourage it.

copyStream :: {BlockStream} h1 - {BlockStream} h2
  - {Integral} size - IO ()

What is gained by attaching the constraints inline with the type
variables?  If the type variable occurs more than once, which occurrence
should I attach the constraint to?  What if I attach different
constraints to different occurrences of the same variable?  (Obviously
the union is intended, but writing constraints in several different
locations would be highly confusing).  But at least there is a syntactic
marker ({}) that overloading is happening.

copyStream :: {BlockStream} - {BlockStream} - {Integral} - IO ()

Again, omitting type variables means that the possible mental confusion
over whether the two {BlockStream} constraints apply to the same
implicit variable or to different ones is unpleasant.  Better to be
fully explicit, after all, it only takes one extra character to name the
variable!

 foo :: Collection c a = a - c
 === foo :: {Collection c} a - c
 
 foo :: Collection c a = c - c
 === foo :: {Collection * a} c - c
 
 forall a. Num a = (forall b. (Coll b a, Ord b) = b a - ()) - ()
 === (forall b. {Coll * a, Ord}b{Num}a   - ())-   ()
 === forall a. (forall b. ({Coll * a, Ord} b) ({Num} a) - ()) - ()

The lengths people will go to in making things difficult for the reader,
just to save a few characters is truly amazing.  Remember, the code will
be read many more times than it is written.  IMHO, the various proposed
sugar adds nothing helpful, and just muddies understanding.

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


Re[2]: [Haskell-cafe] Re: Memoizing longest-common-subsequence

2006-08-23 Thread Bulat Ziganshin
Hello Alistair,

Wednesday, August 23, 2006, 1:43:30 PM, you wrote:

 I've found the folder in which I did some of this testing, and GNU diff
 has no problem with the input files; they're only 7M, My program spends
 70% of its time doing String-IO (so 30% in the algorithm), and peaks at
 about 350M of memory (which seems quite high, but then it does convert
 the String input into STArrays). The algorithm itself takes about 18secs
 on this input (wall-clock time), but the profile says a lot less CPU
 time is used.

 I think using ByteStrings would be a big improvement; maybe I'll find
 time to try that later.

as variant, you can try streams library - it's several times faster
for line-oriented I/O. another solution that can also speed up your
code, although not so much, is to use hGetContents and then 'lines'

http://haskell.org/haskellwiki/Library/Streams
http://www.haskell.org/library/StreamsBeta.tar.gz

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: Re[2]: class [] proposal Re: [Haskell-cafe] One thought: Num to 0as ? to list?

2006-08-23 Thread Tomasz Zielonka
On Wed, Aug 23, 2006 at 01:28:57PM +0100, Malcolm Wallace wrote:
 The lengths people will go to in making things difficult for the reader,
 just to save a few characters is truly amazing.  Remember, the code will
 be read many more times than it is written.  IMHO, the various proposed
 sugar adds nothing helpful, and just muddies understanding.

Seconded. If someone just wants to type less characters, the he/she
can omit most of type signatures.

I haven't used any IDE for Haskell (like VisualHaskell), but it would be
nice if it could fill the missing type signatures automatically. In
cases when monomorphism restriction kicks in, it could also present the
type that would be inferred with MR turned off.

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


Re: Re[2]: class [] proposal Re: [Haskell-cafe] One thought: Num to 0as ? to list?

2006-08-23 Thread Donald Bruce Stewart
tomasz.zielonka:
 On Wed, Aug 23, 2006 at 01:28:57PM +0100, Malcolm Wallace wrote:
  The lengths people will go to in making things difficult for the reader,
  just to save a few characters is truly amazing.  Remember, the code will
  be read many more times than it is written.  IMHO, the various proposed
  sugar adds nothing helpful, and just muddies understanding.
 
 Seconded. If someone just wants to type less characters, the he/she
 can omit most of type signatures.
 
 I haven't used any IDE for Haskell (like VisualHaskell), but it would be
 nice if it could fill the missing type signatures automatically. In
 cases when monomorphism restriction kicks in, it could also present the
 type that would be inferred with MR turned off.

I use the following script from vim to infer top level type declarations
for me. I've found it particularly useful for understanding others' code:

#!/bin/sh
# input is a top level .hs decls

FILE=$*
DECL=`cat`
ID=`echo $DECL | sed 's/^\([^ ]*\).*/\1/'`
echo :t $ID | ghci -v0 -cpp -fglasgow-exts -w $FILE
echo $DECL

Saved to 'typeOf', you can bind it from vim with:
:map ty :.!typeOf %^M

in your .vimrc
So, from vim the following source:

f (x,y,z) a b = y + a + b

hit, 'ty' and its replaced with:

f :: forall b c a. (Num b) = (a, b, c) - b - b - b
f (x,y,z) a b = y + a + b

I imagine it would be possible to bind from emacs with little effort.

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


[Haskell-cafe] Proposal to allow {} instead of () in contexts

2006-08-23 Thread Brian Hulley

Hi -
Disregarding my last proposal which involved the use of {} in types, I am 
wondering if anyone would agree with me that it would be a good idea to use 
{} instead of () when writing out the context ie:


   foo :: (Num a, Bar a) = a - a

would become:

   foo :: {Num a, Bar a} = a - a

and the same for every other situation in the language where a context 
appears.


My reasons are twofold:

1) The context is supposed to be understood (afaiu) as a *set* of 
constraints not a *tuple* of constraints (ie what relevance does the 
ordering implied by the tuple notation have here?), so the using of set 
braces seems mathematically more appropriate


2) It would allow an editor to give the correct fontification for an 
incomplete type expression. At the moment, if you'd just typed:


   foo :: (Bar

the editor would have no way of knowing if Bar is a classcon or a tycon, 
whereas with:


   foo :: {Bar

the opening brace immediately informs the editor that the following text 
should be parsed as a context and so it could fontify Bar appropriately.


For backwards compatibility the use of () could still be supported - braces 
don't occur in H98 in the positions I'm proposing to allow them so nothing 
would be broken.


Regards, Brian.
--
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.

http://www.metamilk.com 


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


[Haskell-cafe] extreme newbie: hugs prompt vs load module

2006-08-23 Thread George Young
[linux, ghci 6.4.3.20060820, hugs May 2006]

I have just started learning Haskell.  I have hugs and ghci under
linux, and I'm going through the Gentle Introduction to
Haskellhttp://www.haskell.org/tutorial, so far through section 4,
case expressions and pattern matching.  I'm a python programmer, with
background in maclisp, scheme, T, C, C++, and a little J.  

I'm confused about what sort of things I can type at the interpreter
prompt, and what things have to be loaded as a module.  I keep trying
to treat the prompt like a lisp or python REPL, which is obviously
wrong.  Can someone set me straight?

Is there another tutorial that might be more appropriate for me?

I am finding haskell quite appealing.  I hope to start writing real (if
small) applications to do some data analysis from our Postgres DB.  Any
hints?

--George Young
-- 
Are the gods not just?  Oh no, child.
What would become of us if they were? (C.S. Lewis)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] extreme newbie: hugs prompt vs load module

2006-08-23 Thread Robert Dockins


On Aug 23, 2006, at 10:16 AM, George Young wrote:


[linux, ghci 6.4.3.20060820, hugs May 2006]

I have just started learning Haskell.  I have hugs and ghci under
linux, and I'm going through the Gentle Introduction to
Haskellhttp://www.haskell.org/tutorial, so far through section 4,
case expressions and pattern matching.  I'm a python programmer,  
with

background in maclisp, scheme, T, C, C++, and a little J.

I'm confused about what sort of things I can type at the interpreter
prompt, and what things have to be loaded as a module.  I keep trying
to treat the prompt like a lisp or python REPL, which is obviously
wrong.  Can someone set me straight?


For the most part, the things you can enter at the GHCi or Hugs  
prompt are _expressions_.  This mostly* excludes _declarations_,  
which are things like function definitions, datatype declarations,  
class and instance declarations, etc.  Those things need to go into a  
source file.


(*) 'let' expressions will allow you to define local functions as  
part of an expression, however.  GHCi also has a slight variation of  
'let' that allows you to define functions for the session.




Is there another tutorial that might be more appropriate for me?


The following tutorial is generally recognized as one of the better  
ones:


http://www.cs.utah.edu/~hal/htut/


I am finding haskell quite appealing.  I hope to start writing real  
(if
small) applications to do some data analysis from our Postgres DB.   
Any

hints?


There are several haskell database layers.  I've had some luck with  
HDBC, which has a PostgreSQL driver.


http://quux.org:70/devel/hdbc



--George Young
--
Are the gods not just?  Oh no, child.
What would become of us if they were? (C.S. Lewis)




Rob Dockins

Speak softly and drive a Sherman tank.
Laugh hard; it's a long way to the bank.
  -- TMBG



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


Re: Re[2]: class [] proposal Re: [Haskell-cafe] One thought: Num to 0as ? to list?

2006-08-23 Thread Tomasz Zielonka
On Wed, Aug 23, 2006 at 11:11:59PM +1000, Donald Bruce Stewart wrote:
 So, from vim the following source:
 
 f (x,y,z) a b = y + a + b
 
 hit, 'ty' and its replaced with:
 
 f :: forall b c a. (Num b) = (a, b, c) - b - b - b
 f (x,y,z) a b = y + a + b

Nice!

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


Re: [Haskell-cafe] Proposal to allow {} instead of () in contexts

2006-08-23 Thread Brian Smith
On 8/23/06, Brian Hulley [EMAIL PROTECTED] wrote:
Hi -Disregarding my last proposal which involved the use of {} in types, I amwondering if anyone would agree with me that it would be a good idea to use{} instead of () when writing out the context ie:
foo :: (Num a, Bar a) = a - awould become:foo :: {Num a, Bar a} = a - aand the same for every other situation in the language where a contextappears.My reasons are twofold:
1) The context is supposed to be understood (afaiu) as a *set* ofconstraints not a *tuple* of constraints (ie what relevance does theordering implied by the tuple notation have here?), so the using of set
braces seems mathematically more appropriateI just started programming in Haskell again recently and I cannot even think of a case where any kind of brackets should be necessary. In the report [1], it clearly shows that a context is always followed by =. Are the parantheses just used to reduce lookahead requirements for parsers? If so, perhaps the parentheses should be made optional to make them easier to read for people. Plus, then there would not be any tuple vs. set confusion.
BTW, at least GHC allows duplicates in the context, like [ foo :: (Num a, Num a) = a - a ], so I don't know if calling it a set is really appropriate either.
2) It would allow an editor to give the correct fontification for anincomplete type _expression_. At the moment, if you'd just typed:foo :: (Barthe editor would have no way of knowing if Bar is a classcon or a tycon,
whereas with:foo :: {Barthe opening brace immediately informs the editor that the following textshould be parsed as a context and so it could fontify Bar appropriately.What about [ foo :: Bar ] when typing [ foo :: Bar a = a - a ]? It would be a mistake to require the grouping symbols even when there is only one element in the context. I think that the editor has to be know enough about the program to distinguish classes and type constructors without any grouping symbol requirement.
- Brian
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] extreme newbie: hugs prompt vs load module

2006-08-23 Thread Brandon Moore

George Young wrote:

[linux, ghci 6.4.3.20060820, hugs May 2006]

I have just started learning Haskell.  I have hugs and ghci under
linux, and I'm going through the Gentle Introduction to
Haskellhttp://www.haskell.org/tutorial, so far through section 4,
case expressions and pattern matching.  I'm a python programmer, with
background in maclisp, scheme, T, C, C++, and a little J.  


I'm confused about what sort of things I can type at the interpreter
prompt, and what things have to be loaded as a module.  I keep trying
to treat the prompt like a lisp or python REPL, which is obviously
wrong.  Can someone set me straight?
  


GHCi allows expressions, plus anything valid as a statement in a do 
block (of IO). That's why you can use let without an in clause to make 
bindings that stick around - you're getting the let form allowed in do 
blocks. You can also bind use the arrow bindings, to get result out of 
IO actions, like some_even - fmap (*2) randomIO. (isn't this a good 
answer to the perennial newbie question how do I get a out of IO a?)


I usually work with GHCi (ghci MyModdule.hs) next to an editor, 
examining things in GHCi, then changing the code or adding things like 
data type declarations that can't be done interactively, and reloading 
the file (with :r). It works pretty well, though copying important 
declarations from the session into the module to preserve them across a 
reload is a bit annoying.


The usual approach of making a REPL accept any valid code in the 
language wouldn't work so well for Haskell. It would be tough to 
implement, because declarations can come in any order, and extremely 
aggravating to use, because declarations can't be shadowed. Allowing 
class and type declarations interactively would be nice (perhaps Hugs 
already does?), but not a massive improvement alone. Maybe if there were 
a feature to extract all the code necessary to reproduce some 
interactively defined value?


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


Re: [Haskell-cafe] extreme newbie: hugs prompt vs load module

2006-08-23 Thread Bulat Ziganshin
Hello George,

Wednesday, August 23, 2006, 6:16:12 PM, you wrote:

 I'm confused about what sort of things I can type at the interpreter
 prompt, and what things have to be loaded as a module.  I keep trying
 to treat the prompt like a lisp or python REPL, which is obviously
 wrong.  Can someone set me straight?

in hugs you can only type expressions: such as 2*2 or prod [1..10].
although there is a trick what sometimes help:

let fac n = prod [1..n] in fac n

it's also an expression, after all :)

in ghci you can define functions with 'let'

you can find more information about this in appropriate user guides,
what is part of your installations and is also available online

 Is there another tutorial that might be more appropriate for me?

yet another haskell tutorial commonly considered as more gentle
than gentle introduction

you can find Getting started and Books and tutorials links on the
haskell.org. First page includes the most recommended books/tutorials
while second contains more detailed explanations about their contents

 I am finding haskell quite appealing.  I hope to start writing real (if
 small) applications to do some data analysis from our Postgres DB.  Any
 hints?

haskell.org - libraries and tools - databases

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] extreme newbie: hugs prompt vs load module

2006-08-23 Thread Shao Chih Kuo

You can always load things inside ghci with:

:m

i.e.

Prelude :m List
Prelude List :m Control.Concurrent
Prelude Control.Concurrent :m Control.Concurrent List
Prelude List Control.Concurrent

George Young wrote:

[linux, ghci 6.4.3.20060820, hugs May 2006]

I have just started learning Haskell.  I have hugs and ghci under
linux, and I'm going through the Gentle Introduction to
Haskellhttp://www.haskell.org/tutorial, so far through section 4,
case expressions and pattern matching.  I'm a python programmer, with
background in maclisp, scheme, T, C, C++, and a little J.  


I'm confused about what sort of things I can type at the interpreter
prompt, and what things have to be loaded as a module.  I keep trying
to treat the prompt like a lisp or python REPL, which is obviously
wrong.  Can someone set me straight?

Is there another tutorial that might be more appropriate for me?

I am finding haskell quite appealing.  I hope to start writing real (if
small) applications to do some data analysis from our Postgres DB.  Any
hints?

--George Young
  


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


Re: [Haskell-cafe] implementing a csv reader

2006-08-23 Thread Henk-Jan van Tuyl


L.S.,

Reading and writing a comma seperated datafile doesn't have to be that  
complicated; the following is an easy way to read a CSV file into a list  
of tuples and display the list on screen:



displayTuples =
  do
   csvData - readFile data.csv
   putStrLn $ unlines $ map (show . readTuple) $ lines csvData



readTuple :: String - (Int, Bool, String)
readTuple line = read tuple
  wheretuple = '(' : line ++ )


If the file data.csv contains the following:
  1, True, Festina lente
  2, False, Carpe diem

displayTuples displays:
  (1,True,Festina lente)
  (2,False,Carpe diem)

Writing a list of tuples to a CSV file is even simpler:

writeTuples file tuples =  writeFile file $ unlines $ map (tail . init .  
show) tuples


The call:
  writeTuples new.csv [(1, 'a'), (2, 'b')]
results in a file containg:
  1,'a'
  2,'b'

(without the leading spaces)

Met vriendelijke groet,
Henk-Jan van Tuyl


--
http://Van.Tuyl.eu/
--



On Tue, 22 Aug 2006 11:19:35 +0200, Tamas K Papp [EMAIL PROTECTED]  
wrote:



Hi,

Now that I have read the tutorials, I think that the best way to learn
Haskell would be to use the language and write something simple yet
useful.  I noticed that Haskell lacks a module for reading/writing csv
(comma separated value) files, so I thought I could implement that.

Questions:

1. Please tell me if you know of a csv module, because then I would do
   something else.

2. I am looking for a parser, but I don't know Haskell parsers.  Is
   Parsec a good choice?

Thanks,

Tamas


--
Using Opera's revolutionary e-mail client:
https://secure.bmtmicro.com/opera/buy-opera.html?AID=789433

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


Re: [Haskell-cafe] implementing a csv reader

2006-08-23 Thread Robert Dockins


On Aug 23, 2006, at 3:37 PM, Henk-Jan van Tuyl wrote:



L.S.,

Reading and writing a comma seperated datafile doesn't have to be  
that complicated; the following is an easy way to read a CSV file  
into a list of tuples and display the list on screen:


For every complex problem, there is a solution which is simple,  
neat, and wrong.  -- HL Mencken



Although it seems straightforward at first, CSV suffers from text  
escaping complexities, just as does every other general purpose plain- 
text encoding.  Most notably, a newline embedded inside double quotes  
does not end a record.  These issues cause ugly corner cases if you  
aren't expecting them.  And that's just the issues with moving tables  
of strings around; if those fields have non-string interpretations  
(dates or numbers or what have you), things get really hairy.  To do  
the right thing probably requires perl-ish duck typing  :-p


See http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm for a semi- 
authoritative reference on CSV.  A related RFC is here: http:// 
tools.ietf.org/html/rfc4180




Rob Dockins

Speak softly and drive a Sherman tank.
Laugh hard; it's a long way to the bank.
  -- TMBG



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


[Haskell-cafe] Cabal question, adding data files

2006-08-23 Thread Neil Mitchell

Hi,

I have a cabal executable, which requires additional data files. How
do I do this in Cabal? I have seen extra-source-files, but they are
not added at install time to the destination directory, which doesn't
help me.

I noticed that Alex does this, but with a lot of Cabal calling in
Setup.hs with hooks etc, which is not really ideal. Is there any easy
way to do the install these files along with the program, please ?

If anyone needs any concrete examples, take for example HsColour,
which needs the files .hscolour and hscolour.css, but currently
install doesn't put either of them anywhere useful.

Thanks

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


Re: [Haskell-cafe] Cabal question, adding data files

2006-08-23 Thread Ross Paterson
On Wed, Aug 23, 2006 at 10:42:54PM +0100, Neil Mitchell wrote:
 I have a cabal executable, which requires additional data files. How
 do I do this in Cabal? I have seen extra-source-files, but they are
 not added at install time to the destination directory, which doesn't
 help me.

The field you want is data-files, documented in section 2.1.1 of the
Cabal User's Guide.

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


Re: [Haskell-cafe] Cabal question, adding data files

2006-08-23 Thread Neil Mitchell

Hi


The field you want is data-files, documented in section 2.1.1 of the
Cabal User's Guide.


That looks perfect. Is there any reason that Alex doesn't use this? I
was trying to learn by example.

Thanks

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


Re: Re[2]: class [] proposal Re: [Haskell-cafe] One thought: Num to 0as ? to list?

2006-08-23 Thread Toby Hutton
On 8/23/06, Donald Bruce Stewart [EMAIL PROTECTED] wrote:
I use the following script from vim to infer top level type declarationsfor me. I've found it particularly useful for understanding others' code:delurkOn the topic of coding Haskell with Vim is there an indentation plugin
for Haskell available? Google hasn't found one for me and none ismentioned on the Haskell wiki.Thanks,Toby.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Proposal to allow {} instead of () in contexts

2006-08-23 Thread Brian Hulley

On August 23, 2006 5:16 PM, Brian Smith  wrote

On 8/23/06, Brian Hulley [EMAIL PROTECTED] wrote:

Hi -
Disregarding my last proposal which involved the use of {} in types, I am
wondering if anyone would agree with me that it would be a good idea
to  use {} instead of () when writing out the context ie:

   foo :: (Num a, Bar a) = a - a

would become:

   foo :: {Num a, Bar a} = a - a

1) The context is supposed to be understood (afaiu) as a *set*



I just started programming in Haskell again recently and I cannot even
think of a case where any kind of brackets should be necessary. In the
report [1], it clearly shows that a context is always followed by =. 
Are

the parantheses just used to reduce lookahead requirements for
parsers? If so, perhaps the parentheses should be made optional to
make them easier to read for people. Plus, then there would not be any
tuple vs. set confusion.


Also, parens should not be needed in

   data D = D | E deriving Eq, Ord

because a data decl can never be confused with a tuple component. It would 
certainly be very much neater to not have to use parens just because there 
is more than one constraint / deriving class.


Certainly the current need for parens in these situations seems like a wart 
and always trips me up.



BTW, at least GHC allows duplicates in the context, like [  foo :: (Num a,
Num a) = a - a  ], so I don't know if calling it a set is really
appropriate either.


I'd argue that this is precisely what makes the above a set rather than a 
tuple: {Num a, Num a} === {Num a}
Also, I'd argue that an error should be given when a constraint is 
duplicated because it has no meaning thus probably indicates some 
misunderstanding on the part of the programmer (unless the idea is to pave 
the way for class aliases where one may want to write code that can compile 
under different alias environments).



2) It would allow an editor to give the correct fontification for an
incomplete type expression. At the moment, if you'd just typed:

   foo :: (Bar

the editor would have no way of knowing if Bar is a classcon or a
tycon, whereas with:

   foo :: {Bar

the opening brace immediately informs the editor that the following text
should be parsed as a context and so it could fontify Bar appropriately.



What about [   foo :: Bar  ] when typing [   foo :: Bar a = a - a   ]?
It would be a mistake to require the grouping symbols even when there
is only one element in the context. I think that the editor has to be know
enough about the program to distinguish classes and type constructors
without any grouping symbol requirement.


If braces were used even in the case where there was only one constraint the 
= would never be needed as in:


   foo :: {Bar a} a-a

so there would be no more characters to type yet the notation would have the 
advantage that the signature could be understood by itself without requiring 
the user to have already defined Bar somewhere.


I was also thinking that in:

   foo :: {Ba

Ba could be fontified as a classcon to help the user realise that he/she is 
typing a classcon at that point. However it also could be helpful to only 
fontify known tycons/classcons and have a different font for unknown 
entity, and in practice I suppose it is likely that you'd only start 
entering signatures etc when the types and classes have already been 
defined.


BTW this also assumes tycons and classcons share the same namespace. If this 
were changed in future, then it would no longer be able to determine the 
type/class distinction just by the id (but of course would eventually be 
known after the = but this is too late for providing syntax help while 
editing the context itself).


Thanks for the idea of making parens optional. I intend to try this as the 
editor could still save/load files in normal H98 syntax (with parens) yet 
allow them to be displayed/edited without for added user convenience... :-)


Regards, Brian.
--
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.

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


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


[Haskell-cafe] Fran - Functional Reactive Animation

2006-08-23 Thread HIGGINS Neil (ENERGEX)
Title: Fran - Functional Reactive Animation







Fran is a Haskell library (or embedded language) for interactive animations with 2D and 3D graphics and sound. See http://www.conal.net/fran/ and http://research.microsoft.com/research/downloads/download.aspx?FUID=c9eff407-ce59-4a2a-90cb-de099a9bacbd

I would like to use Fran as a rapid prototyping environment for animations, but it appears to be broken under WinHugs.


I'm looking for someone with much better Haskell prowess than myself who might be able resurrect Fran under WinHugs. Unfortunately I can only offer my gratitude in return.

It's a long shot, I know.


Kind regards,
Neil Higgins
Snr Strategic Planning Engineer
ENERGEX
Em: [EMAIL PROTECTED]
Ph: 3407 4800
Fx: 3407 4832





*
This email message (including any file attachments transmitted with it)
is for the sole use of the intended recipient(s) and may contain
confidential and legally privileged information. Any unauthorised
review, use, alteration, disclosure or distribution of this email
(including any attachments) by an unintended recipient is prohibited.
If you have received this email in error, please notify the sender by
return email and destroy all copies of the original message.
Any confidential or legal professional privilege is not waived
or lost by any mistaken delivery of the email.
ENERGEX accepts no responsibility for the content of any email
which is sent by an employee which is of a personal nature.
Sender Details:
  ENERGEX
  GPO Box 1461 Brisbane QLD Australia 4001
  +61 7 3407 4000
  http://www.energex.com.au
ENERGEX policy is to not send unsolicited electronic messages. Suspected
breaches of this policy can be reported by replying to this message
including the original message and the word "UNSUBSCRIBE" in the subject.
*


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


Re: [Haskell-cafe] Fran - Functional Reactive Animation

2006-08-23 Thread Jared Updike

I think this works:

 http://haskell.org/edsl/pansharp.html

 Jared.

On 8/23/06, HIGGINS Neil (ENERGEX) [EMAIL PROTECTED] wrote:






Fran is a Haskell library (or embedded language) for interactive
animations with 2D and 3D graphics and sound. See
http://www.conal.net/fran/ and
http://research.microsoft.com/research/downloads/download.aspx?FUID=c9eff407-ce59-4a2a-90cb-de099a9bacbd

I would like to use Fran as a rapid prototyping environment for animations,
but it appears to be broken under WinHugs.

I'm looking for someone with much better Haskell prowess than myself who
might be able resurrect Fran under WinHugs. Unfortunately I can only offer
my gratitude in return.

It's a long shot, I know.

Kind regards,
Neil Higgins
Snr Strategic Planning Engineer
ENERGEX
Em: [EMAIL PROTECTED]
Ph:  3407 4800
Fx:  3407 4832


*
 This email message (including any file attachments transmitted with it)
 is for the sole use of the intended recipient(s) and may contain
 confidential and legally privileged information. Any unauthorised
 review, use, alteration, disclosure or distribution of this email
 (including any attachments) by an unintended recipient is prohibited.
 If you have received this email in error, please notify the sender by
 return email and destroy all copies of the original message.
 Any confidential or legal professional privilege is not waived
 or lost by any mistaken delivery of the email.
 ENERGEX accepts no responsibility for the content of any email
 which is sent by an employee which is of a personal nature.
 Sender Details:
 ENERGEX
 GPO Box 1461 Brisbane QLD Australia 4001
 +61 7 3407 4000
 http://www.energex.com.au
 ENERGEX policy is to not send unsolicited electronic messages. Suspected
 breaches of this policy can be reported by replying to this message
 including the original message and the word UNSUBSCRIBE in the subject.
*

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






--
http://www.updike.org/~jared/
reverse )-:
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Cabal question, adding data files

2006-08-23 Thread Conrad Parker
On Wed, Aug 23, 2006 at 11:36:00PM +0100, Neil Mitchell wrote:
 Hi
 
 The field you want is data-files, documented in section 2.1.1 of the
 Cabal User's Guide.
 
 That looks perfect. Is there any reason that Alex doesn't use this? I
 was trying to learn by example.

Perhaps because Alex predates the data-files field; data-files was only
introduced in Cabal 1.1.4. Hence you might want to also put the following
at the top of your .cabal file:

Cabal-Version:   = 1.1.4

cheers,

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