Re: [Haskell-cafe] Defining types (newbie)

2007-03-14 Thread Bryan O'Sullivan
John Fouhy wrote: But if I want to combine tcEqOne and tcGtThree I run into type problems, because one of them uses Strings and the other Integers. Yep. The observation you can make here is that TC is really a fancy way to write a function that takes some parameters and returns a Bool. So

[Haskell-cafe] Re: Foralls in records

2007-03-14 Thread apfelmus
Adde wrote: I'm experimenting with implementing database transactions as monads but I'm getting stuck on how to store a generic connection (only constrained by a typeclass) inside the transaction. The reason I'm doing it this way is that the connection could be a different kind of structure

[Haskell-cafe] Re: Defining types (newbie)

2007-03-14 Thread apfelmus
John Fouhy wrote: [...] data Thing = Thing { field_one :: String, field_two :: String, field_three :: Integer } type BooleanOp a = a - a - Bool type Field a = Thing - a data ThingCompare a = TC (BooleanOp a) (Field a) | And (ThingCompare a) (ThingCompare a)

Re: [Haskell-cafe] c2hs and pthreadtypes.h

2007-03-14 Thread Magnus Therning
On Wed, Mar 14, 2007 at 12:27:10 +1100, Duncan Coutts wrote: [..] Yes, I do have a C parser that can parse the linux kernel and that of course includes anonymous structs and unions. Currently I'm part way through merging these changes into the darcs version of c2hs. Excellent news! So, Magnus,

Re: [Haskell-cafe] Parallelism on concurrent?

2007-03-14 Thread Bjorn Bringert
On Mar 13, 2007, at 17:26 , Dusan Kolar wrote: Hello all, I'm googling around haskell.org to get some deeper knowledge about Control.Parallel.Strategies than it is presented on http:// www.haskell.org/ghc/docs/latest/html/libraries/base/Control- Parallel-Strategies.html BTW, could someone

[Haskell-cafe] Re: Foralls in records

2007-03-14 Thread Martin Huschenbett
Hi, instead of writing a function getTransaction that retrieves the connection you could write a function withConnection that doesn't return the connection itself but performs an operation on the connection: withConnection :: (forall c. Connection c = c - Transaction a) - Transaction

RE: [Haskell-cafe] Read Instance for UArray won't port to linux

2007-03-14 Thread Simon Peyton-Jones
| The error in linux is: | Illegal instance declaration for `Read (UArray Int Double)' | (The instance type must be of form (T a b c) | where T is not a synonym, and a,b,c are distinct type variables) | In the instance declaration for `Read (UArray Int Double)' | | Why

Re: [Haskell-cafe] Read Instance for UArray won't port to linux

2007-03-14 Thread Björn Bringert
Simon Peyton-Jones wrote: | The error in linux is: | Illegal instance declaration for `Read (UArray Int Double)' | (The instance type must be of form (T a b c) | where T is not a synonym, and a,b,c are distinct type variables) | In the instance declaration for `Read

[Haskell-cafe] Re: Foralls in records

2007-03-14 Thread Adde
Martin Huschenbett huschi at gmx.org writes: Hi, instead of writing a function getTransaction that retrieves the connection you could write a function withConnection that doesn't return the connection itself but performs an operation on the connection: withConnection ::

Re: [Haskell-cafe] Re: Foralls in records

2007-03-14 Thread Chris Kuklewicz
I can't seem to find any examples of how to actually implement liftIO for a monad. Any ideas/pointers? Searching the haskell wiki for MonadIO gives several examples. http://haskell.org/haskellwiki/New_monads/MonadExit instance MonadIO m = MonadIO (ExitT e m) where liftIO = lift .

[Haskell-cafe] Re: Foralls in records

2007-03-14 Thread Adde
Matthew Brecknell haskell at brecknell.org writes: Since the concrete type has been forgotten, there's no way to get it back. You can't write a function that exposes the forgotten type, so getConnection is basically a lost cause. When you write getConnection :: Transaction c, you are saying

[Haskell-cafe] Re: ANN: HSH 1.2.0

2007-03-14 Thread John Goerzen
On 2007-03-13, Brandon Michael Moore [EMAIL PROTECTED] wrote: On Mon, Mar 12, 2007 at 05:14:57PM -0500, John Goerzen wrote: You can do this with runProcess, if you use System.Posix.IO.{createPipe,fdToHandle} to make a pipe and wrap the ends as handles. I hope hCreatePipe could be implemented

[Haskell-cafe] Re: Foralls in records

2007-03-14 Thread Adde
Do you want to mix differently typed Connections inside a single transaction? It looks like you don't, so you may well leave out existential types altogether and simply parametrize the Transaction monad on the type of the connection it uses. data Connection c = TransactionState c = TS c

lazily handling exceptions in lazy sources (Re: [Haskell-cafe] Re: Takusen and strictness, and perils of getContents)

2007-03-14 Thread Claus Reinke
Is this really a solution? Currently, getContents reports no errors but does perfect error recovery: the result of the computation prior to the error is preserved and reported to the caller. Imprecise exceptions give us error reporting -- but no error recovery. All previously computed results are

[Haskell-cafe] principle types

2007-03-14 Thread Vikrant
Hi, I can understand why principle type of map is map :: (a - b) - [a] - [b] , I would interpret this as map takes a function of type a-b and a list of type [a] as arguments and returns a list of type [b] but it is going somewhat beyond my imagination why principle type of map map is (map

Re: [Haskell-cafe] principle types

2007-03-14 Thread Paul Johnson
Vikrant wrote: (map map)::[a - b] - [[a] - [b]] I am able to interpret the expressions [a - b] - [[a] - [b]] vaguely... does this mean that 'map map' takes list of functions of type (a-b) and returns list of functions of type ([a]-[b]) if yes ..how do I derive it from basic type

Re: [Haskell-cafe] principle types

2007-03-14 Thread Jules Bean
Vikrant wrote: Hi, I can understand why principle type of map is map :: (a - b) - [a] - [b] , I would interpret this as map takes a function of type a-b and a list of type [a] as arguments and returns a list of type [b] but it is going somewhat beyond my imagination why principle type

Re: [Haskell-cafe] principle types

2007-03-14 Thread Big Chris
Hi Vikrant, The other two have said basically the same thing as me, but your description of map's type makes me think maybe an explanation of curried functions is in order: map is what's called a curried function. Basically, the type: (a - b) - [a] - [b] has two interpretations. The

RE: [Haskell-cafe] Read Instance for UArray won't port to linux

2007-03-14 Thread Simon Peyton-Jones
Ah, a fine idea. I'll do that anyway; maybe others will have even better ideas, but that's a good start S | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Björn | Bringert | Sent: 14 March 2007 14:28 | To: Simon Peyton-Jones | Cc:

[Haskell-cafe] Re: Foralls in records

2007-03-14 Thread apfelmus
Adde wrote: Do you want to mix differently typed Connections inside a single transaction? It looks like you don't, so you may well leave out existential types altogether and simply parametrize the Transaction monad on the type of the connection it uses. data Connection c = TransactionState

Re[2]: [Haskell-cafe] Read Instance for UArray won't port to linux

2007-03-14 Thread Bulat Ziganshin
Hello Bjorn, Wednesday, March 14, 2007, 5:27:35 PM, you wrote: I'm not the original poster, but what about just changing it to The instance type must be of the form (T a1 ... an) where T is not a synonym, and a1 ... an are distinct type variables)? or even better, are distinct type

Re: [Haskell-cafe] Read Instance for UArray won't port to linux

2007-03-14 Thread Alex Queiroz
Hallo, On 3/14/07, Simon Peyton-Jones [EMAIL PROTECTED] wrote: Ah, a fine idea. I'll do that anyway; maybe others will have even better ideas, but that's a good start Ah! So now I knows what it means. I've also been beaten by this error message a couple of days ago. Cheers, -- -alex

[Haskell-cafe] Re: Foralls in records

2007-03-14 Thread Adde
Chris Kuklewicz haskell at list.mightyreason.com writes: Searching the haskell wiki for MonadIO gives several examples. http://haskell.org/haskellwiki/New_monads/MonadExit instance MonadIO m = MonadIO (ExitT e m) where liftIO = lift . liftIO Where you can see you are just

Re: [Haskell-cafe] Read Instance for UArray won't port to linux

2007-03-14 Thread Dan Piponi
On 3/14/07, Simon Peyton-Jones [EMAIL PROTECTED] wrote: However, you mis-read the error message to say the instance type must have three parameters, which isn't what I meant at all! I was trying to use an example of the general form, but conveyed the wrong idea. Oh! I've been wondering

[Haskell-cafe] Re: small boys performance

2007-03-14 Thread apfelmus
-- redirected from haskell.general Andrzej Jaworski wrote: As I regretfully pointed out earlier in [Fwd: Re: Computer Language Shootout] large search and simulations are not for Haskell. This is equally true with GHC 6.5 http://eric_rollins.home.mindspring.com/haskellAnt.html. Indeed,

Re: [Haskell-cafe] Read Instance for UArray won't port to linux

2007-03-14 Thread SevenThunders
You guys are awesome! I post this not 12 hours ago and I already have a complete treatise on the subject. Yeah to clarify things putting an ellipsis between b and c would help. But also clarify the meaning of distinct type variables. Does this mean the type variable must not be parameterized?

Re[2]: [Haskell-cafe] Read Instance for UArray won't port to linux

2007-03-14 Thread Bulat Ziganshin
Hello SevenThunders, Wednesday, March 14, 2007, 10:32:23 PM, you wrote: the type variables are dark side of GHC, and you need to have at least 1 mlOleg of brain to understand them. it will be great if someone will ever write reasonable introduction into this. meanwhile, you can look into ghc

[Haskell-cafe] Lazy IO and closing of file handles

2007-03-14 Thread Pete Kazmier
When using readFile to process a large number of files, I am exceeding the resource limits for the maximum number of open file descriptors on my system. How can I enhance my program to deal with this situation without making significant changes? My program takes one or more directories that

Re: [Haskell-cafe] Lazy IO and closing of file handles

2007-03-14 Thread Donald Bruce Stewart
pete-expires-20070513: When using readFile to process a large number of files, I am exceeding the resource limits for the maximum number of open file descriptors on my system. How can I enhance my program to deal with this situation without making significant changes? Read in data strictly,

[Haskell-cafe] Re: Lazy IO and closing of file handles

2007-03-14 Thread Pete Kazmier
[EMAIL PROTECTED] (Donald Bruce Stewart) writes: pete-expires-20070513: When using readFile to process a large number of files, I am exceeding the resource limits for the maximum number of open file descriptors on my system. How can I enhance my program to deal with this situation without

[Haskell-cafe] Re: [Haskell] small boys performance

2007-03-14 Thread Dan Piponi
On 3/14/07, Andrzej Jaworski [EMAIL PROTECTED] wrote: I am glad you are interested Dan. ... I do not intend to bore anybody with differential geometry but as I was pushed that far let me add that if Haskell was made to handle Riemannian geometry it could be useful in next generation machine

Re: [Haskell-cafe] Re: Lazy IO and closing of file handles

2007-03-14 Thread Donald Bruce Stewart
pete-expires-20070513: [EMAIL PROTECTED] (Donald Bruce Stewart) writes: pete-expires-20070513: When using readFile to process a large number of files, I am exceeding the resource limits for the maximum number of open file descriptors on my system. How can I enhance my program to deal

Re: [Haskell-cafe] Re: Lazy IO and closing of file handles

2007-03-14 Thread Dougal Stanton
Quoth Pete Kazmier, nevermore, the same error regarding max open files. Incidentally, the lazy bytestring version of my program was by far the fastest and used the least amount of memory, but it still crapped out regarding max open files. I've tried the approach you appear to be using and

[Haskell-cafe] How to convert Num a = a to Int

2007-03-14 Thread Sergey Perminov
As a beginner I want to implement such fuction: plusSecs :: Num a = a - ClockTime - ClockTime plusSecs n = addToClockTime ( secTimeDiff (n) ) where secTimeDiff n = TimeDiff { tdYear = 0, tdMonth = 0,

Re: [Haskell-cafe] How to convert Num a = a to Int

2007-03-14 Thread Brandon S. Allbery KF8NH
On Mar 14, 2007, at 19:30 , Sergey Perminov wrote: So, the question is: Is it possible somehow to convert any Num (or at least Integral) to Int. Please, tell me if I don't get smth in Haskell type system. fromIntegral. Try http://haskell.org/hoogle for searching for useful functions like

[Haskell-cafe] SYB vs HList (again)

2007-03-14 Thread S. Alexander Jacobson
Right now I am looking at using either SYB (Scrap Your Boilerplate) or HList Records to eliminate boilerplate for: * parsing URLEncoded strings into application data structures * generating XML/JSON from application data structures * handling adding new fields to serialized data

Re: [Haskell-cafe] Lazy IO and closing of file handles

2007-03-14 Thread Greg Fitzgerald
Pete, mapM fileContentsOfDirectory = mapM_ print . threadEmails . map parseEmail . concat By using the IO monad you've /scheduled/ your first 'print' to occur after your last 'readFile', so every file is opened before the first file is read. I've come across the same problem and

Re: [Haskell-cafe] Lazy IO and closing of file handles

2007-03-14 Thread Matthew Brecknell
Pete Kazmier: When using readFile to process a large number of files, I am exceeding the resource limits for the maximum number of open file descriptors on my system. How can I enhance my program to deal with this situation without making significant changes? AFAIU, file handles opened by

Re: [Haskell-cafe] Lazy IO and closing of file handles

2007-03-14 Thread David Brown
Greg Fitzgerald wrote: What we need is a library for a readonly filesystem. That is, all the same functions but pure. I believe you could make this readonly library by wrapping each readonly I/O function with 'unsafeInterleaveIO' or 'unsafePerformIO', but I don't really understand the

Re: [Haskell-cafe] How to convert Num a = a to Int

2007-03-14 Thread Albert Y. C. Lai
Moreover: from RealFrac to Int (or Integral): truncate, round, ceiling, or floor, depending on how you want to lose information. from Num to Int: there is none with such generality, since there are too many conceivable variations. ___

Re: [Haskell-cafe] Lazy IO and closing of file handles

2007-03-14 Thread Claus Reinke
When using readFile to process a large number of files, I am exceeding the resource limits for the maximum number of open file descriptors on my system. How can I enhance my program to deal with this situation without making significant changes? .. 1. Read contents of all files returning a

[Haskell-cafe] N and R are categories, no?

2007-03-14 Thread Steve Downey
EOk, i'm trying to write down, not another monad tutorial, because I don't know that much yet, but an explication of my current understanding of monads. But before I write down something that is just flat worng, I thought I'd get a cross check. (and I can't get to #haskell) Monads are Functors.

Re: [Haskell-cafe] Re: Foralls in records

2007-03-14 Thread Matthew Brecknell
Adde: Thanks, using pattern matching to avoid mentioning the type didn't even cross my mind. You are correct in assuming that I thought I could get away with getConnection :: Connection c = Transaction c. To be honest, I still don't understand why it's too polymorphic. To me it says

Re: [Haskell-cafe] Read Instance for UArray won't port to linux

2007-03-14 Thread Steve Downey
It's not just type variables. Type classes looked innocent, but smuggled an entire turing complete generic meta computation system into the language. Just thank SIMON that the error messages aren't as bad as C++ and templates. This does imply that mOleg have some equivalence relation to

Re: [Haskell-cafe] Re: small boys performance

2007-03-14 Thread Steve Downey
Many years ago, I got a B- in abstract algebra, and an A+ in differential geometry. Now I know why I worry about the blue glow of an unplanned criticality excursion occuring in my brain. On 3/14/07, Dan Piponi [EMAIL PROTECTED] wrote: On 3/14/07, Andrzej Jaworski [EMAIL PROTECTED] wrote: I

Re: [Haskell-cafe] Lazy IO and closing of file handles

2007-03-14 Thread Donn Cave
When using readFile to process a large number of files, I am exceeding the resource limits for the maximum number of open file descriptors on my system. How can I enhance my program to deal with this situation without making significant changes? I note that if you use mmap(2) to map a disk

Re: [Haskell-cafe] principle types

2007-03-14 Thread Vikrant
woow :) I am loving this language. Thank you all for very useful hints and thanks for the exercise about map.map! On 14/03/07, Big Chris [EMAIL PROTECTED] wrote: Hi Vikrant, The other two have said basically the same thing as me, but your description of map's type makes me think maybe an

Re: [Haskell-cafe] Lazy IO and closing of file handles

2007-03-14 Thread Donald Bruce Stewart
donn: When using readFile to process a large number of files, I am exceeding the resource limits for the maximum number of open file descriptors on my system. How can I enhance my program to deal with this situation without making significant changes? I note that if you use mmap(2) to

Re: [Haskell-cafe] Lazy IO and closing of file handles

2007-03-14 Thread Donn Cave
Quoth [EMAIL PROTECTED] (Donald Bruce Stewart): ... | In fact, the (commented out code) for mmapFile :: FilePath - IO ByteString | is in Data.ByteString now. You can also provide munmap as the finaliser, | and let the GC take care of that. It does make more sense to unmap the string when it's the

[Haskell-cafe] Jaskell, has anybody tried it?

2007-03-14 Thread Lars Johansson
Hello, I have installed the Jaskell libraries for java under Eclipse, but I can't get it running and the documentation on installing is really sparse. So any help I will apprreciate. Or any ideas! Sincerely Lars Johansson