[Haskell-cafe] Removing polymorphism from type classes (viz. Functor) (Again)

2010-08-14 Thread Alexey Karakulov
I was inspired by George Pollard's posthttp://www.haskell.org/pipermail/haskell-cafe/2009-July/063981.htmlat haskell-cafe and tried to implement the non-polymorphic Functor class ( I named it Functor' ). I changed some names and added reasonable constraints. type family NewPt f a class

Re: [Haskell-cafe] Removing polymorphism from type classes (viz. Functor) (Again)

2010-08-14 Thread Ivan Lazar Miljenovic
Alexey Karakulov ankaraku...@gmail.com writes: (Ord b) must be deduced from (Functor (Set b)) but it doesn't. I don't know whether it's my mistake somewhere or ghc problem. I've come across this problem as well; the best solution I've seen so far is the one taken by Ganesh in his rmonad

Re: [Haskell-cafe] Removing polymorphism from type classes (viz. Functor) (Again)

2010-08-14 Thread Alexey Karakulov
On Sat, Aug 14, 2010 at 2:27 PM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: Alexey Karakulov ankaraku...@gmail.com writes: (Ord b) must be deduced from (Functor (Set b)) but it doesn't. I don't know whether it's my mistake somewhere or ghc problem. I've come across this

Re: [Haskell-cafe] Removing polymorphism from type classes (viz. Functor) (Again)

2010-08-14 Thread Stephen Tetley
The non-type-changing map can be implemented as a type class - in my graphics lib Wumpus, I call it pointwise: class Pointwise sh where type Pt sh :: * pointwise :: (Pt sh - Pt sh) - sh - sh I think other people have posted it to the cafe under a different name, before I did:

Re: [Haskell-cafe] Removing polymorphism from type classes (viz. Functor) (Again)

2010-08-14 Thread Stephen Tetley
On 14 August 2010 20:27, Stephen Tetley stephen.tet...@gmail.com wrote: If I was doing Wumpus again though, I'd probably do with Pointwise. Ahem, do without Pointwise Originally the types I operated on with Pointwise were more complicated than they are now and Pointwise seemed a benefit. But

Re: [Haskell-cafe] Type classes

2010-07-04 Thread Ivan Lazar Miljenovic
Andrew Coppin andrewcop...@btinternet.com writes: In summary, I think we need to devise a way of better-documenting class instances. Haddock 2.7 supports documenting instance implementations; I don't know how this works, but according to the Changelog it's available. -- Ivan Lazar

Re: [Haskell-cafe] Type classes

2010-07-04 Thread Ross Paterson
On Sun, Jul 04, 2010 at 09:55:53PM +1000, Ivan Lazar Miljenovic wrote: Andrew Coppin andrewcop...@btinternet.com writes: In summary, I think we need to devise a way of better-documenting class instances. Haddock 2.7 supports documenting instance implementations; I don't know how this

Re: [Haskell-cafe] Type classes

2010-07-04 Thread Ivan Lazar Miljenovic
Ross Paterson r...@soi.city.ac.uk writes: On Sun, Jul 04, 2010 at 09:55:53PM +1000, Ivan Lazar Miljenovic wrote: Andrew Coppin andrewcop...@btinternet.com writes: In summary, I think we need to devise a way of better-documenting class instances. Haddock 2.7 supports documenting instance

Re: [Haskell-cafe] Type classes

2010-07-04 Thread David Waern
2010/7/4 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com: Andrew Coppin andrewcop...@btinternet.com writes: In summary, I think we need to devise a way of better-documenting class instances. Haddock 2.7 supports documenting instance implementations; I don't know how this works, but

Re: [Haskell-cafe] Type classes

2010-07-04 Thread Daniel Fischer
On Sunday 04 July 2010 14:07:03, Ivan Lazar Miljenovic wrote: Ross Paterson r...@soi.city.ac.uk writes: On Sun, Jul 04, 2010 at 09:55:53PM +1000, Ivan Lazar Miljenovic wrote: Andrew Coppin andrewcop...@btinternet.com writes: In summary, I think we need to devise a way of better-documenting

Re: [Haskell-cafe] Type classes

2010-07-04 Thread Daniel Fischer
On Sunday 04 July 2010 14:03:51, Ross Paterson wrote: Now we need to go round and document our instances. Hmm, it seems only partial: documentation attached to an instance is shown in the list of instances under a type, but not the list under a class. Not much of a problem. Right-click on

Re: [Haskell-cafe] Type classes

2010-07-04 Thread David Waern
2010/7/4 Daniel Fischer daniel.is.fisc...@web.de: Hmm, it seems only partial: documentation attached to an instance is shown in the list of instances under a type, but not the list under a class. I'm guessing that's to reduce noise... I'm guessing it might have something to do with the

Re: [Haskell-cafe] Type classes

2010-07-04 Thread Ross Paterson
On Sun, Jul 04, 2010 at 02:32:35PM +0200, Daniel Fischer wrote: On Sunday 04 July 2010 14:07:03, Ivan Lazar Miljenovic wrote: Ross Paterson r...@soi.city.ac.uk writes: Hmm, it seems only partial: documentation attached to an instance is shown in the list of instances under a type, but not

Re: [Haskell-cafe] Type classes

2010-07-04 Thread Ivan Lazar Miljenovic
David Waern david.wa...@gmail.com writes: 2010/7/4 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com: Andrew Coppin andrewcop...@btinternet.com writes: In summary, I think we need to devise a way of better-documenting class instances. Haddock 2.7 supports documenting instance

Re: [Haskell-cafe] Type classes

2010-07-04 Thread David Waern
2010/7/4 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com: David Waern david.wa...@gmail.com writes: 2010/7/4 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com: Andrew Coppin andrewcop...@btinternet.com writes: In summary, I think we need to devise a way of better-documenting class instances.

Re: [Haskell-cafe] Type classes

2010-07-04 Thread David Waern
2010/7/4 Ross Paterson r...@soi.city.ac.uk: It could be either way: sometimes you define a new class with instances for existing types, and with the current implementation that produces no documentation. (I tested with type, class and instance in the same package.) Hi Ross, thanks for

Re: [Haskell-cafe] Type classes

2010-07-04 Thread David Waern
2010/7/4 David Waern david.wa...@gmail.com: 2010/7/4 Daniel Fischer daniel.is.fisc...@web.de: Hmm, it seems only partial: documentation attached to an instance is shown in the list of instances under a type, but not the list under a class. I'm guessing that's to reduce noise... I'm

Re: [Haskell-cafe] Type classes

2010-07-04 Thread Andrew Coppin
David Waern wrote: I found the bug and fixed it, it's in the latest darcs version Open Source Works.(tm) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] ambiguous type variable problem when using forall, multiparameter type classes, and constraints on polymorphic values (and syb-with-class)

2010-05-21 Thread Jeremy Shaw
Hello, I am trying to understand why I am getting an ambigious type variable error, and what I can do to work around it. The problem is occurring while trying to use syb-with-class, but I have stripped it down to it's bare essentials, so the following code is self-contained, and does not require

Re: [Haskell-cafe] ambiguous type variable problem when using forall, multiparameter type classes, and constraints on polymorphic values (and syb-with-class)

2010-05-21 Thread C. McCann
On Fri, May 21, 2010 at 12:30 PM, Jeremy Shaw jer...@n-heptane.com wrote: Adding all the scoped type variable stuff does not seem to help. Alas, I can not figure out if this is a limitation of the type-checker, or something that is fundamentally impossible. Nor can I figure out how to work

Re: [Haskell-cafe] Strange error with type classes + associated types

2010-04-19 Thread Conal Elliott
On Sun, Apr 18, 2010 at 9:02 PM, Brent Yorgey byor...@seas.upenn.eduwrote: Conal, Thanks for looking into this! Making (:-*) into a proper type seems promising. I did try wrapping (:-*) in a newtype but that didn't help (although I didn't expect it to). What do you mean by a proper type?

Re: [Haskell-cafe] Strange error with type classes + associated types

2010-04-19 Thread Brent Yorgey
On Mon, Apr 19, 2010 at 09:40:25AM -0700, Conal Elliott wrote: On Sun, Apr 18, 2010 at 9:02 PM, Brent Yorgey byor...@seas.upenn.eduwrote: Conal, Thanks for looking into this! Making (:-*) into a proper type seems promising. I did try wrapping (:-*) in a newtype but that didn't help

Re: [Haskell-cafe] Strange error with type classes + associated types

2010-04-18 Thread Brent Yorgey
Conal, Thanks for looking into this! Making (:-*) into a proper type seems promising. I did try wrapping (:-*) in a newtype but that didn't help (although I didn't expect it to). I see you just uploaded a new version of vector-space; what's new in 0.6.2? -Brent On Sat, Apr 17, 2010 at

Re: [Haskell-cafe] Strange error with type classes + associated types

2010-04-17 Thread Roman Leshchinskiy
On 17/04/2010, at 11:00, Conal Elliott wrote: I'm unsure now, but I think I tried making Basis a data type (not syn) and ran into the problem I mentioned above. The Basis *synonyms* also have HasTrie instances, which is crucially important. If we switch to (injective) data types, then we

Re: [Haskell-cafe] Strange error with type classes + associated types

2010-04-17 Thread Conal Elliott
Oh! I'd completely forgotten about this idea. Looking at Data.LinearMap in vector-space, I see a comment about exactly this ambiguity, as well as the start of a new module that wraps a data type around the linear map representation. I don't recall whether I got stuck or just distracted. On

Re: [Haskell-cafe] Strange error with type classes + associated types

2010-04-16 Thread Conal Elliott
Hi Brent, I'm sorry to hear that the non-injectivity issue bit you. It's bitten me also at times, leading me to choose associated data types (injective) instead of associated synonyms (potentially non-injective). And sometimes, the data types route is problematic, as the new types aren't

Re: [Haskell-cafe] Strange error with type classes + associated types

2010-04-14 Thread Stephen Tetley
On 14 April 2010 03:48, Brent Yorgey byor...@seas.upenn.edu wrote: Can someone more well-versed in the intricacies of type checking with associated types explain this?  Or is this a bug in GHC? Hi Brent Maybe you can't compose linear maps of the same type, and thus can't build a valid monoid

Re: [Haskell-cafe] Strange error with type classes + associated types

2010-04-14 Thread Brent Yorgey
On Wed, Apr 14, 2010 at 09:51:52AM +0100, Stephen Tetley wrote: On 14 April 2010 03:48, Brent Yorgey byor...@seas.upenn.edu wrote: Can someone more well-versed in the intricacies of type checking with associated types explain this?  Or is this a bug in GHC? If you take the definition of

Re: [Haskell-cafe] Strange error with type classes + associated types

2010-04-14 Thread Roman Leshchinskiy
On 15/04/2010, at 00:30, Brent Yorgey wrote: On Wed, Apr 14, 2010 at 09:51:52AM +0100, Stephen Tetley wrote: On 14 April 2010 03:48, Brent Yorgey byor...@seas.upenn.edu wrote: Can someone more well-versed in the intricacies of type checking with associated types explain this? Or is this a

Re: [Haskell-cafe] Strange error with type classes + associated types

2010-04-14 Thread Brent Yorgey
On Thu, Apr 15, 2010 at 12:48:20AM +1000, Roman Leshchinskiy wrote: Right, this seems weird to me. Why is there still a 'u' mentioned in the constraints? Actually, I don't even see why there ought to be both v and v1. The type of (*.*) mentions three type variables, u, v, and w:

[Haskell-cafe] Strange error with type classes + associated types

2010-04-13 Thread Brent Yorgey
Hi all, Consider the following declarations. -- from vector-space package: (*.*) :: (HasBasis u, HasTrie (Basis u), HasBasis v, HasTrie (Basis v), VectorSpace w, Scalar v ~ Scalar w) = (v :-* w) - (u :-* v) - u :-* w -- my code: data

Re: [Haskell-cafe] floating-point comparison (was haskell gsoc proposal for richer numerical type classes and supporting algorithms)

2010-04-11 Thread Jason Dagit
On Thu, Apr 8, 2010 at 7:29 PM, Doug Burke doug_j_bu...@yahoo.com wrote: --- On Thu, 4/8/10, Gregory Crosswhite gcr...@phys.washington.edu wrote: From: Gregory Crosswhite gcr...@phys.washington.edu On a tangental note, I've considered coding up a package with an AlmostEq typeclass

Re: [Haskell-cafe] haskell gsoc proposal for richer numerical type classes and supporting algorithms

2010-04-10 Thread Paul McJones
Dear Carter, Although I'm not an active Haskell programmer, I'd like to add my support for you to write up your GSOC application. In the first five chapters of the book /Elements of Programming/ (Addison-Wesley, 2009), my coauthor Alex Stepanov and I undertook a somewhat similar effort,

Re: [Haskell-cafe] haskell gsoc proposal for richer numerical type classes and supporting algorithms

2010-04-08 Thread Stephen Tetley
Hi Carter The proposal is interesting - but maybe there is not a great community benefit to a 'covers everything' library considering Henning Thielemann and others 'numeric prelude' already exists: http://hackage.haskell.org/package/numeric-prelude As a not especially mathematically inclined

Re: [Haskell-cafe] haskell gsoc proposal for richer numerical type classes and supporting algorithms

2010-04-08 Thread Edward Kmett
type classes which a user wouldn't often encounter or deal with unless they're doing real math, in which case understanding them is probably key for correctly writing the desired code anyways. For those reading this who don't know the abstract algebra terminology: *a monoid* is a set

Re: [Haskell-cafe] haskell gsoc proposal for richer numerical type classes and supporting algorithms

2010-04-08 Thread Casey McCann
On Thu, Apr 8, 2010 at 2:09 PM, Edward Kmett ekm...@gmail.com wrote: Template Haskell can help dull the pain, but the result seems hardly idiomatic. Well, since this is dealing with types and type classes, much of the required boilerplate could also be straightforwardly derived in full

Re: [Haskell-cafe] haskell gsoc proposal for richer numerical type classes and supporting algorithms

2010-04-08 Thread Edward Kmett
On Thu, Apr 8, 2010 at 3:25 PM, Casey McCann syntaxgli...@gmail.com wrote: On Thu, Apr 8, 2010 at 2:09 PM, Edward Kmett ekm...@gmail.com wrote: Template Haskell can help dull the pain, but the result seems hardly idiomatic. Well, since this is dealing with types and type classes, much

Re: [Haskell-cafe] haskell gsoc proposal for richer numerical type classes and supporting algorithms

2010-04-08 Thread Gregory Crosswhite
On Apr 8, 2010, at 12:25 PM, Casey McCann wrote: Seriously, floating point so-called numbers don't even have reflexive equality! They don't? I am pretty sure that a floating point number is always equal to itself, with possibly a strange corner case for things like +/- 0 and NaN. Cheers,

Re: [Haskell-cafe] haskell gsoc proposal for richer numerical type classes and supporting algorithms

2010-04-08 Thread wren ng thornton
Gregory Crosswhite wrote: On Apr 8, 2010, at 12:25 PM, Casey McCann wrote: Seriously, floating point so-called numbers don't even have reflexive equality! They don't? I am pretty sure that a floating point number is always equal to itself, with possibly a strange corner case for things

Re: [Haskell-cafe] haskell gsoc proposal for richer numerical type classes and supporting algorithms

2010-04-08 Thread Casey McCann
On Thu, Apr 8, 2010 at 7:58 PM, wren ng thornton w...@freegeek.org wrote: They don't?  I am pretty sure that a floating point number is always equal to itself, with possibly a strange corner case for things like +/- 0 and NaN. Exactly. NaN /= NaN. Other than that, I believe that let x = ...

Re: [Haskell-cafe] haskell gsoc proposal for richer numerical type classes and supporting algorithms

2010-04-08 Thread Gregory Crosswhite
On Apr 8, 2010, at 5:30 PM, Casey McCann wrote: On Thu, Apr 8, 2010 at 7:58 PM, wren ng thornton w...@freegeek.org wrote: Exactly. NaN /= NaN [...] Indeed. NaN means that equality is not reflexive for floats in general, only a subset of them. First of all, it isn't clear to me that NaN /=

Re: [Haskell-cafe] haskell gsoc proposal for richer numerical type classes and supporting algorithms

2010-04-08 Thread Daniel Fischer
Am Freitag 09 April 2010 02:51:23 schrieb Gregory Crosswhite: On Apr 8, 2010, at 5:30 PM, Casey McCann wrote: On Thu, Apr 8, 2010 at 7:58 PM, wren ng thornton w...@freegeek.org wrote: Exactly. NaN /= NaN [...] Indeed. NaN means that equality is not reflexive for floats in general,

Re: [Haskell-cafe] haskell gsoc proposal for richer numerical type classes and supporting algorithms

2010-04-08 Thread Gregory Crosswhite
On Apr 8, 2010, at 6:53 PM, Daniel Fischer wrote: Am Freitag 09 April 2010 02:51:23 schrieb Gregory Crosswhite: Yes, but 1/0 isn't a NaN: Prelude isNaN (1.0/0.0) False Prelude isNaN (0.0/0.0) True Prelude 1.0/0.0 Infinity Prelude 0.0/0.0 NaN Prelude (0.0/0.0) == (0.0/0.0) False

Re: [Haskell-cafe] haskell gsoc proposal for richer numerical type classes and supporting algorithms

2010-04-08 Thread Casey McCann
On Thu, Apr 8, 2010 at 8:51 PM, Gregory Crosswhite gcr...@phys.washington.edu wrote: First of all, it isn't clear to me that NaN /= NaN, since in ghci the expression 1.0/0.0 == 1.0/0.0 evaluates to True.  But even if that were the case, I would call that more of a technicality then meaning

[Haskell-cafe] floating-point comparison (was haskell gsoc proposal for richer numerical type classes and supporting algorithms)

2010-04-08 Thread Doug Burke
--- On Thu, 4/8/10, Gregory Crosswhite gcr...@phys.washington.edu wrote: From: Gregory Crosswhite gcr...@phys.washington.edu On a tangental note, I've considered coding up a package with an AlmostEq typeclass that allows one to test for approximate equality.  The problem is that different

[Haskell-cafe] haskell gsoc proposal for richer numerical type classes and supporting algorithms

2010-04-07 Thread Carter Schonwald
engine . This part is easy, just a lot of support type classes which a user wouldn't often encounter or deal with unless they're doing real math, in which case understanding them is probably key for correctly writing the desired code anyways. For those reading this who don't know the abstract algebra

Re: [Haskell-cafe] derivable type classes

2010-03-24 Thread Ozgur Akgun
Thanks for the pointers again - you are of great help every time! On 23 March 2010 17:44, Josef Svenningsson josef.svennings...@gmail.comwrote: On Tue, Mar 23, 2010 at 11:52 AM, Ozgur Akgun ozgurak...@gmail.com wrote: Can a user define a derivable type class of her own? If yes, how? GHC

[Haskell-cafe] derivable type classes

2010-03-23 Thread Ozgur Akgun
Can a user define a derivable type class of her own? If yes, how? Cheers, -- Ozgur Akgun ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] derivable type classes

2010-03-23 Thread Ivan Lazar Miljenovic
Ozgur Akgun ozgurak...@gmail.com writes: Can a user define a derivable type class of her own? No. The derivable classes are defined in the Haskell Report; GHC does allow some others to be derived with extensions however. There is one exception to this: using the GeneralizedNewtypeDeriving

Re: [Haskell-cafe] derivable type classes

2010-03-23 Thread Chris Eidhof
No. A solution for this (depending on the type class you want to derive) is Generic Programming. Using Generic Programming, you can define functions that work on the structure of the type. For example, take a look at the regular package [1]. It provides all the functionality to write your own

Re: [Haskell-cafe] derivable type classes

2010-03-23 Thread Josef Svenningsson
On Tue, Mar 23, 2010 at 11:52 AM, Ozgur Akgun ozgurak...@gmail.com wrote: Can a user define a derivable type class of her own? If yes, how? GHC has a feature which lets you define classes such that making an instance of them is as easy as deriving. It's called Generic classes. See GHC's

Re: [Haskell-cafe] The Related monad and constant values in type classes

2010-02-18 Thread Edward Kmett
I've needed something similar in the past. I used it in the reflection library, and its present on its own on hackage as 'tagged'. http://hackage.haskell.org/packages/archive/tagged/0.0/doc/html/Data-Tagged.html I talked a bit about using it here:

Re: [Haskell-cafe] The Related monad and constant values in type classes

2010-02-18 Thread Stephen Tetley
Hi Edward Does Tagged have a common synonym as its the 'opposite' of Const? I thought I'd seen the same construction used with Strafunski / StrategyLib, but if I did I can no longer find the examples. Thanks Stephen ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] The Related monad and constant values in type classes

2010-02-18 Thread Jonas Almström Duregård
Hi Edward, Nothing new under the sun it would seem :). Perhaps these functions could be useful in the Tagged library? on1 :: Tagged a v - Tagged (x a) v on1 = retag on2 :: Tagged a v - Tagged (x a x0) v on2 = retag on3 :: Tagged a v - Tagged (x a x0 x1) v on3 = retag on4 :: Tagged a v -

[Haskell-cafe] The Related monad and constant values in type classes

2010-02-17 Thread Jonas Almström Duregård
Hi, This literate haskell file was intended to be a quick question about a problem i have been pondering, but it developed into a short presentation instead. What i want to know is if there is already something like this (and suggestions for improvement of course). {-#LANGUAGE

Re: [Haskell-cafe] The Related monad and constant values in type classes

2010-02-17 Thread Sean Leather
for, but it seems related. Oleg Kiselyov, Chung-chieh Shan. Functional pearl: Implicit configurations-or, type classes reflect the values of types, in Haskell 2004. ACM, 2004, pp. 33-44. http://www.citeulike.org/user/spl/article/313800 Regards, Sean ___ Haskell-Cafe

[Haskell-cafe] Translation of Haskell type classes

2010-02-04 Thread Enrique Martín
Hello all, few days ago I made some experiments with Haskell type classes. I wrote a small Haskell program for searching in sorted lists, defining my own type classes for equality (MyEq) and order (MyOrd) so that they only have one member function

Re: [Haskell-cafe] Translation of Haskell type classes

2010-02-04 Thread Daniel Fischer
Am Donnerstag 04 Februar 2010 16:32:24 schrieb Enrique Martín: Hello all, few days ago I made some experiments with Haskell type classes. I wrote a small Haskell program for searching in sorted lists, defining my own type classes for equality (MyEq) and order (MyOrd) so that they only have

[Haskell-cafe] Re: Translation of Haskell type classes

2010-02-04 Thread Christian Maeder
some experiments with Haskell type classes. I wrote a small Haskell program for searching in sorted lists, defining my own type classes for equality (MyEq) and order (MyOrd) so that they only have one member function: class MyEq

[Haskell-cafe] Alternatives to type classes.

2009-12-29 Thread Jason Dusek
Consider the real numbers. They are a group. We have an identity element `0', inverses and closure under the associative operation `+'. Group+ = (+, 0, -1 * _) They are another group, too -- the group with `*': Group* = (*, 1, 1 / _) This seems like a real problem with the

Re: [Haskell-cafe] Alternatives to type classes.

2009-12-29 Thread Dan Doel
can't encode equational laws in the type system anyway). But if there were, we'd probably want something more like ML modules (or dependent records). And of course, that's essentially what type classes are. They're records/modules that are uniquely determined by the type(s) in question, so

Re: [Haskell-cafe] Alternatives to type classes.

2009-12-29 Thread Luke Palmer
On Tue, Dec 29, 2009 at 6:22 PM, Jason Dusek jason.du...@gmail.com wrote:  Consider the real numbers. They are a group. We have an  identity element `0', inverses and closure under the associative  operation `+'.    Group+ = (+, 0, -1 * _)  They are another group, too -- the group with `*':

Re: [Haskell-cafe] Alternatives to type classes.

2009-12-29 Thread Jason Dusek
2009/12/29 Luke Palmer lrpal...@gmail.com:  They are another group, too -- the group with `*':  Group* = (*, 1, 1 / _) Ignoring 0 for sake of discussion. Doh. -- Jason Dusek ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] Trying to sort out multiparameter type classes and their instances

2009-12-01 Thread Jeremy Fitzhardinge
I'm playing around with some types to represent a game board (like Go, Chess, Scrabble, etc). I'm using a type class to represent the basic Board interface, so I can change the implementation freely: class Board b pos piece where -- Update board with piece played at pos play :: b pos

Re: [Haskell-cafe] Trying to sort out multiparameter type classes and their instances

2009-12-01 Thread Daniel Fischer
Am Dienstag 01 Dezember 2009 23:34:46 schrieb Jeremy Fitzhardinge: I'm playing around with some types to represent a game board (like Go, Chess, Scrabble, etc). I'm using a type class to represent the basic Board interface, so I can change the implementation freely: class Board b pos piece

Re: [Haskell-cafe] Trying to sort out multiparameter type classes and their instances

2009-12-01 Thread Jeremy Fitzhardinge
On 12/01/09 15:12, Daniel Fischer wrote: Am Dienstag 01 Dezember 2009 23:34:46 schrieb Jeremy Fitzhardinge: I'm playing around with some types to represent a game board (like Go, Chess, Scrabble, etc). I'm using a type class to represent the basic Board interface, so I can change the

Re: [Haskell-cafe] Trying to sort out multiparameter type classes and their instances

2009-12-01 Thread Daniel Fischer
Am Mittwoch 02 Dezember 2009 01:43:04 schrieb Jeremy Fitzhardinge: On 12/01/09 15:12, Daniel Fischer wrote: Am Dienstag 01 Dezember 2009 23:34:46 schrieb Jeremy Fitzhardinge: I'm playing around with some types to represent a game board (like Go, Chess, Scrabble, etc). I'm using a type

Re: [Haskell-cafe] Trying to sort out multiparameter type classes and their instances

2009-12-01 Thread Jeremy Fitzhardinge
On 12/01/09 17:38, Daniel Fischer wrote: Am Mittwoch 02 Dezember 2009 01:43:04 schrieb Jeremy Fitzhardinge: On 12/01/09 15:12, Daniel Fischer wrote: Am Dienstag 01 Dezember 2009 23:34:46 schrieb Jeremy Fitzhardinge: I'm playing around with some types to represent a game board

[Haskell-cafe] Strange problem with type classes (ghc 6.8.2 looks allright and ghc 6.10.1 doesn't).

2009-09-22 Thread Serguey Zefirov
any value of a type). The type class can be easily generalized to most haskell data types and it's easy to write instance derivation using Template Haskell. I used multiparameter type classes because support for type families in Template Haskell was incomplete in 6.10.1 and prior versions

[Haskell-cafe] Strange problem with type classes (ghc 6.8.2 looks allright and ghc 6.10.1 doesn't).

2009-09-22 Thread Serguey Zefirov
(followup to my previous letter with the same subject) I found the way to break 6.8.2 type checker. It's as easy as to uncomment Div case alternative in valueIndex. Weird. I found a solution, though. Instead of (valueIndex (x_38,(x_36,x_37))) in that Div alternative I should create expression

Re: [Haskell-cafe] Essentials about type classes?

2009-09-11 Thread Kim-Ee Yeoh
it does. -- View this message in context: http://www.nabble.com/Essentials-about-type-classes--tp25393728p25405022.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Removing polymorphism from type classes (viz. Functor)

2009-07-13 Thread Henning Thielemann
George Pollard schrieb: Ok, so I have a small idea I'm trying to work on; call it a Prelude-rewrite if you want. For this I want to be able to have the hierarchy Functor → Applicative → Monad. For Functor, I would like to be able to implement it for a wider variety of types, as there are

Re: [Haskell-cafe] Removing polymorphism from type classes (viz. Functor)

2009-07-13 Thread George Pollard
It does seem that having quantified contexts would make this *much* easier... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Removing polymorphism from type classes (viz. Functor)

2009-07-09 Thread Edward Kmett
Well, you're going to wind up with a lot of cases where you really want a quantified context, even with just your Functor definition, but in that same spirit you can build an 'Applicative-like' instance as well. type family Arg f :: * type instance Arg [a - b] = [a] type family Result f :: *

[Haskell-cafe] Removing polymorphism from type classes (viz. Functor)

2009-07-07 Thread George Pollard
Ok, so I have a small idea I'm trying to work on; call it a Prelude-rewrite if you want. For this I want to be able to have the hierarchy Functor → Applicative → Monad. For Functor, I would like to be able to implement it for a wider variety of types, as there are types which have aren't

[Haskell-cafe] specialization in type classes

2009-06-05 Thread Cetin Sert
module IOStream where import System.IO import System.IO.Unsafe class Out a where out :: a → String instance Show a ⇒ Out a where out = show instance Out String where {-# SPECIALISE out :: String → String #-} out = id instance Out Char where {-# SPECIALISE out :: Char → String #-}

[Haskell-cafe] Re: specialization in type classes

2009-06-05 Thread Cetin Sert
Now there's also a stackoverflow question for this: http://stackoverflow.com/questions/955711/specialization-in-type-classes-using-ghc Any help highly appreciated! 2009/6/5 Cetin Sert cetin.s...@gmail.com module IOStream where import System.IO import System.IO.Unsafe class Out a where

Re: [Haskell-cafe] Re: specialization in type classes

2009-06-05 Thread Ryan Ingram
out function that the default) But this isn't in the language currently. -- ryan 2009/6/5 Cetin Sert cetin.s...@gmail.com: Now there's also a stackoverflow question for this: http://stackoverflow.com/questions/955711/specialization-in-type-classes-using-ghc Any help highly appreciated! 2009

Re: [Haskell-cafe] Factoring into type classes

2009-01-22 Thread Patai Gergely
could probably even be extended and turned into a tutorial on the topic. Of course type classes are not only important just for making dictionary passing implicit, but also because of their interactions, which is nicely demonstrated by the sigfpe blog entry that someone also linked from

Re: [Haskell-cafe] Factoring into type classes

2009-01-20 Thread Conor McBride
Hi folks I have been known to venture the viewpoint that the newtype trick might benefit from improved library support, for example, here http://www.mail-archive.com/haskell-cafe@haskell.org/msg37213.html This is in a similar vein to Derek's approach, if accompanied by a little more

Re: [Haskell-cafe] Factoring into type classes

2009-01-20 Thread Iavor Diatchki
Hello, I don't mean to be negative here but I really fail to see how do any of these ideas help the situation. (I do think it would be cool to have a generic way to lift functions from one type to another that is isomorphic to it). The fundamental problem is that there are multiple functions of

Re: [Haskell-cafe] Factoring into type classes

2009-01-20 Thread wren ng thornton
Luke Palmer wrote: On Mon, Jan 19, 2009 at 3:58 AM, Patai Gergely patai_gerg...@fastmail.fmwrote: However, there are other type classes that are too general to assign such concrete uses to. For instance, if a data structure can have more than one meaningful (and useful) Functor or Monoid

Re: [Haskell-cafe] Factoring into type classes

2009-01-20 Thread wren ng thornton
type classes that are too general to assign such concrete uses to. For instance, if a data structure can have more than one meaningful (and useful) Functor or Monoid instance, what should one do? Should one refrain from instantiating these classes altogether and just use the names of operations

[Haskell-cafe] Factoring into type classes

2009-01-19 Thread Patai Gergely
call it a use case?) which of these we actually want, e.g. human readable form, debug information, serialisation for later reading and so on, and one of the solutions was to propose a family of show functions that carry the intended use in their name. However, there are other type classes that are too

Re: [Haskell-cafe] Factoring into type classes

2009-01-19 Thread Eugene Kirpichov
form, debug information, serialisation for later reading and so on, and one of the solutions was to propose a family of show functions that carry the intended use in their name. However, there are other type classes that are too general to assign such concrete uses to. For instance, if a data

Re: [Haskell-cafe] Factoring into type classes

2009-01-19 Thread Luke Palmer
On Mon, Jan 19, 2009 at 3:58 AM, Patai Gergely patai_gerg...@fastmail.fmwrote: However, there are other type classes that are too general to assign such concrete uses to. For instance, if a data structure can have more than one meaningful (and useful) Functor or Monoid instance, As a side

Re: [Haskell-cafe] Factoring into type classes

2009-01-19 Thread Antoine Latter
2009/1/19 Luke Palmer lrpal...@gmail.com: As a side curiosity, I would love to see an example of any data structure which has more than one Functor instance. Especially those which have more than one useful functor instance. (,) ? -Antoine ___

Re: [Haskell-cafe] Factoring into type classes

2009-01-19 Thread Thomas DuBuisson
2009/1/19 Luke Palmer lrpal...@gmail.com: On Mon, Jan 19, 2009 at 3:58 AM, Patai Gergely patai_gerg...@fastmail.fm wrote: However, there are other type classes that are too general to assign such concrete uses to. For instance, if a data structure can have more than one meaningful

Re: [Haskell-cafe] Factoring into type classes

2009-01-19 Thread Daniel Fischer
Am Montag, 19. Januar 2009 14:31 schrieb Antoine Latter: 2009/1/19 Luke Palmer lrpal...@gmail.com: As a side curiosity, I would love to see an example of any data structure which has more than one Functor instance. Especially those which have more than one useful functor instance. (,) ?

Re: [Haskell-cafe] Factoring into type classes

2009-01-19 Thread Holger Siegel
Am Montag, den 19.01.2009, 14:47 +0100 schrieb Daniel Fischer: Am Montag, 19. Januar 2009 14:31 schrieb Antoine Latter: 2009/1/19 Luke Palmer lrpal...@gmail.com: As a side curiosity, I would love to see an example of any data structure which has more than one Functor instance. Especially

Re: [Haskell-cafe] Factoring into type classes

2009-01-19 Thread Lennart Augustsson
The desugaring of (, a) would involve some type level lambda, and that's not something that is available (yet). -- Lennart On Mon, Jan 19, 2009 at 1:49 PM, Holger Siegel holgersiege...@yahoo.de wrote: Am Montag, den 19.01.2009, 14:47 +0100 schrieb Daniel Fischer: Am Montag, 19. Januar 2009

Re: [Haskell-cafe] Factoring into type classes

2009-01-19 Thread Patai Gergely
As a side curiosity, I would love to see an example of any data structure which has more than one Functor instance. Especially those which have more than one useful functor instance. data Record a b = R { field1 :: a, field2 :: b } If I want to use fmap to transform either field, I have to

Re: [Haskell-cafe] Factoring into type classes

2009-01-19 Thread Iavor Diatchki
Hello, The multitude of newtypes in the Monoid module are a good indication that the Monoid class is not a good fit for the class system (it is ironic that discussing it resulted in such a huge thread recently :-). How I'd approach the situation that you describe would depend on the context

Re: [Haskell-cafe] Factoring into type classes

2009-01-19 Thread Jonathan Cast
On Mon, 2009-01-19 at 10:59 -0800, Iavor Diatchki wrote: Hello, The multitude of newtypes in the Monoid module are a good indication that the Monoid class is not a good fit for the class system I would say rather that the class system is not a good fit for Monoid. Proposals for local

Re: [Haskell-cafe] Factoring into type classes

2009-01-19 Thread Iavor Diatchki
Hi, On Mon, Jan 19, 2009 at 11:06 AM, Jonathan Cast jonathancc...@fastmail.fm wrote: On Mon, 2009-01-19 at 10:59 -0800, Iavor Diatchki wrote: Hello, The multitude of newtypes in the Monoid module are a good indication that the Monoid class is not a good fit for the class system I would say

Re: [Haskell-cafe] Factoring into type classes

2009-01-19 Thread Alberto G. Corona
Palmer lrpal...@gmail.com: On Mon, Jan 19, 2009 at 3:58 AM, Patai Gergely patai_gerg...@fastmail.fm wrote: However, there are other type classes that are too general to assign such concrete uses to. For instance, if a data structure can have more than one meaningful (and useful) Functor

Re: [Haskell-cafe] Factoring into type classes

2009-01-19 Thread Jonathan Cast
that, if we're going to restrict type classes to only those cases where we never want to specialize an overloaded function to a non-standard instance, that we're going to end up with Eq, Num, and maybe Functor as classes. I'm not sure a general language mechanism is really needed just for those three

Re: [Haskell-cafe] Factoring into type classes

2009-01-19 Thread Derek Elkins
patai_gerg...@fastmail.fm wrote: However, there are other type classes that are too general to assign such concrete uses to. For instance, if a data structure can have more than one meaningful (and useful) Functor or Monoid

Re: [Haskell-cafe] Factoring into type classes

2009-01-19 Thread Miguel Mitrofanov
19, 2009 at 3:58 AM, Patai Gergely patai_gerg...@fastmail.fm wrote: However, there are other type classes that are too general to assign such concrete uses to. For instance, if a data structure can have more than one meaningful (and useful) Functor or Monoid instance, As a side

Re: [Haskell-cafe] Factoring into type classes

2009-01-19 Thread Derek Elkins
On Mon, 2009-01-19 at 12:10 -0800, Iavor Diatchki wrote: Hi, On Mon, Jan 19, 2009 at 11:06 AM, Jonathan Cast jonathancc...@fastmail.fm wrote: On Mon, 2009-01-19 at 10:59 -0800, Iavor Diatchki wrote: Hello, The multitude of newtypes in the Monoid module are a good indication that the

<    1   2   3   4   5   6   7   >