Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Processing a list of files the Haskell way (Chadda? Fouch?)
2. Strange gchi behavior? (Olwe Melwasul)
3. Re: Strange gchi behavior? (David McBride)
4. Re: Strange gchi behavior? (Antoine Latter)
5. Re: Strange gchi behavior? (Brandon Allbery)
----------------------------------------------------------------------
Message: 1
Date: Wed, 14 Mar 2012 13:04:03 +0100
From: Chadda? Fouch? <[email protected]>
Subject: Re: [Haskell-beginners] Processing a list of files the
Haskell way
To: Michael Schober <[email protected]>
Cc: [email protected]
Message-ID:
<canfjzrzs0gyhrouanayo+zvyodgt4sqt+cllznaikdotk_z...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Le 14 mars 2012 11:44, "Michael Schober" <[email protected]> a ?crit :
>
>> An "experienced" Haskell programmer would probably reuse some of the
>> "streaming" solutions on Hackage, combine it with md5 and a map :
>
> This seems to be the 'Haskell-way' solution I was looking for. I'm still
in the progress of digging through a lot of material I found ([1-3], links
below for other interested readers), but I think that this will be very
helpful in the future with similar projects as well.
>
> I have yet to test the code you send me last time, but I will give some
feedback of it as soon as I get the chance.
>
In my own tests it wasn't very fast : 10min to check a 25GB hierarchy of
music files, using 13MB of memory maximum. Though I must admit that I
didn't try to find similar tools to compare so I'm not too certain of
normal performance times.
>
> Thank you very much!
> Michael
>
> References:
> [1] The original conduit article I found:
> http://www.yesodweb.com/book/conduit
> [2] Conduits seem to be a development progress originating from
enumerators/iteratee. Therefore, it seems to be a good idea to read up on
those prior:
> http://www.yesodweb.com/book/enumerator
> [3] There's also an article in The Monad.Reader, issue 16 about Iteratee:
> http://themonadreader.wordpress.com/2010/05/12/issue-16/
Good reading ! Though understanding them is not always easy, basic usage of
iteratee/conduit/... is not too hard and often deliver pretty nice
performance improvements.
--
Jeda?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120314/c47da1ce/attachment-0001.htm>
------------------------------
Message: 2
Date: Wed, 14 Mar 2012 23:28:02 -0500
From: Olwe Melwasul <[email protected]>
Subject: [Haskell-beginners] Strange gchi behavior?
To: [email protected]
Message-ID:
<caag7i-tuepyxzub7xgnrbuvpeitjyxx9emewj+pxkoto0jg...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
I'm working my way through Real World Haskell and am in Chapter 3. On page
56 there is a discussion called "Record Syntax" and it gives this data
constructor:
data Customer = Customer {
customerID :: CustomerID
, customerName :: String
, customerAddress :: Address
} deriving (Show)
where CustomerID and Address were defined (and loaded) before. But when I
try to put in data, I get these errors
*Main> :load BookStore.hs
[1 of 1] Compiling Main ( BookStore.hs, interpreted )
Ok, modules loaded: Main.
*Main> customer1 = Customer 271828 "J.R. Hacker"
["255 Syntax Ct",
"Milpitas, CA 95134",
"USA"]
<interactive>:1:11: parse error on input `='
*Main>
<interactive>:1:18: parse error (possibly incorrect indentation)
*Main>
<interactive>:1:21: parse error on input `,'
*Main>
<interactive>:1:6: parse error on input `]'
*Main>
If I put the whole data add on one line, I still get
*Main> customer1 = Customer 271828 "J.R. Hacker" ["255 Syntax Ct",
"Milpitas, CA 95134", "USA"]
<interactive>:1:11: parse error on input `='
*Main>
I'm on Ubuntu 11.10, using Emacs23, haskell-mode, running 7.0.4. Any ideas
what's going wrong? The book gives this alternate version:
data Customer = Customer Int String [String]
deriving (Show)
customerID :: Customer -> Int
customerID (Customer id _ _) = id
customerName :: Customer -> String
customerName (Customer _ name _) = name
customerAddress :: Customer -> [String]
customerAddress (Customer _ _ address) = address
...but it produces the same errors.
Olwe
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120314/19ea5453/attachment-0001.htm>
------------------------------
Message: 3
Date: Thu, 15 Mar 2012 00:39:39 -0400
From: David McBride <[email protected]>
Subject: Re: [Haskell-beginners] Strange gchi behavior?
To: Olwe Melwasul <[email protected]>
Cc: [email protected]
Message-ID:
<CAN+Tr4217q=7sbx9rhpztrgehpsvtwcsaze_yhynp0ptpac...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
There's nothing wrong with the Customer data type. More than likely
you have a white space error on some lines before the Customer
datatype, or perhaps a missing closing bracket on some previous data
type. Make sure there are no hard tabs, only spaces.
If you plan to do mulitline input in ghci, you must go :{\n before you
start, :}\n to end. You can find this in :help in ghci if you forget
what it was.
But that is not why your customer = ... line does not work. When you
declare something like that in ghci, you must use let, ie "let
customer = undefined". You don't have to do that in the file, but
ghci is already running, it requires let for new bindings. I'm not
sure why, but it is not too big of a deal once you realize it.
On Thu, Mar 15, 2012 at 12:28 AM, Olwe Melwasul
<[email protected]> wrote:
> I'm working my way through Real World Haskell and am in Chapter 3. On page
> 56 there is a discussion called "Record Syntax" and it gives this data
> constructor:
>
> data Customer = Customer {
> ? ? ? customerID ? ? ?:: CustomerID
> ? ? , customerName ? ?:: String
> ? ? , customerAddress :: Address
> ? ? } deriving (Show)
>
> where CustomerID and Address were defined (and loaded) before. But when I
> try to put in data, I get these errors
>
> *Main> :load BookStore.hs
> [1 of 1] Compiling Main ? ? ? ? ? ? ( BookStore.hs, interpreted )
> Ok, modules loaded: Main.
> *Main> customer1 = Customer 271828 "J.R. Hacker"
> ? ? ? ? ? ? ["255 Syntax Ct",
> ? ? ? ? ? ? ?"Milpitas, CA 95134",
> ? ? ? ? ? ? ?"USA"]
>
> <interactive>:1:11: parse error on input `='
> *Main>
> <interactive>:1:18: parse error (possibly incorrect indentation)
> *Main>
> <interactive>:1:21: parse error on input `,'
> *Main>
> <interactive>:1:6: parse error on input `]'
> *Main>
>
> If I put the whole data add on one line, I still get
>
> *Main> customer1 = Customer 271828 "J.R. Hacker" ["255 Syntax Ct",
> "Milpitas, CA 95134", "USA"]
>
> <interactive>:1:11: parse error on input `='
> *Main>
>
> I'm on Ubuntu 11.10, using Emacs23, haskell-mode, running 7.0.4. Any ideas
> what's going wrong? The book gives this alternate version:
>
> data Customer = Customer Int String [String]
> ? ? ? ? ? ? ? ? deriving (Show)
>
> customerID :: Customer -> Int
> customerID (Customer id _ _) = id
>
> customerName :: Customer -> String
> customerName (Customer _ name _) = name
>
> customerAddress :: Customer -> [String]
> customerAddress (Customer _ _ address) = address
>
> ...but it produces the same errors.
>
>
> Olwe
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
------------------------------
Message: 4
Date: Wed, 14 Mar 2012 23:41:02 -0500
From: Antoine Latter <[email protected]>
Subject: Re: [Haskell-beginners] Strange gchi behavior?
To: Olwe Melwasul <[email protected]>
Cc: [email protected]
Message-ID:
<cakjsnqegozqpctkojnvntdftlyvmn_eulby8meqs08vf9cs...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
On Wed, Mar 14, 2012 at 11:28 PM, Olwe Melwasul
<[email protected]> wrote:
> I'm working my way through Real World Haskell and am in Chapter 3. On page
> 56 there is a discussion called "Record Syntax" and it gives this data
> constructor:
>
> data Customer = Customer {
> ? ? ? customerID ? ? ?:: CustomerID
> ? ? , customerName ? ?:: String
> ? ? , customerAddress :: Address
> ? ? } deriving (Show)
>
> where CustomerID and Address were defined (and loaded) before. But when I
> try to put in data, I get these errors
>
> *Main> :load BookStore.hs
> [1 of 1] Compiling Main ? ? ? ? ? ? ( BookStore.hs, interpreted )
> Ok, modules loaded: Main.
> *Main> customer1 = Customer 271828 "J.R. Hacker"
> ? ? ? ? ? ? ["255 Syntax Ct",
> ? ? ? ? ? ? ?"Milpitas, CA 95134",
> ? ? ? ? ? ? ?"USA"]
>
In GHCi definitions are introduced with 'let', as in:
> let x = ...
Antoine
------------------------------
Message: 5
Date: Thu, 15 Mar 2012 00:45:41 -0400
From: Brandon Allbery <[email protected]>
Subject: Re: [Haskell-beginners] Strange gchi behavior?
To: Olwe Melwasul <[email protected]>
Cc: [email protected]
Message-ID:
<CAKFCL4UoLc9Q-RybjoR==qz3z4nzodyukcr4n-mj+_e4rs8...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Thu, Mar 15, 2012 at 00:28, Olwe Melwasul <[email protected]>wrote:
> I'm working my way through Real World Haskell and am in Chapter 3. On page
> 56 there is a discussion called "Record Syntax" and it gives this data
> constructor:
>
> data Customer = Customer {
> customerID :: CustomerID
> , customerName :: String
> , customerAddress :: Address
> } deriving (Show)
>
> where CustomerID and Address were defined (and loaded) before. But when I
> try to put in data, I get these errors
>
> *Main> :load BookStore.hs
> [1 of 1] Compiling Main ( BookStore.hs, interpreted )
> Ok, modules loaded: Main.
> *Main> customer1 = Customer 271828 "J.R. Hacker"
>
You cannot create a binding that way in ghci; you need to use a "let", or
for monadic bindings "<-". (Think of the ghci prompt as being inside a big
"do" block, although in more recent versions of GHC there are various top
level things that will work.)
*Mail> let customer1 = Customer 271828 "J. R. Hacker." ["255 Syntax Ct",
"Milpitas, CA 95134",
"USA"]
Note the "let".
(Summary: ghci is not the top level of a source file. I'm surprised you
didn't get an error if you tried to do the data declaration in your other
example, unless you were using 7.4.1 where "data" works but a binding
without "let" or "<-" still does not.)
--
brandon s allbery [email protected]
wandering unix systems administrator (available) (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120315/6c480c6d/attachment.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 45, Issue 19
*****************************************