Re: deleteBy

1999-12-08 Thread Alex Ferguson
S. Alexander Jacobson: > Can we stop polluting the namespace with list based function > definitions? Most of these functions: delBy, filter, map, concat, length, > take, takeWhile, etc. are well specified for data structures other than > lists. Regardless of whether Haskell includes generic pro

A case in point.

1999-12-07 Thread Alex Ferguson
John Atwood: > You have it right, except you need to > 1) explicitly type test, > test:: Reader [Char] Char José Romildo Malaquias: > > --- > > test = do env <- ask > > if env == "choose a" > > then return 'a' > > else return 'b' > > >

RE: Type application: a modest proposal.

1999-12-06 Thread Alex Ferguson
Frank Christoph: > > I think he means the application term associated with second-order lambda > > calculus' "big lambda," usually written "M [T]" or just "M T" where M is a > > value term and T is a type term, e.g., "(/\X.\x.x) Int 3". > > Should be: "(/\X.\x:X.x) Int 3". (Doesn't make much sen

A case in point.

1999-12-06 Thread Alex Ferguson
John Atwood: > You have it right, except you need to > 1) explicitly type test, > test:: Reader [Char] Char José Romildo Malaquias: > > --- > > test = do env <- ask > > if env == "choose a" > > then return 'a' > > else return 'b' > > >

Type application: a modest proposal.

1999-12-06 Thread Alex Ferguson
Now that rank-2 polymorphism seems to be part of the 'received standard' (at least two implementations support 'em, and I assume they're a shoo-in for Haskell 2), couldn't we really also do with type application? It seems that ambiguity is here to stay in Haskell, and in principle R2L makes the s

What to wish for.

1999-11-25 Thread Alex Ferguson
Eduardo Costa on small Haskell compilers: > Besides, it becomes easier to install, and uninstall. For instance, > Dr. Alcimar (that you know quite well) is finishing his prosthetic arm > for amputees. Clean was able to produce code that was small enough, > uses heap sparingly, and was fast enough

Oops. [RE: Existential types, save me now?]

1999-11-22 Thread Alex Ferguson
Alex, malreported, haskell and ghc-users lists...: > It does me ego no end of good to find out that I'm right, and the > compiler is wrong (for a change, it must be said...). Unless either > ghc or hbc catch up to the Hugs extension, though, avails me little > in practice, sadly. (Hint, hint.)

Re: Existential types, save me now?

1999-11-22 Thread Alex Ferguson
Hi Fergus. > > > data OrdFuncExist = OE (Ord a => Char -> a) > > > That's not the syntax for a existential type, > that's the syntax for a universally quantified type > with rank-2 polymorphism. With that syntax, the > argument of `OE' must be a polymorphic function > with type `forall a . Ord

RE: Existential types, save me now?

1999-11-22 Thread Alex Ferguson
Hi Mark, all: thanks for the swiftly muddle-dispelling response. > | Here's some of the threatened examples: > | > | > data OrdFuncExist = OE (Ord a => Char -> a) > | > data OrdListExist = OLE (Ord a => [a]) > > Perhaps this is a GHC/Hugs difference, but the syntax that you've > used here isn

Re: Existential types, save me now?

1999-11-22 Thread Alex Ferguson
Here's some of the threatened examples: > data OrdFuncExist = OE (Ord a => Char -> a) > data OrdListExist = OLE (Ord a => [a]) > emap :: OrdFuncExist -> [Char] -> OrdListExist > emap (OE f) l = OLE (map f l) Grand... (Apparently.) But now I try to define an actual OrdFuncExist: > blah = O

Existential types, save me now?

1999-11-22 Thread Alex Ferguson
Hi all. I'm wrestling with a typing problem, which I keep hoping that I ought to be able to solve with existentially quantified data types, but such a problem keeps eluding me, leading me to rend my hair at the prospect of instead having to use a some sort of dynamic type or universal type hack.

Re: Partial Type Declarations

1999-11-17 Thread Alex Ferguson
Koen Claessen: > I want to propose a modest extension to Haskell, which > would solve a common irritating problem in programming > in Haskell, and on-the-fly solves the practical programming > problems occuring due to the monomorphism restriction. I've banged into this more than once, so I have

Re: Help with lists?

1999-10-20 Thread Alex Ferguson
Ronald J. Legere: > Is there anyway to make a 'subtype' of lists? I have a type > that is essentially a list,but I want to be able to overide > 'show' for example. So in order to do that, I have to leave > the world of type synonyms: > > newtype SS = SS [Int] I'm forgetting the obvious here:

Re: Help with lists?

1999-10-20 Thread Alex Ferguson
Ronald J. Legere writes: > newtype SS = SS [Int] > > Now I can override show for my newtype, but > unfortunately , I cant overide 'take' 'drop' etc...so > I have to rewrite new versions 'sstake, ssdrop' that does > nothing but peel the wrapper off. Ok, so is there > any nice way to do this? Wel

Re: O, O'Haskell, where are you?

1999-10-12 Thread Alex Ferguson
> Does anyone have a 'live' link to Johan Nordlander's O'Haskell? > http://www.cs.chalmers.se/~nordland/ohaskell/ seems to be unwell. You're all going to think I'm mad, but the above link has now 'recovered'... Cheers, Alex.

O, O'Haskell, where are you?

1999-10-12 Thread Alex Ferguson
Does anyone have a 'live' link to Johan Nordlander's O'Haskell? http://www.cs.chalmers.se/~nordland/ohaskell/ seems to be unwell. Cheers, Alex.

Re: OO in Haskell

1999-10-06 Thread Alex Ferguson
Me: > > Your 'partial' list would appear, from a initial > > inspection, to leave little left of either type safety or referential > > transparency. KA: > Could explain how they could. There is a very nice paper written up on > True ad-hoc polymorphism. By a build in build in dynamic type s

Re: Limititions of Haskell Type System (was Re: OO in Haskell)

1999-10-06 Thread Alex Ferguson
Kevin Atkinson: > I have a generic mutable array class which has a few basic methods: > > class MArray ... where > newArray :: Int -> m (mutArray st el) > write :: mutArray st el -> Int -> el -> m () > read :: mutArray st el -> Int -> m el > freeze :: m mutArray st el -> m array el >

Re: OO in Haskell

1999-10-06 Thread Alex Ferguson
Kevin Atkinson, replying to me... > > I think it should be eminently possible to write a good generic > > container class without resorting to either dynamic typing, or to > > ad hoc polymorphism. (I don't see how these would really help, > > actually.) > > Neither of them will. Sorry if I

Re: OO in Haskell

1999-10-06 Thread Alex Ferguson
Kevin Atkinson: > I never, ever, said that I would like Haskell to be able to do > everything C++ can. No, that was my inference from the general drift of your comments. I also never said that I want Haskell to become a > more type unsafe language. If it was implied I'm sorry. What I did s

Re: OO in Haskell

1999-10-05 Thread Alex Ferguson
Kevin Atkinson and I argue about C++'s 'Cleaner more natural syntax': > I would like to be able to do the things in Haskell that I can do in C++ > but currently Haskell's type system is too simple to allow me to do > them. There are also some things I can't do in C++ but really wish I > could, I

Re: OO in Haskell

1999-10-05 Thread Alex Ferguson
Kevin Atkinson: > > > 3) Encapsulation. You can't have private and protected members. Some > > > of this can be done using modules. However it is more work. > > > > What exactly can't be done with classes, and how, substantively, is > > it more work? > class Foo > private: -- only members

Re: OO in Haskell

1999-10-05 Thread Alex Ferguson
Kevin Atkinson: > 2) More specific types, you can't _easilly_ call the more general type. > For example in OO this is very commen: > > class Base > virtual foo() > do stuff > > class Derived, extends Base > foo() > call Base::foo() > doo stuff You can certainly do this in H

Re: Where is "Server Side Scripting" code?

1999-10-04 Thread Alex Ferguson
Jan Skibinski: > What is available from haskell.org are two much outdated versions of CGI > library: one by Erik himself and one modified (and adopted to Haskell 98) > by Sven Panne. By outdated I mean that they both are based on Erik's > earlier work and much predate the refined and simplified c

Re: CPP is not part of Haskell

1999-09-30 Thread Alex Ferguson
> Either, cpp (or some preprocessor standard), should be made part of the > Haskell language definition or Haskell files that require a preprocessor > should have a different extension. > > Since, I assume that the hugs team has a good reason not to build in cpp > functionality, I am suggestin

Re: What *I* thinks Haskell Needs.

1999-09-28 Thread Alex Ferguson
Fergus Henderson: > One example is the case where you already have existing code that > creates a heterogenous collection, and you want to extract an > element from that heterogenous collection, and then if it is > a member of a particular type class perform action A otherwise > perform action B,

Re: OO in Haskell (was Re: What *I* thinks Haskell Needs.)

1999-09-28 Thread Alex Ferguson
> From [EMAIL PROTECTED] Mon Sep 27 18:50:33 1999 > X-Authentication-Warning: sun00pg2.wam.umd.edu: kevina owned process doing -bs > Date: Mon, 27 Sep 1999 13:50:59 -0400 (EDT) Kevin Atkinson: > You have a collection of Shapes. Some of these shapes are circles, > however, others are rectangl

Re: To all those who don't like ad-hoc overloading

1999-09-28 Thread Alex Ferguson
Kevin Atkinson: > I take it that you are happy with names such as: [long list] Yes. Certainly I'm more than happy that types with completely different signatures have different names.

Re: What *I* thinks Haskell Needs.

1999-09-27 Thread Alex Ferguson
Fergus Henderson, replying to me: > > That's far from clear. Certainly, I don't think it's likely to be > > reasonably possible a conversative extension. [...] > Ad-hoc overloading and type inference don't mix so well, because > you can easily get ambiguities which the compiler cannot resolve.

Re: What *I* thinks Haskell Needs.

1999-09-27 Thread Alex Ferguson
Kevin Atkinson, replying to me: > > If I understand you correctly, then the best way of doing this would be > > with existentially (boundedly) quantified data types, currently a > > non-standard extention present in hbc (and I think, ghc, these days, not > > sure if it's with the same generality

Re: What *I* thinks Haskell Needs.

1999-09-27 Thread Alex Ferguson
Kevin Atkinson: > Yes but often putting things in type classes is tedious to do. I also > want to be able to overload not only on the TYPE of parameters but also > on the NUMBER of parameters. It IS possible to do these things and it > DOES make sense in a curing system. That's far from clear.

Re: Mailing lists down for a while, should be back up now

1999-09-27 Thread Alex Ferguson
> Maintainer's note: > > The Haskell mailing list, and all the other lists served by > haskell.org, have recently moved to a new machine (the "real" > haskell.org). None of the addresses have changed, and the address for > admin requests is still [EMAIL PROTECTED] The mail headers certainly ch

CynWinTclHaskell...?

1999-09-24 Thread Alex Ferguson
I've managed to entirely confuse myself trying to install TclHaskell on a Wintel machine, via Cynwin and ghc-4.03. Poking around it looks like the problem is with the Tcl/Tk libraries, which seem to have been complied up with Visual C++. Now, is there a magic incantation that will persuade TclH

Re: Which GUI on X11R6 ?

1999-08-02 Thread Alex Ferguson
Wilhelm B. Kloke: > has anybody there an idea which GUI is usable with Haskell 98 on > a Unix/X11R6 system (FreeBSD to be complete)? > > It seems that all GUI stuff develepmont (Fudgets, Haggis ...) > has been stalled since some years. I'd look at TclHaskell, if I were you. It's not strictly s

Re: Associativity of $

1999-07-20 Thread Alex Ferguson
Manuel Chakravarty and Olaf Chitil debate the fixity of ($): > > I think the idea behind $ is exactly the change of > > associativity. > > Hmm, I thought, the idea behind it is a change of precedence... > > > I use $ a lot to save a lot of brackets. I very much prefer > > > > f $ g $ h $ i $

Will the real CGI library please stand up?

1999-06-15 Thread Alex Ferguson
Erik Meijer's nifty-looking CGI library, as described in his upcoming JFP paper, looks like just the very thing I'm looking for, but alas, I can't find a complete copy of the code anyplace. In particular, some of combinators in the paper have only type sigs, not complete definitions, and are not

Re: Modifying the monomorphism restriction

1999-02-25 Thread Alex Ferguson
Joe English: > I was thinking of the example from the Haskell Report: > > let { len = genericLength xs } in (len, len) > > which, without the MR, computes 'len' twice. > Operationally I expect that in "let x = f y in ... x ... x", > 'f y' is only evaluated once, no matter what type it is.

Re: Modifying the monomorphism restriction

1999-02-24 Thread Alex Ferguson
Thomas Hallgren: > The monomorphism restriction makes sure that certain values are computed at most > once by restricting them to be used at only one type. Couldn't the same be > achieved by > >* getting rid the monomorphism restriction, i.e., let all definitions to be > overloaded by

Re: Modifying the monomorphism restriction

1999-02-24 Thread Alex Ferguson
Joe English: > (Am I the only one who's never been bitten by the MR restriction?) If one always uses type sigs, or never/rarely uses compositional/ combinator style function definitions, it's much less likely to crop up. > How about leaving the 'a = b' binding form as it is, > (monomorphism re

Re: Modifying the monomorphism restriction

1999-02-24 Thread Alex Ferguson
Christian Sievers replies to John Hughes: > > Some suggest that it is enough for compilers to issue a warning when using > > call-by-name. I disagree strongly. Such a warning may alert the programmer > > at the time the overloaded definition is compiled. But programmers need to > > understand pro

Re: Haskell 2 -- MR, for Curry's sakes go.

1999-02-23 Thread Alex Ferguson
John Launchbury: > I agree that the MR is a pain. [...] > Now we find that some type declarations > contain more class info than type!! And some type(+class) declarations are longer than the definition! This sounds a trite point, but it gets very annoying when one is "rapid-prototyping" (aka hac

RE: Haskell 2 -- MR, for Curry's sakes go.

1999-02-17 Thread Alex Ferguson
Simon encouraged me to bellyache with this reply in public, so here it is... > > Having just wasted an hour or so chasing MR-induced errors through > > a moderate-sized module after introducing a relatively minor change, > > I feel the need to vent on this topic, yet again. > Alex, it's fine

Haskell 2 -- MR, for Curry's sakes go.

1999-02-16 Thread Alex Ferguson
Now that Haskell 98 is a done deal (for good or for ill -- what on earth were people thinking of with 'isAlphaNum'?), can we hope that the committee will revisit the Monomorphism Restriction, and somewhat more seriously than it's done to date? Having just wasted an hour or so chasing MR-induced

Re: io monad binding, coding style

1999-01-17 Thread Alex Ferguson
Greg O'Keefe: > main =readFile "input-file" >>= \ s -> > writeFile "output-file" (filter isAscii s) >> > putStr "Filtering succesful\n" [vs.] > main =readFile "input-file" >>= > \ s -> writeFile

Re: Partial Type Declarations

1999-01-16 Thread Alex Ferguson
Patrik Jansson: > I like ? better than .., but maybe the Haskell "don't care"-symbol _ > could be even more suggesting: > > q :: a -> _ -> c > qa_ = c > > Syntactically this is closer to what is currently allowed as type > variables and it would easily (in the sense that such a pro

Re: Haskell 98 progress

1998-11-09 Thread Alex Ferguson
Hi Simon, you spake of simple-context restriction: > My default position is not to change. Question: who, apart from > Ralf, has actually tripped over the lack of contexts of the > form (C (a t1 .. tn)) in Haskell 1.4? *raises hand and jumps up and down* Me, mememe! I provided you with

Re: Haskell in Scientific Computing?

1998-10-16 Thread Alex Ferguson
Various people write: > cc: [EMAIL PROTECTED], [EMAIL PROTECTED] And so on. Please, these are _not_ the correct list addresses to us for this list -- all list mail ought to go to [EMAIL PROTECTED], and not any of these variants. [Glasgow people, is it possible to tweak the list config so that

RE: Nested pattern guards.

1998-10-05 Thread Alex Ferguson
> No semantic objection, but GHC doesn't implement them because of > the lack of a decent syntax. OK, I suspected as much. I think I shall go off and try to craft a syntax for a "logical" such extensions, so it can be shot down in more detail! The only snags I can think of off the top of my he

Nested pattern guards.

1998-10-01 Thread Alex Ferguson
Hi all. Was there ever any sort of consensus about whether pattern guards ought to be "nestable", or not? And if not, was there some semantic objection to this, was the syntax just considered to Unspeakable to be spoken of, or is the feature just largely redundant? (I think you can always rewr

Re: Standard Haskell

1998-09-10 Thread Alex Ferguson
John Launchbury: > I think I favor "20th century Haskell" myself :-) I forsee legal wrangles with one R. Murdoch -- though on the plus side, he might buy us all out for half a billion quid or so, perhaps. [ soccer econo-political reference for those not up on the latest NewsMegaCorp shenaniga

Re: Scoped typed variables.

1998-07-22 Thread Alex Ferguson
Jeff Lewis: > I'm not sure what the parenthetical comment about the interpretation of a means - > take the definition at face value. My point was: were they _intended_ to be same "a", or different? What is "face value" is surely simply begging the question. > It's not at all clear to me that

Re: Scoped typed variables.

1998-07-22 Thread Alex Ferguson
Hi Jeff. > > http://www.cs.chalmers.se/~rjmh/Haskell/Messages/Display.cgi?id=274 > > > > I think "A" is fine, it's "B" (and hence, SPJ's Composite Motion, A+B) > > that worries me, for the reasons I alluded to. If "beefed up A" > > does the job, I'm equally happy as with a more conservation syn

Re: instances of types.

1998-07-22 Thread Alex Ferguson
Sergey Mechveliani writes: > Second, some compilers say at this: > " > (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) > " > Maybe, they treat Int Int as a repeated variable? Not quite, Int isn't a type variable at all, but an act

RE: Scoped typed variables.

1998-07-22 Thread Alex Ferguson
Hi Mark (and all). > I think the way that Hugs 1.3c handles it would meet your goals. All that > it requires is a strict extension to the syntax for patterns to allow type > annotations. These can be useful in their own right, but also can be > applied to problems like the one that you gave: >

Re: avoiding repeated use of show

1998-07-21 Thread Alex Ferguson
Alex Jacobson: > > > > (./) :: (Stringable a,Stringable b)=> a->b->String > > > > x./y = (toString x)++(toString y) > > Wouldn't it be a great deal less tortuous to define: > > > > > x .++ y = show x ++ y > > > > > x ++. y = x ++ show y > > > > and then to use (++), (.++), or (++.), as approp

Re: avoiding repeated use of show

1998-07-21 Thread Alex Ferguson
S. Alexander Jacobson writes: > So I tried creating my own Stringable class: > > class Stringable a where > > toString::a -> String > > (./) :: (Stringable a,Stringable b)=> a->b->String > > x./y = (toString x)++(toString y) Wouldn't it be a great deal less tortuous to define: > x .++ y = sho

Scoped typed variables.

1998-07-21 Thread Alex Ferguson
Further to discussion on the StdHask site, and (of all places) ghc-bugs, I remain concerned about the program-breaking proposal to have typesigs scope over equation groups, thereby binding any type variable occurrences in local signatures. But I agree with the need to add this expressivity. Sure

Re: type context

1998-07-16 Thread Alex Ferguson
Sergey Mechveliani writes: > But question aside, on "MPC forces me to use non-variable contexts": > its this necessary to represent a Set as a constructor class? > Why do not declare >class (Foo a,Foo' b) => Set a b where ... > ? I'm not sure I follow. Can you elaborate on ho

Re: Instance contexts.

1998-07-16 Thread Alex Ferguson
SPJ: > Alex: can you flesh out your example any more? I was expecting > Num (s n) not Num [s n], for example. The idea is to generalise numeric operations from sets (intervals say), to sets of sets (lists of intervals). If it were possible to write Set as a unary class, the instance declaration

Re: Monomorphism

1998-07-15 Thread Alex Ferguson
John Peterson defends the DMR: > read :: Read a => String -> a > read s = let [(r,s')] = reads s in r > This *won't compile* if you don't treat the let binding definition > monomorphicly. Without monomorphism, the types of r and s' are > r :: Read a => a > s' :: Read a => String > This leads

Re: Instance contexts.

1998-07-15 Thread Alex Ferguson
Fergus Henderson, replaying to me: > > I haven't looked at this in great detail, so forgive me if I'm talking > > through my hat, as seems quite likely: is it workable to require only > > that contexts be non-increasing in size, and that there be no manifest > > circularity where the sizes are no

RE: Instance contexts.

1998-07-15 Thread Alex Ferguson
Mark Jones: > Looking at the `size' of types is, of course, a generalization of Simon's > suggestion that contexts might be allowed to constrain only proper sub- > expressions of types in the context. (Proper sub-expressions are, by > definition, smaller in size.) However, it is still too stric

Re: what is leaking?

1998-06-29 Thread Alex Ferguson
Hi Alex. > If you use a different (but still lazy) definition of foldl: > > myFoldl f s [] = s > > myFoldl f s (x:xs) = f s (foldl f x xs) Unless I'm more asleep than I realise, this is just foldr, isn't it? (To wit, "fold to the right", rather than "fold to the left".) In fact, foldr is the "

Re: Exceptions are too return values!

1998-06-09 Thread Alex Ferguson
Alex Jacobson: > Ooops, I forgot to remove the "and". Anyway, my point is that > 1. it is not logically consistent to treat exceptions as return values > 2. as an implementation matter it violates laziness to do so OK, now I follow. And diagree. ;-) On your second point first: I'm not sure w

Exceptions are too return values!

1998-06-08 Thread Alex Ferguson
Alex Jacobson: > In the backchannel, Alastair Reid and Adrian Hey, have convinced me > that the return values of functions and cannot be represented using > algebraic types. I'm not clear what you mean by this. > I am not sure of syntax, but I am describing something like: > > fun:: a->b->c :

order of evalutation of ||

1998-05-29 Thread Alex Ferguson
S. Alexander Jacobson wonders: > If you have a statement like: > > result= a || b || c > > does Haskell guarantee that a gets evaluated before b? Indeed it does, for see the standard Prelude definition of (||): True || _ = True False || x = x Hope that helps. Slainte, Alex.

Re: binary search

1998-04-17 Thread Alex Ferguson
Various people write: > Cc: [EMAIL PROTECTED], [EMAIL PROTECTED] Can I ask people to be careful to which haskell-list address(es) they followup to? My understanding is that list messages ought to be sent _only_ to [EMAIL PROTECTED], and that any other addresses are symptoms (and in some cases c

Re: Press Release

1998-04-01 Thread Alex Ferguson
John "Poisson d'Avril" Peterson writes: > Microsoft And Yale Conclude Agreement To License Technology For Haskell Very droll. ;-) Slainte, Alex.

RE: Standard Haskell

1998-03-27 Thread Alex Ferguson
Frank A. Christoph: > I hope that Either will be renamed to (+), or at > least deprecated in favor of (+). I'd basically agree with Frank here, though presumably for consistency with Koen's (very reasonable) proposals, this would need to be the symbol (:+:) -- or characters to that effect -- for

Type of insertBy

1998-01-23 Thread Alex Ferguson
Greetings all. Why does the 1.4 report have "insert" use the "compare" member function of Ord, rather than ">", hence giving insertBy a funny type involving "Ordering"? This seems unnecessary, and not the most convenient form for direct use of insertBy, either. Slainte, Alex.

Re: Overlapping instance declarations.

1997-12-10 Thread Alex Ferguson
Thanks Simon, you largely confirmed what I'd inferred. Pity there isn't such a clear description -- or really, any such description -- in the report! Cheers, Alex.

Overlapping instance declarations.

1997-12-09 Thread Alex Ferguson
The 1.4 report says: "A type may not be declared as an instance of a particular class more than once in the program." Doesn't it really mean that a type _constructor_ may not appear in more than one instance declaration for a particular class? That (stronger) condition seems to be what ghc and

Partially annoying orders.

1997-12-08 Thread Alex Ferguson
I'm sure something like this has come up here before, but I've just been banging my head against it, and feel like a mild grouse. I recently found myself needing a partial order class, and found that: The most likely-looking operator symbols are all "taken"; It'd be des

Re: Call for parsers

1997-11-14 Thread Alex Ferguson
parser grammar with as close a structure to that as is in the Report as possible. Obviously the lack is gettable-roundable, though at further cost to both efficiency and clarity. Slainte, Alex. ___ Dr. Alex Ferguson,

Re: Lexer/Parser for Haskell in Haskell?

1997-07-07 Thread Alex Ferguson
Graeme, you wrote: > Has Happy (the parser generator) been upgraded to Haskell 1.3/1.4 yet? Happy output works fine with ghc's 2.01 and 2.02. Progressively better in fact, efficiency-wise. The only caveat is that a small tweak in the includes becomes necessary for "happy -g" output (and probab

Re: Working with newtype

1997-05-29 Thread Alex Ferguson
Graeme Moss asks about "map" defined over this type: >newtype MyList a = MyList [a] using variously case, an auxiliary function, a selector function, and pattern guards. > Should any of these rather cumbersome ways of defining the standard > map over (MyList a) cause any more code than the

Superclass defaults.

1997-05-16 Thread Alex Ferguson
Phil Wadler, quoting K. Claesson: > > At the moment you make an instance of a class that has default definitions > > for one of its superclasses, and there is no corresponding instance for > > that class, we implicitly insert the specified default instance. If > > there are more instances to cho

Re: Deriving class instances

1997-05-16 Thread Alex Ferguson
Olaf Chitil suggests making "deriving" semi-detachable from type declararations, thusly: > deriving Tree (Eq, Ord, Show) or: > deriving (Tree a) (Eq, Ord, Show) I think this is a pretty sensible idea, but I believe it would be preferable to use a more instance-like syntax, given that's what is

Re: Monads, Functors and typeclasses

1997-05-14 Thread Alex Ferguson
Lennart says of superclass defaults: > there is an ambiguity problem when there are several different > defaults available. E.g. > > class C a where > m :: a -> Int > > class (C a) => C1 a where > m x = 1 > > class (C a) => C2 a where > m x = 2 > I guess you could "solve" it by fo

Re: Monads, Functors and typeclasses

1997-05-13 Thread Alex Ferguson
Koen Claessen suggests: > In this case we could allow the programmer giving a default declaration > for the superclass methods during the class definition of the subclass. An > example would be: > > class Functor f where > map :: (a -> b) -> m a -> m b > > class Functor m => Monad m w

Re: Monads, Functors and typeclasses

1997-05-13 Thread Alex Ferguson
Koen Claessen: > I would suggest you take a look at Simon, Erik and Mark's paper [1]. Thanks for the suggestion, but I already have. > My answer is: yes, there are a lot of examples where this is useful. > Simon's answer is: yes, but allowing this breaks other properties which I > find more des

Re: Monads, Functors and typeclasses

1997-05-13 Thread Alex Ferguson
Koen Claessen: > In fact, the connection between Monad and Functor is much stronger than > the connection between MonadZero and Monad; the former relation can be > expressed in terms of a direct default definition. But alas, not in Haskell; this would be possible, though, if the rules against ci

Re: A new view of guards

1997-05-02 Thread Alex Ferguson
Heribert Schuetz: > I wanted to point out > that no use of patterns is really "essential" (see also the equivalences > below), or at least that it is a bit arbitrary what one considers > essential. Let me rephrase then; it wasn't a convincing example, because the non-pattern-guarding version (5a

Re: A new view of guards

1997-05-01 Thread Alex Ferguson
Heribert Schuetz: > 3. From Alex' example (version 5a) one could have learned that we do not >need guards at all, because all sorts of guards (today's Haskell >guards, Peyton-Jones-style guards, and nested guards) can be replaced >by the Maybe monad in a *straightforward* way: I don

Re: pattern guards and guarded patterns

1997-04-30 Thread Alex Ferguson
A couple of minor counter-quibbles:- Pablo E. Martinez Lopez suggests: > You can define your own "sequential if" a la Hoare: > >data GuardedExp a = Bool :? a > >seqif :: [GuardedExp a] -> a >seqif [True:?a] = a >seqif ((b:?a):x:xs) = if b then a else seqif (x:xs

Re: A new view of guards

1997-04-30 Thread Alex Ferguson
Oh, I forgot to say, concerning the Alternative Syntax (strict where's) Simon mentions; I think this is not supportable, particularly for the program-breaking reason SPJ mentions. (And especially because lots of the borken programs would be mine, and I shudder at the thought of adding ~'s all ov

Re: A new view of guards

1997-04-29 Thread Alex Ferguson
Simon (PJ) sez: > Is this a storm in a teacup? Much huff and puff for a seldom-occurring > situation? No! It happens to me ALL THE TIME. I have to join Simon out of the closet, and confess that I write Clunky Functions rather a lot too, or at least find myself going to significant lengths to a

The wonderful thing about Standards...

1997-03-26 Thread Alex Ferguson
... is that there's yet another of them! Simon L Peyton Jones ordains: > Don't bother with 2.01. The trouble with regarding 2.02 as a Mere Bugfix Release are all those *term deleted* library incompatibilities. Why is the August Committee _still_ rearranging these things in seemingly incosequen