Re: In search of: [a->b] -> a -> [b]

2003-06-17 Thread Derek Elkins
On Tue, 17 Jun 2003 21:01:57 +0100 Graham Klyne <[EMAIL PROTECTED]> wrote: > I'm convinced I've seen a function like this somewhere: >[a->b] -> a -> [b] > but cannot remember where. Or maybe: >Monad m => m (a->b) -> a -> m b > ? > > I could roll my own (*), but I'm trying not to duplicat

In search of: [a->b] -> a -> [b]

2003-06-17 Thread Graham Klyne
I'm convinced I've seen a function like this somewhere: [a->b] -> a -> [b] but cannot remember where. Or maybe: Monad m => m (a->b) -> a -> m b ? I could roll my own (*), but I'm trying not to duplicate standard library functions is I can help it. Any pointers? #g -- (*) flist :: [a->b

ICFP Programming Contest

2003-06-17 Thread John Hughes
ICFP Programming Contest There are just ten days to go to the sixth ICFP Programming Contest! Starting at midnight on Saturday morning, June 28th, you can prove once again that your favourite programming language is "the programming tool of choice for discriminating hacker

Re: Type classes and code generation

2003-06-17 Thread Keith Wansbrough
> Does this also mean that a dictionary class is created for every class, and > a dictionary created for every instance? Yes, exactly. Every class is translated to a data type declaration, and every instance is translated to an element of that data type - a dictionary. (Note that you can't act

Re: Type classes and code generation

2003-06-17 Thread Andreas Rossberg
Bayley, Alistair wrote: When it's applied, the compiler will know the types of the arguments, won't it?. Which means that you would generate a version of double for each (applied) instance of Num. I don't doubt that there's a good reason this is not done: code bloat? or are there simply some expres

RE: Type classes and code generation

2003-06-17 Thread Bayley, Alistair
> > Is there > > some way of preventing the type mechanism from generating > code for the > > instance type, as opposed to the class? > > I don't understand this question - does the explanation above help? I could have been clearer with my questions. What I was wondering was: is there some sit

Re: C++ class structure mapping

2003-06-17 Thread Derek Elkins
On Tue, 17 Jun 2003 09:07:06 +0100 Alastair Reid <[EMAIL PROTECTED]> wrote: > On Tuesday 17 June 2003 2:33 am, Abraham Egnor wrote: > > I'd like to make a haskell binding for a C++ library. Most of the > > tools out there seem oriented towards c bindings, so it looks like > > I'll be writing the

RE: C++ class structure mapping

2003-06-17 Thread Daan Leijen
Dear Abraham, > Now comes the question of how to map a C++ class hierarchy > into haskell. > It seems natural to try to map C++ classes into haskell typeclasses; > however, there are a few issues involved with that. You will quickly run into problems when doing that. The most important probl

Re: Type classes and code generation

2003-06-17 Thread Keith Wansbrough
Alistair Bayley writes: > Warning: Defaulting the following constraint(s) to type `Integer' >`Num a' arising from the literal `2' at Main.lhs:3 > > This implies to me that the compiler is generating the code for (+) for the > particular instance, rather than using a run-time dispa

Re: Type classes and code generation

2003-06-17 Thread Bernard James POPE
> I had a discussion with someone over the type class mechanism and would like > to clarify something. > > When I compile this trivial program: > > > module Main where > > main = putStrLn (show (1 + 2)) > > with ghc -Wall, the compiler says: > > Main.lhs:3: > Warning: Defaulting the followi

Type classes and code generation

2003-06-17 Thread Bayley, Alistair
I had a discussion with someone over the type class mechanism and would like to clarify something. When I compile this trivial program: > module Main where > main = putStrLn (show (1 + 2)) with ghc -Wall, the compiler says: Main.lhs:3: Warning: Defaulting the following constraint(s) to type

Re: C++ class structure mapping

2003-06-17 Thread Alastair Reid
On Tuesday 17 June 2003 2:33 am, Abraham Egnor wrote: > I'd like to make a haskell binding for a C++ library. Most of the tools > out there seem oriented towards c bindings, so it looks like I'll be > writing the FFI code generator myself. While I'm at it I figure I might > as well just make a ge

Re: Threads

2003-06-17 Thread Thomas L. Bevan
Strange. I have used this form many times without difficulties. Perhaps, it is a platform-dependant bug. Tom On Fri, 13 Jun 2003 03:33 pm, Filip wrote: > Hi, > > I have function > f:: a -> b > > and I need something like this: > > myaccept:: Socket -> IO () > myaccept g = do a <- accept g >