[Haskell-cafe] FW: Treating command-line arguments as a Haskell expression

2007-12-24 Thread Simon Peyton-Jones
Would someone familiar with the command-line-parsing libraries care to help Krassimir? Thanks Simon -Original Message- From: Krassimir Krustev [mailto:[EMAIL PROTECTED] Sent: 23 December 2007 11:38 To: Simon Peyton-Jones Subject: Treating command-line arguments as a Haskell expression

[Haskell-cafe] Printing and Referential transparency excuse

2007-12-24 Thread Cristian Baboi
While reading the Haskell language report I noticed that function type is not an instance of class Read. I was told that one cannot define them as an instance of class Show without breaking referential transparency or printing a constant. f :: (a-b)-String f x = bla bla bla How can I

[Haskell-cafe] Re: Printing and Referential transparency excuse

2007-12-24 Thread apfelmus
Cristian Baboi wrote: While reading the Haskell language report I noticed that function type is not an instance of class Read. I was told that one cannot define them as an instance of class Show without breaking referential transparency or printing a constant. f :: (a-b)-String f x =

RE: [Haskell-cafe] A Foldable binary search tree

2007-12-24 Thread Simon Peyton-Jones
| data (Ord a) = BST a = Empty | BST (BST a) a (BST a) | | Experience has taught me to _never_ put class contexts on data | definitions. Correct. Haskell-98 contexts on data-type declarations are a mis-feature of Haskell, which I resisted at the time but failed to eliminate. As others have

Re: [Haskell-cafe] FW: Treating command-line arguments as a Haskell expression

2007-12-24 Thread Max Vasin
2007/12/24, Simon Peyton-Jones [EMAIL PROTECTED]: Would someone familiar with the command-line-parsing libraries care to help Krassimir? AFAIU Krassimir's needs, hs-plugins will help him (function eval). -- WBR, Max Vasin JID: [EMAIL PROTECTED]

Re: [Haskell-cafe] Haskell performance

2007-12-24 Thread Peter Lund
On Sun, 2007-12-23 at 11:52 +, Ian Lynagh wrote: On Thu, Dec 20, 2007 at 10:58:17AM +, Malcolm Wallace wrote: Nobench does already collect code size, but does not yet display it in the results table. I specifically want to collect compile time as well. Not sure what the best way

Re: [Haskell-cafe] Functions are first class values in C

2007-12-24 Thread Antti-Juhani Kaijanaho
On Sat, Dec 22, 2007 at 05:25:26PM +0300, Miguel Mitrofanov wrote: That's not C. That's the C preprocessor, which is a textual substitution macro language. Well, the preprocessor is part of the language in a way. These two come together. No. In fact, these are even two different programs,

Re: [Haskell-cafe] Functions are first class values in C

2007-12-24 Thread Miguel Mitrofanov
It is true, however, that preprocessing used to be (in pre-standard days) separate from the language. This has not been true for decades. Well, I've seen cpp to be used as a preprocessor not for C sources but for something else. ___ Haskell-Cafe

Re: [Haskell-cafe] Re: Comments on reading two ints off Bytestring

2007-12-24 Thread Paulo J. Matos
On Dec 23, 2007 12:44 PM, Isaac Dupree [EMAIL PROTECTED] wrote: -- this should work too parseHeader3 :: BS.ByteString - Maybe (Int, Int) --note accurate type signature, which helps us use Maybe failure-monad, --although losing your separate error messages Oh gee, I just noticed that my type

Re: [Haskell-cafe] Re: Comments on reading two ints off Bytestring

2007-12-24 Thread Paulo J. Matos
On Dec 24, 2007 11:55 AM, Paulo J. Matos [EMAIL PROTECTED] wrote: On Dec 23, 2007 12:44 PM, Isaac Dupree [EMAIL PROTECTED] wrote: -- this should work too parseHeader3 :: BS.ByteString - Maybe (Int, Int) --note accurate type signature, which helps us use Maybe failure-monad, --although

Re: [Haskell-cafe] Re: Comments on reading two ints off Bytestring

2007-12-24 Thread Chaddaï Fouché
2007/12/24, Paulo J. Matos [EMAIL PROTECTED]: On Dec 24, 2007 11:55 AM, Paulo J. Matos [EMAIL PROTECTED] wrote: On Dec 23, 2007 12:44 PM, Isaac Dupree [EMAIL PROTECTED] wrote: -- this should work too parseHeader3 :: BS.ByteString - Maybe (Int, Int) --note accurate type signature,

Re: [Haskell-cafe] Re: Printing and Referential transparency excuse

2007-12-24 Thread Cristian Baboi
On Mon, 24 Dec 2007 11:27:11 +0200, apfelmus [EMAIL PROTECTED] wrote: Cristian Baboi wrote: How can I define a function to do the inverse operation ? g :: String - ( a - b ) This time I cannot see how referential transparency will deny it. What's the excuse now ? The new excuse is

Re: [Haskell-cafe] Re: Printing and Referential transparency excuse

2007-12-24 Thread Chaddaï Fouché
2007/12/24, Cristian Baboi [EMAIL PROTECTED]: On Mon, 24 Dec 2007 11:27:11 +0200, apfelmus [EMAIL PROTECTED] wrote: Cristian Baboi wrote: How can I define a function to do the inverse operation ? g :: String - ( a - b ) This time I cannot see how referential transparency will deny

Re: [Haskell-cafe] FW: Treating command-line arguments as a Haskell expression

2007-12-24 Thread Yitzchak Gale
Simon Peyton-Jones: Would someone familiar with the command-line-parsing libraries care to help Krassimir? I agree with Max that it looks like the problem is not doing any fancy command-line parsing (if that is indeed the issue, then please post more information about what the problem is).

Re: [Haskell-cafe] Functions are first class values in C

2007-12-24 Thread Antti-Juhani Kaijanaho
On Mon, Dec 24, 2007 at 02:12:30PM +0300, Miguel Mitrofanov wrote: It is true, however, that preprocessing used to be (in pre-standard days) separate from the language. This has not been true for decades. Well, I've seen cpp to be used as a preprocessor not for C sources but for

Re: [Haskell-cafe] FW: Treating command-line arguments as a Haskell expression

2007-12-24 Thread Sterling Clover
As the previous answers show, hooking dynamic evaluation, or a subset thereof, into Haskell is not a particularly easy task. If this is just a program to get up-and-running with understanding Haskell, probably best not to delve into this sorts of stuff? A simpler solution, albeit one which

Re: [Haskell-cafe] FW: Treating command-line arguments as a Haskell expression

2007-12-24 Thread Neil Mitchell
Hi I want to call a function from within Haskell module so that the name of this function corresponds to my first command-line argument and the rest rest of the command-line arguments are would become themselves the argument to this function. While you can do this, you probably don't

Re: [Haskell-cafe] Re: Comments on reading two ints off Bytestring

2007-12-24 Thread Isaac Dupree
Paulo J. Matos wrote: On Dec 23, 2007 12:44 PM, Isaac Dupree [EMAIL PROTECTED] wrote: -- this should work too parseHeader3 :: BS.ByteString - Maybe (Int, Int) --note accurate type signature, which helps us use Maybe failure-monad, --although losing your separate error messages Oh gee, I just

Re: [Haskell-cafe] Re: Comments on reading two ints off Bytestring

2007-12-24 Thread Brandon S. Allbery KF8NH
On Dec 24, 2007, at 13:18 , Isaac Dupree wrote: Paulo J. Matos wrote: On Dec 23, 2007 12:44 PM, Isaac Dupree [EMAIL PROTECTED] wrote: parseHeader3 bs = do (x, rest) - BS.readInt $ BS.dropWhile (not . isDigit) bs (y, _) - BS.readInt $ BS.dropWhile (not . isDigit) rest return (x, y)

Re: [Haskell-cafe] Peyton Jones' Beautiful Concurrency .. i.e. Software Transactional Memory ...

2007-12-24 Thread Ryan Ingram
{- compile with ghc --make stm.hs -} module Main where import Control.Concurrent.STM type Account = TVar Int withdraw :: Account - Int - STM () withdraw acc amount = do bal - readTVar acc writeTVar acc (bal - amount) main = do account - atomically $ newTVar 100 atomically $

Re: [Haskell-cafe] Re: Comments on reading two ints off Bytestring

2007-12-24 Thread Isaac Dupree
Brandon S. Allbery KF8NH wrote: On Dec 24, 2007, at 13:18 , Isaac Dupree wrote: Paulo J. Matos wrote: On Dec 23, 2007 12:44 PM, Isaac Dupree [EMAIL PROTECTED] wrote: parseHeader3 bs = do (x, rest) - BS.readInt $ BS.dropWhile (not . isDigit) bs (y, _) - BS.readInt $ BS.dropWhile (not .

Re: [Haskell-cafe] Comments on reading two ints off Bytestring

2007-12-24 Thread Conal Elliott
To clean up even more, use StateT B.ByteString Maybe. Then the ByteString threading will be invisible, leading to just liftM2 (,) readI readI, for suitably defined readI. On Dec 23, 2007 6:45 AM, Bryan O'Sullivan [EMAIL PROTECTED] wrote: Paulo J. Matos wrote: I guess the latter is the

[Haskell-cafe] Trouble with types

2007-12-24 Thread Konstantin Vladimirov
Colleagues! The essence of trouble may be given by code: [haskell] module TypeTrouble where class FirstClass a where firstFunction :: (SecondClass b) = a - b class SecondClass a where secondFunction :: a - Double data FirstData = FirstData Double data SecondData = SecondData Double

Re: [Haskell-cafe] Trouble with types

2007-12-24 Thread Stefan O'Rear
On Tue, Dec 25, 2007 at 08:11:34AM +0300, Konstantin Vladimirov wrote: [haskell] module TypeTrouble where class FirstClass a where firstFunction :: (SecondClass b) = a - b class SecondClass a where secondFunction :: a - Double [/haskell] I need, the firstFunction of

Re: [Haskell-cafe] Trouble with types

2007-12-24 Thread Antoine Latter
On Dec 25, 2007 12:11 AM, Konstantin Vladimirov [EMAIL PROTECTED] wrote: class FirstClass a where firstFunction :: (SecondClass b) = a - b snip! instance FirstClass FirstData where firstFunction (FirstData d) = SecondData d The problem is that the type of firstFunction as producing