RE: infered type does not typecheck

2004-07-08 Thread Simon Peyton-Jones
Duncan Oleg's recent message to Haskell-Café tackles your real problem, but I thought I'd just say what is going on with your apparent bug below. Here's a much simpler example: class Foo a b where to :: a - b fro :: b - a -- foo :: forall b1 b a. (Foo a

[Haskell] SDL binding available.

2004-07-08 Thread Adrian Hey
Hello, I've put my Haskell bindings to SDL,SDL_Image, and SDL_TTF here.. http://homepages.nildram.co.uk/~ahey/HLibs/Multimedia.SDL.Core/ http://homepages.nildram.co.uk/~ahey/HLibs/Multimedia.SDL.Image/ http://homepages.nildram.co.uk/~ahey/HLibs/Multimedia.SDL.TTF/ It's not really as polished as

Re: [Haskell] Do the libraries define S' ?

2004-07-08 Thread Bernard James POPE
On Wed, Jul 07, 2004 at 01:18:54PM +0100, Graham Klyne wrote: There's a pattern of higher-order function usage I find myself repeatedly wanting to use, exemplified by the following: [[ -- combineTest :: (Bool-Bool-Bool) - (a-Bool) - (a-Bool) - (a-Bool) combineTest :: (b-c-d) - (a-b) -

Re: [Haskell] Do the libraries define S' ?

2004-07-08 Thread Conor T McBride
Hi folks Iavor S. Diatchki wrote: hi, you can use the reader (environment monad) for this. lately i have been using 2 combinators to do things like that (thanks to Thomas Hallgren for showing me this): -- a nicer name for fmap (or liftM if one prefers) (#) :: Functor f = (a - b) - f a - f b --

[Haskell] Separate Namespaces and Type Classes

2004-07-08 Thread Stephan Herhut
Hi all, I am pretty new to haskell, but while exploring the haskell module system, I came along some questions. As far as I found out, haskell supports separated namespaces, i.e. every module has its own symbol space. Thus, when defining a class in one module like module A(Foo(f)) where class

Re: [Haskell] Separate Namespaces and Type Classes

2004-07-08 Thread Ketil Malde
Stephan Herhut [EMAIL PROTECTED] writes: module B(bar) where instance Foo Integer where module C(tango) instance Foo Integer where import B(bar) import C(tango) But now, ghc complains about two instances of Foo Integer, although there should be none in the namespace main. I suspect

Re: [Haskell] Do the libraries define S' ?

2004-07-08 Thread Remi Turk
On Thu, Jul 08, 2004 at 03:47:08PM +1000, Bernard James POPE wrote: I use almost exactly the same thing in my code. And I nearly came up with the same names as you! (I have .. and .||.) I find them very useful in guards: foo x y | (this .. that) x = ... I don't believe this

[Haskell] CfP: IFL'04 16th International Workshop on Implementation and Application of Functional Languages

2004-07-08 Thread Clemens Grelck
We apologize if you receive multiple copies of this mail. Sincerely, Clemens Grelck and Frank Huch IFL'04 Announcement, Call for Papers and Call for Participation for the

Re: [Haskell] Do the libraries define S' ?

2004-07-08 Thread David Menendez
Conor T McBride writes: As some of you know, I like them a lot too. In fact, if you have a return-like thing and an ap-like thing, you can make fmap as well. (Note that the return for the environment monad is none other than S's best friend K.) So I got hacking, a little while ago...

[Haskell-cafe] Inferred type is not general enough

2004-07-08 Thread Ivan Tihonov
I start some ip networks related work in haskell and wrote two basic classes Location and Packet. Before writing IpLocation and IpPacket instances i have written simple TestLocation and TestPacket instances just to compile this and check for errors in class definitions. But looks like i

RE: [Haskell-cafe] Inferred type is not general enough

2004-07-08 Thread Stefan Holdermans
Ivan, It's the type of source and destination that is playing you parts. Let's write them explicitly quantified, source :: forall a b . (Packet a, Location b) = a - b destination :: forall a b . (Packet a, Location b) = a - b and reflect on this for a while. This basicly says that

Re: [Haskell-cafe] Inferred type is not general enough

2004-07-08 Thread Ben Lippmeier
Ivan, I don't yet know how to explain this formally, but I know how to fix your problem.. You need to add a parameter to the Packet class so the compiler knows what type to use for the Location. .. The following code works for me.. You'll need to use a compiler/interpreter which supports

RE: [Haskell-cafe] Inferred type is not general enough

2004-07-08 Thread Stefan Holdermans
Ivan, Oops ... SH and write the following function, knowing that SH TestPacket is an instance of Packet, SH SH getFoo:: Packet - Foo SH getFoo packet = source packet . Clearly, I meant to write getFoo :: TestPacket - Foo here. Regards, Stefan

Re: [Haskell-cafe] Inferred type is not general enough

2004-07-08 Thread Ivan Tihonov
Stefan Holdermans wrote: Huh. I'm really get stuck. Can someone write me working implementation of my crap? ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Inferred type is not general enough

2004-07-08 Thread Ben Lippmeier
Ivan.. Uh.. by 'works' I meant 'compiles' :) Here is a fixed version.. As I understand it, the 2 parameter class (Location loc = Packet p loc) means loc is a Location, and types p and loc are related by class Packet with just that information, if you try (as you did) something like $ source

RE: [Haskell-cafe] Inferred type is not general enough

2004-07-08 Thread Stefan Holdermans
Ivan, IT Stefan Holdermans wrote: IT IT Huh. I'm really get stuck. Can someone write me working IT implementation of my crap? Huh? Did *I* wrote that ... ? ;) \begin{code} {-# -OPTIONS -fglasgow-exts #-} class Location a where point :: a - String class (Location b) = Packet a b

Re: [Haskell-cafe] Inferred type is not general enough

2004-07-08 Thread Glynn Clements
Ivan Tihonov wrote: I start some ip networks related work in haskell and wrote two basic classes Location and Packet. Before writing IpLocation and IpPacket instances i have written simple TestLocation and TestPacket instances just to compile this and check for errors in class

Re: [Haskell-cafe] Inferred type is not general enough

2004-07-08 Thread Ivan Tihonov
thanks a lot, functional dependencies is my choice. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Of types and constructors; a question of programming style

2004-07-08 Thread Alastair Reid
It sounds a little as though you want a family of n-ary union type constructor. A crude first attempt would be: data Either2 t1 t2 = In1 t1 | In2 t2 data Either3 t1 t2 t3 = In1 t1 | In2 t2 | In3 t3 ... but this would be a bit tedious to use because the names are a bit meaningless -

[Haskell-cafe] List find-and-remove

2004-07-08 Thread Graham Klyne
Once again, I find myself making code that I think may exist somewhere in the libraries: [[ -- list find and remove extract0 :: (a-Bool) - [a] - Maybe (a,[a]) extract0 p as = ex [] as where ex seen (a:more) | p a = Just (a,revcat seen more) | otherwise =

RE: [Haskell-cafe] so how does one convert an IO a into an a ?

2004-07-08 Thread Stefan Holdermans
Crypt Master, CM Thanks for your help so far, but I am still not CM getting this IO stuff. After reading your CM previous help and reading several articles on CM it I still cant phathom how you convert the IO CM Int into an Int. Welcome to pure functional programming! :) Well, since

[Haskell-cafe] so how does one convert an IO a into an a ?

2004-07-08 Thread John Kozak
The root problem is that random number generation is inherently stateful, and so the familiar imperative idioms don't translate directly into a pure functional language. In a C-like language, each invocation of rand() mutates a secret piece of state lurking off-stage; pure functional code doesn't

[Haskell-cafe] In relation to shuffling

2004-07-08 Thread paolo veronelli
Most of my imperative pieces of software find their answers by touching around in some space of solutions and my favourite approximation algorithms use random distributions. Is it haskell the wrong languages for those, as I'm obliged to code them inside Monads loosing the benefits of lazyness?

Re: [Haskell-cafe] Of types and constructors; a question of programming style

2004-07-08 Thread Graham Klyne
My original question was related to use of existing facilities. I find it somewhat surprising how rich and complex a language Haskell turns out to be. I'm wary of yet more features. That said, you seem to be suggesting a kind of anonymous union type (to complement the proposed anonymous

Re: [Haskell-cafe] In relation to shuffling

2004-07-08 Thread Graham Klyne
At 21:40 08/07/04 +0200, paolo veronelli wrote: Most of my imperative pieces of software find their answers by touching around in some space of solutions and my favourite approximation algorithms use random distributions. Is it haskell the wrong languages for those, as I'm obliged to code them

Re: [Haskell-cafe] so how does one convert an IO a into an a ?

2004-07-08 Thread Alastair Reid
[...] So I am still in IO Int land despite having used the = in the do syntax. [...] The idea of the IO type is that it marks code that can behave differently each time it is called. For this reason, the IO monad 'infects' everything above it in the call chain and, for this reason, the

Re: [Haskell-cafe] In relation to shuffling

2004-07-08 Thread Alastair Reid
On Thursday 08 July 2004 20:40, paolo veronelli wrote: Most of my imperative pieces of software find their answers by touching around in some space of solutions and my favourite approximation algorithms use random distributions. Is it haskell the wrong languages for those, as I'm obliged to

[Haskell-cafe] Re: so how does one convert an IO a into an a ?

2004-07-08 Thread André Pang
On 09/07/2004, at 4:50 AM, Crypt Master wrote: One person mentioned how random just returns an interative program which when eveluated returns the Int. Also from the school of expression book he says The right way to think of (=) above is simply this: It Executes e1 ... in relation to do