Re: [Haskell-cafe] Existentially-quantified constructors, Eq and Show

2005-12-08 Thread Tomasz Zielonka
On Wed, Dec 07, 2005 at 04:09:31PM -0800, John Meacham wrote: you arn't using existential types here. an example with an existential type would be (in ghc syntax) data forall a . State = Start | Stop | (Show a, Eq a) = State a Shouldn't it be: data State = Start

Re: [Haskell-cafe] Existentially-quantified constructors, Eq and Show

2005-12-08 Thread John Meacham
On Thu, Dec 08, 2005 at 09:13:10AM +0100, Tomasz Zielonka wrote: Shouldn't it be: data State = Start | Stop | forall a . (Show a, Eq a) = State a ah. you are right. my bad. John -- John Meacham - ⑆repetae.net⑆john⑈ ___

Re: [Haskell-cafe] Verbosity of imperative code (was: Learning Haskell)

2005-12-08 Thread Robin Green
On Thursday 08 December 2005 07:33, you wrote: seqPair $= (,) or (the slightly less cryptic version) seqPair x y $= (x, y) Wouldn't they be different, the first one forcing (,) to WHNF (NOP), and the second one forcing x and y to WHNF? No. Oh, $= also breaks type inferencing :) So

Re: [Haskell-cafe] Existentially-quantified constructors, Eq and Show

2005-12-08 Thread Joel Reymont
Did someone actually try compiling this? Here are the results: data State a = Start | Stop | (Show a, Eq a) = State a deriving Show foo.hs:1:5: Can't make a derived instance of `Show (State a)' (`State' has existentially-quantified constructor(s)) When deriving

Re: [Haskell-cafe] Existentially-quantified constructors, Eq and Show

2005-12-08 Thread Joel Reymont
On Dec 8, 2005, at 12:09 AM, John Meacham wrote: if you are okay with a being an argument then data State a = Start | Stop | State a deriving(Show,Eq) will do what you want I believe. This does the trick! Thank you! -- http://wagerlabs.com/

Re: [Haskell-cafe] Mixing C++ and Haskell, OpenSSL thread safety, and using mmap

2005-12-08 Thread Joel Reymont
I use OpenSSL in a heavily threaded environment. It works without extra locking. I do not use bound (OS) threads, though. On Dec 8, 2005, at 7:06 AM, Branimir Maksimovic wrote: First I want to say about OpenSSL thread safety. It is not thread safe by default. Who wants to import and use

Re: [Haskell-cafe] Mixing C++ and Haskell, OpenSSL thread safety, and using mmap

2005-12-08 Thread Branimir Maksimovic
From: Joel Reymont [EMAIL PROTECTED] To: Branimir Maksimovic [EMAIL PROTECTED] CC: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Mixing C++ and Haskell, OpenSSL thread safety, and using mmap Date: Thu, 8 Dec 2005 09:21:08 + I use OpenSSL in a heavily threaded environment. It

Re: [Haskell-cafe] Existentially-quantified constructors, Eq and Show

2005-12-08 Thread Joel Reymont
Here is something else that I don't quite understand... Original version compiles: push :: Show b = State b - Dispatcher b a - (ScriptState a b) () push state dispatcher = do w - get trace 95 $ push: Pushing ++ show state ++ onto the stack let s = stack w putStrict $

Re: [Haskell-cafe] Mixing C++ and Haskell, OpenSSL thread safety, and using mmap

2005-12-08 Thread Joel Reymont
I only lock around the connectTo to avoid the gethostbyname issue. After that I set up two memory BIOs and hook them to go through a handshake. Encryption is done through the BIOs afterwards since I need to wrap the encrypted data in a header of my own (don't ask). I haven't had a problem

Re: [Haskell-cafe] Existentially-quantified constructors, Eq and Show

2005-12-08 Thread Cale Gibbard
data (Eq a, Show a) = State a = Start | Stop | State a deriving Show Putting the class context on the data constructor like that wasn't doing you any more good than this way, and was causing ghc to think that the constructor was existentially quantified. - Cale On 08/12/05, Joel Reymont [EMAIL

Re: [Haskell-cafe] Existentially-quantified constructors, Eq and Show

2005-12-08 Thread Cale Gibbard
Okay, so here you *did* get something from the existential typing :) The type of show, restricted to State in the original version is: show :: Show a = State a - String Now, in the new version, you get the type: show :: (Eq a, Show a) = State a - String because what happens is that pattern

[Haskell-cafe] RE: [Haskell] fptools mirror in darcs ready for testing

2005-12-08 Thread Simon Marlow
On 07 December 2005 13:06, John Goerzen wrote: On Wed, Dec 07, 2005 at 11:02:29AM +, Duncan Coutts wrote: Also please note that these repos are READ ONLY for now. Nobody will be accepting darcs patches until Simon (or someone) gives the word. When that does happen, it'd be great if

[Haskell-cafe] String to Hash ?

2005-12-08 Thread raptor
I have made a simple Split function, here is how it works : str = k1=v1|k2=v2|k3=v3 map (sSplit '=') (sSplit '|' str) [[k1,v1],[k2,v2],[k3,v3]] Now what I want to do is to return listOfPairs (instead listOflists) so that I can give this as parameter to Data.Map.fromList and build hash-like

Re[2]: [Haskell-cafe] Existentially-quantified constructors, Eq and Show

2005-12-08 Thread Bulat Ziganshin
Hello Joel, Thursday, December 08, 2005, 12:26:52 PM, you wrote: JR I was also hoping that something like this would let me avoid JR quantifying a in functions downstream but alas, it does not happen. I JR have to use (Eq a, Show a) = a ... everywhere else. to avoid context declarations you

Re: Re[2]: [Haskell-cafe] Existentially-quantified constructors, Eq and Show

2005-12-08 Thread Joel Reymont
Doesn't this have an effect on performance? Is GHC still able to optimize things properly? On Dec 8, 2005, at 10:20 AM, Bulat Ziganshin wrote: Hello Joel, Thursday, December 08, 2005, 12:26:52 PM, you wrote: JR I was also hoping that something like this would let me avoid JR quantifying a

Re: [Haskell-cafe] Existentially-quantified constructors, Eq and Show

2005-12-08 Thread Benjamin Franksen
On Thursday 08 December 2005 09:36, John Meacham wrote: On Thu, Dec 08, 2005 at 09:13:10AM +0100, Tomasz Zielonka wrote: Shouldn't it be: data State = Start | Stop | forall a . (Show a, Eq a) = State a ah. you are right. my bad. But this is a rank-2 type, not an

Re: [Haskell-cafe] Verbosity of imperative code (was: Learning Haskell)

2005-12-08 Thread Henning Thielemann
On Wed, 7 Dec 2005, J. Garrett Morris wrote: On 12/7/05, Robin Green [EMAIL PROTECTED] wrote: Let's say you want to write a function seqPair :: (Monad m) = (m a, m b) - m (a, b) which returns a computation which does the left computation followed by the right computation (i.e. it's

Re: [Haskell-cafe] Differences in optimisiation with interactive and compiled mode

2005-12-08 Thread Cale Gibbard
GHCi does things with optimisations off. Note the line on startup which says: Compiling Main ( search.hs, interpreted ) You'll have better luck if you compile the code with optimisations and keep the .o files around when running the program in ghci -- it will notice the compiled copies

[Haskell-cafe] Re: [darcs-conflicts] how to nicely implement phantom type coersion?

2005-12-08 Thread Ian Lynagh
On Thu, Dec 08, 2005 at 09:23:22AM -0500, David Roundy wrote: data EqContext a b = EqContext { safe_coerce :: f(a,b) - f(b,a) } where f(a,b) is a function of two types that returns a type, so the value of f(a,b) might be (Patch a b) or (Patch x b) or something like that. But I'm not sure

Re: [Haskell-cafe] String to Hash ?

2005-12-08 Thread raptor
Is there in standard libraries functions that do structure transformations ? just curious... |Write a function: | |list_to_pair :: [a] - (a,a) | |and then map it over the list of lists: | |map list_to_pair your_resulting_list_of_lists | |HTH, |Ben ___

Re: [Haskell-cafe] String to Hash ?

2005-12-08 Thread Cale Gibbard
Not this one in particular, but there are various functions throughout the libraries which do all sorts of structural transformations on lists and other types. Have a look at the Prelude and Data.List module in the libraries documentation at http://www.haskell.org/ghc/docs/latest/html/libraries/

Re: [Haskell-cafe] Verbosity of imperative code (was: Learning Haskell)

2005-12-08 Thread J. Garrett Morris
On 12/8/05, Robin Green [EMAIL PROTECTED] wrote: Sure, I take your point. But I just jumped on my latest hobby-horse: verbosity of imperative code is not that necessary. There was a discussion along these lines some time ago, started by Frederik Eaton with the subject line Mixing monadic and

Re: [Haskell-cafe] Can't Haskell catch up with Clean's uniqueness typing?

2005-12-08 Thread Wolfgang Jeltsch
Am Donnerstag, 8. Dezember 2005 04:00 schrieb Jan-Willem Maessen: On Dec 7, 2005, at 9:58 AM, Wolfgang Jeltsch wrote: Am Mittwoch, 7. Dezember 2005 14:21 schrieb Jan-Willem Maessen: [...] The principle obstacles are the same as for any reference counting scheme: It imposes more

Re: [Haskell-cafe] Can't Haskell catch up with Clean's uniqueness typing?

2005-12-08 Thread haskell-cafe . mail . zooloo
- Original Message - From: Wolfgang Jeltsch - [EMAIL PROTECTED] Sent: Thursday, December 08, 2005 6:13 PM I thought that the original question was about using some kind of uniqueness type system at an intermediate stage during compiling. Haskell would still have no uniqueness

Re: [Haskell-cafe] Can't Haskell catch up with Clean's uniqueness typing?

2005-12-08 Thread haskell-cafe . mail . zooloo
- Original Message - From: Tomasz Zielonka - [EMAIL PROTECTED] Sent: Wednesday, December 07, 2005 8:53 PM Clean-like _explicit_ uniqueness typing is not what I'm asking for in Haskell. So you want implicit, automatically inferred uniqueness typing - something that would be

Re: [Haskell-cafe] Differences in optimisiation with interactive and compiled mode

2005-12-08 Thread Henning Thielemann
On Thu, 8 Dec 2005, Branimir Maksimovic wrote: program performs search replace on a String http://www.haskell.org/pipermail/haskell-cafe/2005-April/009692.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Can't Haskell catch up with Clean's uniqueness typing?

2005-12-08 Thread haskell-cafe . mail . zooloo
- Original Message - From: Tomasz Zielonka - [EMAIL PROTECTED] Sent: Wednesday, December 07, 2005 8:53 PM Clean-like _explicit_ uniqueness typing is not what I'm asking for in Haskell. So you want implicit, automatically inferred uniqueness typing - something that would be even

Re: [Haskell-cafe] Can't Haskell catch up with Clean's uniqueness typing?

2005-12-08 Thread Wolfgang Jeltsch
Am Donnerstag, 8. Dezember 2005 13:08 schrieb [EMAIL PROTECTED]: [...] A uniqueness checker can be rather robust, as is demonstrated by the Clean one, so all we'd have to worry about is how to find a good set of supposedly unique node candidates to suggest to the checker. (It certainly would

Re: [Haskell-cafe] Can't Haskell catch up with Clean's uniqueness typing?

2005-12-08 Thread Wolfgang Jeltsch
Am Donnerstag, 8. Dezember 2005 18:38 schrieb [EMAIL PROTECTED]: [...] p.p.s.: I've sent this mail a second time because the first one got lost somehow - hopefully, it doesn't show up again. Concerning me, your first mail wasn't lost. I got this mail two times. Best wishes, Wolfgang

Re: [Haskell-cafe] Re: [Haskell] fptools mirror in darcs ready for testing

2005-12-08 Thread Wolfgang Jeltsch
Am Donnerstag, 8. Dezember 2005 16:56 schrieb John Goerzen: [...] I have never worked much with these web front-ends. My understanding is that Trac is probably not the most efficient front-end to darcs, as it tries to put things in a more svn-like model. I wonder if one of the other

[Haskell-cafe] Indenting issue with Haskell mode

2005-12-08 Thread Joel Reymont
I believe the following is not indented correctly. It only happens with (x:xs) when you use nested cases, I think. case foo of [] - case bar of [] - return () (x:xs) - -- http://wagerlabs.com/ ___ Haskell-Cafe

Re: [Haskell-cafe] Can't Haskell catch up with Clean's uniqueness typing?

2005-12-08 Thread haskell-cafe . mail . zooloo
On Thu, Dec 08, 2005 at 06:38:53PM +0100, [EMAIL PROTECTED] wrote: - Original Message - From: Tomasz Zielonka - [EMAIL PROTECTED] Sent: Wednesday, December 07, 2005 8:53 PM Clean-like _explicit_ uniqueness typing is not what I'm asking for in Haskell. So you want implicit,

[Haskell-cafe] Re: syntactic sugar for comonads

2005-12-08 Thread Geoffrey Alan Washburn
Scherrer, Chad wrote: I'm wondering about a syntactic sugar for comonads. These are still very new to me, but it seems like their usage will become much more common once manipulations are more convenient (I believe this was the case with monads and arrows, correct?). I'm actually rather

[Haskell-cafe] Re: Indenting issue with Haskell mode

2005-12-08 Thread Stefan Monnier
I believe the following is not indented correctly. It only happens with (x:xs) when you use nested cases, I think. case foo of [] - case bar of [] - return () (x:xs) - Thanks. The indentation indeed works particularly poorly here in ways that I hadn't

Re: [Haskell-cafe] Can't Haskell catch up with Clean's uniqueness typing?

2005-12-08 Thread Jeremy Shaw
Clean-like _explicit_ uniqueness typing is not what I'm asking for in Haskell. So you want implicit, automatically inferred uniqueness typing - something that would be even more fragile and sensitive then current Haskell's space problems arising from laziness? ;-) Why should

Re: [Haskell-cafe] Can't Haskell catch up with Clean's uniqueness typing?

2005-12-08 Thread Tomasz Zielonka
On Thu, Dec 08, 2005 at 11:29:44AM -0800, Jeremy Shaw wrote: Why should inferring uniqueness be all that fragile? A uniqueness checker can be rather robust, as is demonstrated by the Clean one. Fragile could refer to the fact that a relatively small looking change to your code could

[Haskell-cafe] busting up a structured binary file

2005-12-08 Thread Brian McQueen
Can someone point me to a sample so I can get started? This will be my first Haskkel project, after reading about it for some months now. I need to extract text from a structed binary file. Its a local database for a commercial app of proprietary structure, though the structure has been

Re: [Haskell-cafe] Can't Haskell catch up with Clean's uniqueness typing?

2005-12-08 Thread Duncan Coutts
On Thu, 2005-12-08 at 11:29 -0800, Jeremy Shaw wrote: Why should inferring uniqueness be all that fragile? A uniqueness checker can be rather robust, as is demonstrated by the Clean one. Fragile could refer to the fact that a relatively small looking change to your code could have a

[Haskell-cafe] preffered 'map'

2005-12-08 Thread raptor
hi, I imported : import Data.Map as Map but now anywhere when I want ot use map it complains for name clashes, so I have to specifiy Prelude.map all the time. Is there a way to specify that i mean Prelude not Data 'map' (but not fqn) I use Hugs, 'cause error messages are more understandable.

Re: [Haskell-cafe] Can't Haskell catch up with Clean's uniqueness typing?

2005-12-08 Thread Philippa Cowderoy
On Thu, 8 Dec 2005, Duncan Coutts wrote: For example it's not currently convenient to find out the strictness that ghc infers for functions (though it is possible). Ideally an IDE or something would be able to present this sort of information along with the inferred type etc. It'd be nice

Re: [Haskell-cafe] preffered 'map'

2005-12-08 Thread Duncan Coutts
On Fri, 2005-12-09 at 00:24 +0200, raptor wrote: hi, I imported : import Data.Map as Map but now anywhere when I want ot use map it complains for name clashes, so I have to specifiy Prelude.map all the time. Is there a way to specify that i mean Prelude not Data 'map' (but not fqn) I

Re[4]: [Haskell-cafe] Existentially-quantified constructors, Eq and Show

2005-12-08 Thread Bulat Ziganshin
Hello Joel, better to ask Simon. if automatically determined type is more generic than you really need, this can something slow program. but i think that generally this have no big impact, because many functions are just inlined and, theoretically, can be specialized just at inlining place

Re: [Haskell-cafe] Can't Haskell catch up with Clean's uniqueness typing?

2005-12-08 Thread haskell-cafe . mail . zooloo
- Original Message - From: Duncan Coutts - [EMAIL PROTECTED] Sent: Thursday, December 08, 2005 9:09 PM On Thu, 2005-12-08 at 11:29 -0800, Jeremy Shaw wrote: The only case it is a benefit is when it accidentally happens and it's just a bonus, but in that case you never needed the

Re: [Haskell-cafe] how to nicely implement phantom type coersion?

2005-12-08 Thread Thomas Jäger
Hello, Since you're already using GADTs, why not also use them to witness type equality: import GHC.Exts data Patch a b = Patch Int Int data Sequential a c where Sequential :: Patch a b - Patch b c - Sequential a c data MaybeEq :: * - * - * where NotEq :: MaybeEq a b IsEq :: MaybeEq

[Haskell-cafe] STM reference?

2005-12-08 Thread Scherrer, Chad
Hi, Can anyone suggest some references to learn how to program using GHC with threads? I've read a little bit about STM, but it's still pretty mysterious to me. Is this the best approach to take? I've never used threads in any language, but monads are fairly comfortable for me. Thanks! Chad

Re: [Haskell-cafe] Can't Haskell catch up with Clean's uniqueness typing?

2005-12-08 Thread Tomasz Zielonka
On Thu, Dec 08, 2005 at 09:59:25PM +0100, [EMAIL PROTECTED] wrote: p.s.: Strangely, Tomasz's reply again appears as being sent from my address in the archive. Anyone knows why? Maybe mailman is somehow confused by this weird address: xoxy = haskell-cafe [EMAIL PROTECTED] ? Best regards

[Haskell-cafe] Re: [darcs-conflicts] how to nicely implement phantom type coersion?

2005-12-08 Thread Jim Apple
Ralf Hinze wrote: the type a :=: b defined below goes back to Leibniz's principle of substituting equals for equals: If you like this, check out two of Ralf's papers: First-class phantom types: http://techreports.library.cornell.edu:8081/Dienst/UI/1.0/Display/cul.cis/TR2003-1901 Fun with

Re: [Haskell-cafe] STM reference?

2005-12-08 Thread Bulat Ziganshin
Hello Chad, Friday, December 09, 2005, 3:09:29 AM, you wrote: SC Can anyone suggest some references to learn how to program using GHC SC with threads? I've read a little bit about STM, but it's still pretty SC mysterious to me. Is this the best approach to take? I've never used SC threads in any