Re: [Haskell] Newbie help with type-classes

2007-05-11 Thread Bas van Dijk
so how could that instance ever apply? Is there something basic about type-classes that I'm not understanding here? My actual problem is more complicated than this, but this test-case covers the basic issue; something being an instance of class A means that I can derive an instance of class B

Re: [Haskell] Newbie help with type-classes

2007-05-11 Thread Bas van Dijk
; () is not an instance of ConvertToInt so how could that instance ever apply? Is there something basic about type-classes that I'm not understanding here? My actual problem is more complicated than this, but this test-case covers the basic issue; something being an instance of class A means that I can derive

Re: [Haskell] Newbie help with type-classes

2007-05-11 Thread Derek Elkins
apply? I write anywhere, instance ConvertToInt () where ... Now it is overlapping. Is there something basic about type-classes that I'm not understanding here? They are open (Open World Assumption). I can add a new instance anywhere at any time. Code below: {-# OPTIONS -fglasgow-exts

[Haskell] Newbie help with type-classes

2007-05-10 Thread Ryan Ingram
how could that instance ever apply? Is there something basic about type-classes that I'm not understanding here? My actual problem is more complicated than this, but this test-case covers the basic issue; something being an instance of class A means that I can derive an instance of class B

[Haskell-cafe] Roles == type classes ???

2007-05-09 Thread Magnus Therning
The way roles/traits are described in [1] (and the pages it links to) make me think of Haskell type classes. Am I completely off in doing that? /M [1]: http://griddlenoise.blogspot.com/2007/05/traits-roles-as-alternative-to-abstract.html -- Magnus Therning

Re: [Haskell-cafe] Roles == type classes ???

2007-05-09 Thread Ketil Malde
On Wed, 2007-05-09 at 10:41 +0100, Magnus Therning wrote: The way roles/traits are described in [1] (and the pages it links to) make me think of Haskell type classes. Am I completely off in doing that? At http://mail.python.org/pipermail/python-3000/2007-April/007026.html we find this passage

RE: [Haskell-cafe] GADTs, type classes, existentials

2007-05-07 Thread Simon Peyton-Jones
| Type classes and GADTs are broken in all versions prior to HEAD (at | which point Simon made a heroic effort to do something I don't quite | understand to the type checker). Well, not that heroic, but certainly long-postponed :-) Simon ___ Haskell

[Haskell-cafe] GADTs, type classes, existentials

2007-05-06 Thread Mike Hamburg
Hello all, I'm trying to build a variation on Maps which supports a fast concat-like operation, for a library I'm writing. I'd rather not re-implement Data.Map, so I'm having a try with GADTs. The relevant part of my source file:

Re: [Haskell-cafe] GADTs, type classes, existentials

2007-05-06 Thread Stefan O'Rear
propagated into the function body. Of course, I can't add Ord k to the type signature for lookup, because one can't deduce Ord k from Ord (k1,k2). Is there a clean way around this error? Yes, upgrade. Type classes and GADTs are broken in all versions prior to HEAD (at which point Simon made

Re: [Haskell-cafe] GADTs, type classes, existentials

2007-05-06 Thread Mike Hamburg
On Sun, 2007-05-06 at 07:10 -0700, Stefan O'Rear wrote: On Sun, May 06, 2007 at 03:11:12AM -0700, Mike Hamburg wrote: Is there a clean way around this error? Yes, upgrade. Type classes and GADTs are broken in all versions prior to HEAD (at which point Simon made a heroic effort to do

[Haskell-cafe] Re: Type classes and type equality

2007-04-19 Thread oleg
- If we permit overlapping instances extension, then a few lines of code decide equality for all existing and future types: class TypeEq x y b | x y - b instance TypeEq x x HTrue instance TypeCast HFalse b = TypeEq x y b This is exactly what I was after, but

Re: [Haskell-cafe] Efficient use of ByteString and type classes in template system

2007-04-17 Thread Thomas Hartman
Created wiki page http://haskell.org/haskellwiki/String_Interpolation and referenced various topics mentioned in this thread, there. 2007/4/16, Donald Bruce Stewart [EMAIL PROTECTED]: johan.tibell: Hi Haskell Caf?! I'm writing a perl/python like string templating system which I plan to

[Haskell-cafe] Re: Type classes and type equality

2007-04-17 Thread Neil Mitchell
Hi Oleg, I'm looking for a type class which checks whether two types are the same or not. For the full discussion of various solutions, please see Section 9 and Appendix D of the HList paper: http://homepages.cwi.nl/~ralf/HList/paper.pdf Thanks for pointing that out. As far as I

Re: [Haskell-cafe] Efficient use of ByteString and type classes in template system

2007-04-17 Thread Johan Tibell
Great! I've written some QuickCheck tests now (not commited) so I can start to swap out the implementation and benchmark it. After I get it to run fast enough and some nice utility methods (like the possibility of using records as context) I'll announce a version 1.0. Johan On 4/17/07, Thomas

[Haskell-cafe] Re: Type classes and type equality

2007-04-17 Thread oleg
Thanks for pointing that out. As far as I can see, this requires a new instance declaration for every type? I guess it depends on how many extensions one may wish to enable. At the very least we need multi-parameter type classes with functional dependencies (because that's what TypeEq

[Haskell-cafe] Re: Type classes and type equality

2007-04-17 Thread Neil Mitchell
Hi I guess it depends on how many extensions one may wish to enable. At the very least we need multi-parameter type classes with functional dependencies (because that's what TypeEq is in any case). - If we permit no other extension, we need N^2 instances to compare N classes for equality

Re: [Haskell-cafe] Re: Type classes and type equality

2007-04-17 Thread Stefan O'Rear
On Wed, Apr 18, 2007 at 01:47:04AM +0100, Neil Mitchell wrote: - If we permit undecidable instances, one may assign numerals to types. This gives us total order and hence comparison on types. In this approach, we only need N instances to cover N types. This is still better than Typeable

[Haskell-cafe] Type classes and type equality

2007-04-16 Thread Neil Mitchell
Hi, I'm looking for a type class which checks whether two types are the same or not. My first guess is: class Same a b where same :: a - b - Bool instance Same a a where same _ _ = True instance Same a b where same _ _ = False In Hugs this seems to work with overlapping instances (not

Re: [Haskell-cafe] Type classes and type equality

2007-04-16 Thread Jeremy Shaw
At Mon, 16 Apr 2007 13:44:13 +0100, Neil Mitchell wrote: Hi, So my question is if this is safe? Will the compiler always pick the right one? Is there a better way to do this? I noticed that the results can be a bit suprising sometimes. See if you can predict the answers to these (in ghci):

Re: [Haskell-cafe] Type classes and type equality

2007-04-16 Thread Clifford Beshers
Jeremy Shaw wrote: I noticed that the results can be a bit suprising sometimes. See if you can predict the answers to these (in ghci): Interesting examples. Here's another one that I would find problematic: *SameType same Nothing (Just xyzzy) False *SameType same (Nothing ::

Re: [Haskell-cafe] Efficient use of ByteString and type classes in template system

2007-04-15 Thread Donald Bruce Stewart
johan.tibell: Hi Haskell Caf?! I'm writing a perl/python like string templating system which I plan to release soon: darcs get http://darcs.johantibell.com/template The goal is to provide simple string templating; no inline code, etc.. An alternative to printf and ++. Ok. You might

[Haskell-cafe] Efficient use of ByteString and type classes in template system

2007-04-14 Thread Johan Tibell
Hi Haskell Café! I'm writing a perl/python like string templating system which I plan to release soon: darcs get http://darcs.johantibell.com/template The goal is to provide simple string templating; no inline code, etc.. An alternative to printf and ++. Example usage: import qualified

[Haskell-cafe] MPTC and type classes issue (polymorphic '+')

2007-04-07 Thread Joel Reymont
Folks, I'm trying to save time when typing in my ASTs so I thought I would create a Plus class like this (I do hide the one from Prelude) class PlusClass a b c | a b - c where (+) :: a - b - c {- instance (Integral a, Integral b) = PlusClass a b Expr where a + b = NumExpr (NumOp

Re: [Haskell-cafe] MPTC and type classes issue (polymorphic '+')

2007-04-07 Thread Pepe Iborra
input2 = [ InputDecs [ inp emaLength TyNumber (20 + 40) ] ] (untested). Imho the simple, dumb, best fix for this is to give a explicit type to those values. input2 = [ InputDecs [ inp emaLength TyNumber ((20::Integer) + (40::Integer)) ] ] This is just one way to fix it. You

Re: [Haskell-cafe] MPTC and type classes issue (polymorphic '+')

2007-04-07 Thread Joel Reymont
Pepe, On Apr 7, 2007, at 1:31 PM, Pepe Iborra wrote: input2 = [ InputDecs [ inp emaLength TyNumber ((20::Integer) + (40::Integer)) ] ] Thank you for your suggestion! I'm trying to make my AST definition as succinct as possible, though, so I would really love to have 20 + 40. The issue

Re: [Haskell-cafe] MPTC and type classes issue (polymorphic '+')

2007-04-07 Thread Joel Reymont
This is the related paste: http://hpaste.org/1291#a9 -- http://wagerlabs.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] MPTC and type classes issue (polymorphic '+')

2007-04-07 Thread Joel Reymont
Pepe, On Apr 7, 2007, at 2:01 PM, Pepe Iborra wrote: And without the Integral assumption, you cannot define your instance. So what I would do is to create a thin wrapper: i = id :: Integer - Integer and write: input2 = [ InputDecs [ inp emaLength TyNumber ((i 20) + (i 40)) ] ] That's

Re: [Haskell-cafe] MPTC and type classes issue (polymorphic '+')

2007-04-07 Thread Joel Reymont
On Apr 7, 2007, at 2:01 PM, Pepe Iborra wrote: So what I would do is to create a thin wrapper: i = id :: Integer - Integer and write: input2 = [ InputDecs [ inp emaLength TyNumber ((i 20) + (i 40)) ] ] I do it like this and it does save typing. It's not bad so I'll stick to it for

Re: [Haskell-cafe] MPTC and type classes issue (polymorphic '+')

2007-04-07 Thread Stefan O'Rear
On Sat, Apr 07, 2007 at 01:07:48PM +0100, Joel Reymont wrote: Folks, I'm trying to save time when typing in my ASTs so I thought I would create a Plus class like this (I do hide the one from Prelude) class PlusClass a b c | a b - c where (+) :: a - b - c {- instance (Integral a,

Re: [Haskell-cafe] MPTC and type classes issue (polymorphic '+')

2007-04-07 Thread Joel Reymont
On Apr 7, 2007, at 4:16 PM, Stefan O'Rear wrote: You can probably use -fallow-incoherent-instances for this. It has a scary name on purpose since it doesn't usually do what you think it should... My (very limited!) understanding of type checking algorithms says that in this case, the worst

[Haskell-cafe] Type classes to 'reflect' constructor structure

2007-04-05 Thread Jules Bean
In the thread 'automatic derivation', Joel Reymont is looking for metaprogramming functionality with which he wants to automatically derive a parser and a pretty printer for his ADT (which is an AST for a minilanguage). I replied showing that a significant amount of the boilerplate could be

Re: RULES and type classes

2007-03-29 Thread Donald Bruce Stewart
haskell: Is there any way to use RULES substitutions with type classes? I'm writing a reactive programming arrow (same idea as Yampa, different design goals), and it would help performance (and not just in the speed sense) to be able to tell when a value derived with arr hasn't changed. So

Re: RULES and type classes

2007-03-29 Thread Pepe Iborra
On 29/03/2007, at 11:38, Mike Hamburg wrote: Is there any way to use RULES substitutions with type classes? I'm writing a reactive programming arrow (same idea as Yampa, different design goals), and it would help performance (and not just in the speed sense) to be able to tell when

[Haskell-cafe] Non-exported type classes?

2007-03-03 Thread Roberto Zunino
What is the effect of declaring a class in a module and not exporting it? Would that prevent to add more instances to that class other than those already defined in the module? More in detail, consider this module: === module Peano (Z,S,C) where data Z data S a -- Not exported class Peano b

Re: [Haskell-cafe] Non-exported type classes?

2007-03-03 Thread Stefan O'Rear
On Sun, Mar 04, 2007 at 01:03:45AM +0100, Roberto Zunino wrote: What is the effect of declaring a class in a module and not exporting it? Would that prevent to add more instances to that class other than those already defined in the module? More in detail, consider this module: === module

Re: [Haskell-cafe] Non-exported type classes?

2007-03-03 Thread Lennart Augustsson
Yes, as far as I can tell, C would be limited to Z and S. Nice trick! -- Lennart On Mar 4, 2007, at 00:03 , Roberto Zunino wrote: What is the effect of declaring a class in a module and not exporting it? Would that prevent to add more instances to that class other than those already

RE: [Haskell] A question about a possible bug in GHC regarding GADTs and type classes

2007-01-18 Thread Simon Peyton-Jones
[redirecting to ghc-users] This code works with the HEAD, where I recently fixed the interaction between GADTs and type classes. You'll need to use a HEAD compiler (not 6.6) though. Someone else may help you with the TyRange stuff; I'm just referring to the Num constraint in your data type

[Haskell] A question about a possible bug in GHC regarding GADTs and type classes

2007-01-17 Thread Pablo Nogueira
(If c t e) = if (evalExp c) then (evalExp t) else (evalExp e) -- The type checker complains that evalExp needs a Num constraint on its type signature. This can't be right, for Bool is not an instance of Num, right? Is it the case that the interaction between GADTs and type classes is not fully

[Haskell-cafe] multi parameter type classes for NP problems

2006-12-20 Thread Joshua Ball
. Here is how I am trying to solve the problem, using multi-parameter type classes. class NPProblem inst cert where validates :: cert - inst - Bool certificates :: inst - [cert] decide :: inst - Bool decide i = any (\x - x `validates` i) $ certificates i Unfortunately, ghc throws

Re: [Haskell-cafe] multi parameter type classes for NP problems

2006-12-20 Thread Greg Buchholz
Joshua Ball wrote: Here is how I am trying to solve the problem, using multi-parameter type classes. class NPProblem inst cert where validates :: cert - inst - Bool certificates :: inst - [cert] decide :: inst - Bool decide i = any (\x - x `validates` i) $ certificates i

Re: [Haskell-cafe] multi parameter type classes for NP problems

2006-12-20 Thread Joshua Ball
That works. Thanks. I didn't realize you could put types in the expression itself. On 12/20/06, Greg Buchholz [EMAIL PROTECTED] wrote: Joshua Ball wrote: Here is how I am trying to solve the problem, using multi-parameter type classes. class NPProblem inst cert where validates :: cert

Re: [Haskell-cafe] Are associated types synonyms like type classes?

2006-11-17 Thread Manuel M T Chakravarty
, an associated type should be used if one type depends on the other. Bulat wrote: Also, has anybody written a paper on the differences between typeclasses + associated types and ML's module system + overloading? ML Modules and Haskell Type Classes: A Constructive Comparison http://www.informatik.uni

[Haskell-cafe] Re: Numeric type classes

2006-09-20 Thread Aaron Denney
On 2006-09-12, Brian Hulley [EMAIL PROTECTED] wrote: Bryan Burgers wrote: That being said, I'll have to play the other side of the coin: it would probably be a little bit of a pain to have to define instances of each data declaration (Integer, Int, Float, Matrix, Complex, etc.) on each of

[Haskell-cafe] Re: Numeric type classes

2006-09-20 Thread Aaron Denney
On 2006-09-12, Jacques Carette [EMAIL PROTECTED] wrote: First, as already pointed out in http://www.haskell.org/pipermail/haskell-cafe/2006-April/015404.html there is a lot of relevant previous work in this area. I'm afraid I don't see the relevance. This is very easy to do in 'raw' category

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-20 Thread Jacques Carette
Whenever people start discussing the Numeric type classes, the true scope of what a refactoring can (and should?) be is frequently under-estimated. The 'structure' of algebraic objects in mathematics has been studied quite a lot (in mathematics and in CS, but not so much by programming

[Haskell-cafe] Re: Numeric type classes

2006-09-20 Thread Aaron Denney
On 2006-09-20, Jacques Carette [EMAIL PROTECTED] wrote: [Hopefully this answers your 'relevance' question]. Yes. I was focusing on the more narrow aspect, rather than what had started this thread. In other words, the specification language people have been down this road quite some time

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-15 Thread Henning Thielemann
On Thu, 14 Sep 2006, David Menendez wrote: Ross Paterson writes: On Thu, Sep 14, 2006 at 01:11:56AM -0400, David Menendez wrote: Coincidentally, I spent some time last week thinking about a replacement for the Num class. I think I managed to come up with something that's more

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-14 Thread ajb
G'day all. Quoting Henning Thielemann [EMAIL PROTECTED]: A monoid operation is associative, isn't it? Duh. Yes. Sorry. Need caffeine. Cheers, Andrew Bromage ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-14 Thread Ross Paterson
On Thu, Sep 14, 2006 at 01:11:56AM -0400, David Menendez wrote: Ross Paterson writes: I've collected some notes on these issues at http://haskell.galois.com/cgi-bin/haskell-prime/trac.cgi/wiki/StandardClasses Coincidentally, I spent some time last week thinking about a replacement for

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-14 Thread David Menendez
Ross Paterson writes: On Thu, Sep 14, 2006 at 01:11:56AM -0400, David Menendez wrote: Coincidentally, I spent some time last week thinking about a replacement for the Num class. I think I managed to come up with something that's more flexible than Num, but still mostly comprehensible.

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-14 Thread Jacques Carette
David Menendez wrote: * Having (+) work on lists, tuples and all the other monoids would make error messages more complicated. It gets worse than that. Imagine trying to explain to someone why 1 + sin is actually \a - const 1 a + sin a. It isn't that hard - it is done routinely in

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-14 Thread Jacques Carette
[EMAIL PROTECTED] wrote: That is what polymorphism is all about! Not in this context, sorry. This is a convention. Another one may give you an abomination, e.g., 1+sin means 1 plus the addres of the sin routine. (Of course not in a 'decent' language, but I know a few undecent. No, it is

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-13 Thread ajb
G'day all. Quoting Jason Dagit [EMAIL PROTECTED]: I was making an embedded domain specific language for excel spreadsheet formulas recently and found that making my formula datatype an instance of Num had huge pay offs. Just so you know, what we're talking about here is a way to make that

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-13 Thread Ross Paterson
On Tue, Sep 12, 2006 at 08:59:30PM -0400, [EMAIL PROTECTED] wrote: One of the proposals that comes up every so often is to allow the declaration of a typeclass instance to automatically declare instances for all superclasses. So, for example: class (Functor m) = Monad m where

[Haskell-cafe] Re: Numeric type classes

2006-09-13 Thread Henning Thielemann
or whatever is not exactly mapped to Haskell's type classes. It is even used laxly in mathematics. One often says the set of integers is a ring. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-13 Thread Lennart Augustsson
The sum function really only needs the argument list to be a monoid. And the same is true for the product function, but with 1 and * as the monoid operators. Sum and product are really the same function. :) I don't think Haskell really has the mechanisms for setting up an algebraic class

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-13 Thread Henning Thielemann
On Wed, 13 Sep 2006, Lennart Augustsson wrote: The sum function really only needs the argument list to be a monoid. And the same is true for the product function, but with 1 and * as the monoid operators. Sum and product are really the same function. :) ... which got the same name, too,

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-13 Thread ajb
G'day all. Quoting Henning Thielemann [EMAIL PROTECTED]: ... which got the same name, too, namely 'foldl'. You mean foldr. The place of foldl is a bit tricky, but in this case it requires that the monoid be Abelian. Cheers, Andrew Bromage ___

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-13 Thread Brian Hulley
Henning Thielemann wrote: On Wed, 13 Sep 2006, Lennart Augustsson wrote: I don't think Haskell really has the mechanisms for setting up an algebraic class hierarchy the right way. Consider some classes we might want to build: SemiGroup Monoid AbelianMonoid Group AbelianGroup SemiRing Ring ...

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-13 Thread Jacques Carette
Your solution would imply[1] that all Rational are multiplicatively invertible -- which they are not. The Rationals are not a multiplicative group -- although the _positive_ Rationals are. You can't express this in Haskell's type system AFAIK. Your basic point is correct: if you are willing

[Haskell-cafe] Re: Numeric type classes

2006-09-13 Thread Aaron Denney
On 2006-09-13, Ross Paterson [EMAIL PROTECTED] wrote: On Tue, Sep 12, 2006 at 08:59:30PM -0400, [EMAIL PROTECTED] wrote: One of the proposals that comes up every so often is to allow the declaration of a typeclass instance to automatically declare instances for all superclasses. So, for

[Haskell-cafe] Re: Numeric type classes

2006-09-13 Thread Ashley Yakeley
Aaron Denney wrote: I know of no good way to express that a given data type obeys the same interface two (or more) ways. The best approach here is to use data structures instead of classes: data Monoid a = MkMonoid { monoidNull :: a, monoidFunc :: a - a - a } -- Ashley Yakeley

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-13 Thread David Menendez
Ross Paterson writes: Such features would be useful, but are unlikely to be available for Haskell'. If we concede that, is it still desirable to make these changes to the class hierarchy? I've collected some notes on these issues at

[Haskell-cafe] Re: Numeric type classes

2006-09-12 Thread Henning Thielemann
On Mon, 11 Sep 2006, Ross Paterson wrote: On Mon, Sep 11, 2006 at 04:26:30PM +0200, Henning Thielemann wrote: On Sat, 9 Sep 2006, Ross Paterson wrote: I think that a finer grain numeric hierarchy, while retaining Num, etc, is feasible without changing the language: unlike the case of

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-12 Thread Bryan Burgers
It seems we are at a point, where we have to define what is a 'number'. More precisely: Can you tell me the difference between numbers and more complex mathematical objects? Is a complex number a number? Is a quaternion a number? Is a residue class a number? We can calculate with integers modulo

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-12 Thread Tim Walkenhorst
Bryan Burgers schrieb: [...] it would probably be a little bit of a pain to have to define instances of each data declaration (Integer, Int, Float, Matrix, Complex, etc.) on each of these seperate classes--especially when being in a certain class usually implies being in another [...]

[Haskell-cafe] Re: Numeric type classes

2006-09-12 Thread Aaron Denney
On 2006-09-12, Bryan Burgers [EMAIL PROTECTED] wrote: And another problem I can see is that, for example, the Integers are a group over addition, and also a group over multiplication; Not over multiplication, no, because there is no inverse. I know of no good way to express that a given data

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-12 Thread Brian Hulley
Bryan Burgers wrote: That being said, I'll have to play the other side of the coin: it would probably be a little bit of a pain to have to define instances of each data declaration (Integer, Int, Float, Matrix, Complex, etc.) on each of these seperate classes--especially when being in a certain

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-12 Thread ajb
G'day all. Quoting Henning Thielemann [EMAIL PROTECTED]: It seems we are at a point, where we have to define what is a 'number'. For backwards compatibility, I'd say a Num is what it is at the moment. One of the proposals that comes up every so often is to allow the declaration of a typeclass

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-12 Thread Jason Dagit
On 9/12/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: G'day all. Quoting Henning Thielemann [EMAIL PROTECTED]: More precisely: Can you tell me the difference between numbers and more complex mathematical objects? Yes. A Num is anything which supports the common mathematically- significant

[Haskell-cafe] Numeric type classes (Was: map (-2) [1..5])

2006-09-11 Thread Henning Thielemann
On Sat, 9 Sep 2006, Ross Paterson wrote: On Sat, Sep 09, 2006 at 12:57:56AM -0400, Cale Gibbard wrote: Num itself needs to be split, but we can't do it sanely without something like class aliases. I think that a finer grain numeric hierarchy, while retaining Num, etc, is feasible

[Haskell-cafe] Re: Numeric type classes (Was: map (-2) [1..5])

2006-09-11 Thread Ross Paterson
On Mon, Sep 11, 2006 at 04:26:30PM +0200, Henning Thielemann wrote: On Sat, 9 Sep 2006, Ross Paterson wrote: I think that a finer grain numeric hierarchy, while retaining Num, etc, is feasible without changing the language: unlike the case of monads, the people who will be defining

[Haskell-cafe] Re: Numeric type classes (Was: map (-2) [1..5])

2006-09-11 Thread Aaron Denney
On 2006-09-11, Henning Thielemann [EMAIL PROTECTED] wrote: On Sat, 9 Sep 2006, Ross Paterson wrote: On Sat, Sep 09, 2006 at 12:57:56AM -0400, Cale Gibbard wrote: Num itself needs to be split, but we can't do it sanely without something like class aliases. I think that a finer grain

Re[2]: [Haskell-cafe] Are associated types synonyms like type classes?

2006-09-03 Thread Bulat Ziganshin
Hello Brian, Saturday, September 2, 2006, 10:19:17 PM, you wrote: What is the practical difference between class A and class B? With class A we can define instances so that f is overloaded (Int - Bool), (String - Bool), (Bool - Bool) by defining instances of A for Int, String, and Bool, but

Re: [Haskell-cafe] Are associated types synonyms like type classes?

2006-09-02 Thread Brian Smith
supportsmulti-parameter type classes (MPTC): class AB a b wherefoo :: a - binstance AB Int Bool where foo = (==0)AT replaces MPTC with FD (functional dependency), which allows tospecify which type parameter of MPTC is detremined by another one, i.e.:class AB a b | a-b where for further details

[Haskell-cafe] Are associated types synonyms like type classes?

2006-09-01 Thread Brian Smith
I read the easy parts of the Associated Types with Class and Associated Type Synonyms papers. An associated type synonym seems to kind of work similarly to a restricted form of class. In what way are the two following examples different? -- define a class with a type synonym, and a set of

Re: [Haskell-cafe] Are associated types synonyms like type classes?

2006-09-01 Thread Stefan Holdermans
Brian, I read the easy parts of the Associated Types with Class and Associated Type Synonyms papers. An associated type synonym seems to kind of work similarly to a restricted form of class. In what way are the two following examples different? -- define a class with a type synonym,

Re: [Haskell-cafe] Are associated types synonyms like type classes?

2006-09-01 Thread Bulat Ziganshin
    foo :: a - b instance A Int, B Bool where   foo = (==0) where you've find such unusual syntax? :) GHC/Hugs supports multi-parameter type classes (MPTC): class AB a b where foo :: a - b instance AB Int Bool where     foo = (==0) AT replaces MPTC with FD (functional

[Haskell-cafe] OOP vs type classes: Everything is object?

2006-08-26 Thread Bulat Ziganshin
Hello haskell-cafe, i've added section http://haskell.org/haskellwiki/OOP_vs_type_classes#Everything_is_object.3F which lists cases when we DON'T use type classes to emulate OOP classes features -- Best regards, Bulat mailto:[EMAIL PROTECTED

[Haskell-cafe] OOP vs type classes Re: type gurus, can you please help?

2006-08-16 Thread Bulat Ziganshin
Hello Bulat, Monday, August 14, 2006, 10:37:37 AM, you wrote: i'm started to write article about type classes. can you, type gurus, please check this initial text for correctness in explaining differences between classes and type classes? i continue to develop this text. below is list

OOP vs type classes Re[2]: [Haskell-cafe] type gurus, can you please help?

2006-08-16 Thread Bulat Ziganshin
Hello Gabriel, Tuesday, August 15, 2006, 10:36:28 PM, you wrote: | Moreover, Haskell type classes supports inheritance. Run-time | polymorphism together with inheritance are often seen as OOP | distinctive points, so during long time i considered type classes as a | form of OOP

Re: OOP vs type classes Re[2]: [Haskell-cafe] type gurus, can you please help?

2006-08-16 Thread Gabriel Dos Reis
Bulat Ziganshin [EMAIL PROTECTED] writes: | Hello Gabriel, | | Tuesday, August 15, 2006, 10:36:28 PM, you wrote: | | | Moreover, Haskell type classes supports inheritance. Run-time | | polymorphism together with inheritance are often seen as OOP | | distinctive points, so during long time i

[Haskell] Paper announcement: Software Extension and Integration with Type Classes

2006-07-31 Thread Ralf Lammel
and Integration with Type Classes Authors: Ralf Lämmel and Klaus Ostermann Abstract The abilities to extend a software module and to integrate a software module into an existing software system without changing existing source code are fundamental challenges in software engineering and programming

Re: [Haskell-cafe] The Marriage of Heaven and Hell: Type Classes and Bit-Twiddling

2006-04-13 Thread David F. Place
Sorry to respond to my own message, but I found a much more satisfactory way to solve this problem. ghc is able to specialize it so that data Test1 = Foo | Bar | Baaz | Quux deriving (Enum, Bounded) sizeTest1 :: (Set Test1) - Int sizeTest1 = sizeB compiles into a call directly to

[Haskell-cafe] The Marriage of Heaven and Hell: Type Classes and Bit-Twiddling

2006-04-11 Thread David F. Place
Hi: Looking around further for a charming way to count bits, I found a method that is completely inscrutable might be very fast. http://graphics.stanford.edu/~seander/bithacks.html Counting bits set in 12, 24, or 32-bit words using 64-bit instructions I thought it would be neat to have

[Haskell-cafe] Re: how would this be done? type classes?existential types?

2006-03-23 Thread Ben Rudiak-Gould
Brian Hulley wrote: Is there a reason for using instead of [exists a. Resource a=a] ? Only that = looks like a function arrow, looks like a tuple. I stole this notation from an unpublished paper by SimonPJ et al on adding existential quantification to Haskell. I'm not especially

Re: [Haskell-cafe] Re: how would this be done? type classes?existentialtypes?

2006-03-23 Thread Brian Hulley
Ben Rudiak-Gould wrote: Brian Hulley wrote: Is there a reason for using instead of [exists a. Resource a=a] ? Only that = looks like a function arrow, looks like a tuple. I stole this notation from an unpublished paper by SimonPJ et al on adding existential quantification to

[Haskell-cafe] Define combination of type classes?

2006-03-23 Thread Fritz Ruehr
What is the easiest way to name a combination of type classes, i.e., to abbreviate the fact that a certain type is an instance of several classes simultaneously? I have a vague sense that this is do-able, but that I am messing up by trying to use an empty class body as below. So in the code

Re: [Haskell-cafe] Define combination of type classes?

2006-03-23 Thread Sean Seefried
On 24/03/2006, at 12:45 PM, Fritz Ruehr wrote: What is the easiest way to name a combination of type classes, i.e., to abbreviate the fact that a certain type is an instance of several classes simultaneously? I have a vague sense that this is do-able, but that I am messing up by trying

[Haskell-cafe] Type classes

2006-03-20 Thread Max Vasin
Hi! I'm currently experimenting with a bibliography generation tool for LaTeX. It will (if it will be finished) use BibTeX databases but bibliography styles will be written in Haskell. I want styles to be able to transform database entries into some style specific data type, so I define class

Re: [Haskell-cafe] Type classes

2006-03-20 Thread Stefan Holdermans
Max, class DatabaseEntry e where entryLabel :: e - String formatEntry:: e - String compareEntries :: e - e - Ordering Then I define data Entry = forall a. (DatabaseEntry a) = Entry a instance DatabaseEntry Entry where entryLabel (Entry e) = entryLabel e

RE: [Haskell-cafe] Type classes

2006-03-20 Thread Geest, G. van den
Title: RE: [Haskell-cafe] Type classes I suppose you want to define compareEntries like this: compareEntries (Entry x) (Entry y) = compareEntries x y An option is to just implement it the following way (Haskell98!): class DatabaseEntry e where entryLabel :: e - String formatEntry :: e

[Haskell-cafe] Re: Type classes

2006-03-20 Thread Max Vasin
Geest, == Geest, G van den [EMAIL PROTECTED] writes: Geest, I suppose you want to define compareEntries like this: compareEntries (Entry x) (Entry y) = compareEntries x y Geest, An option is to just implement it the following way Geest, (Haskell98!): class DatabaseEntry e where entryLabel ::

Re: [Haskell-cafe] Re: Type classes

2006-03-20 Thread Gerrit van den Geest
Then you should produce 'some canonical representation for database entries suited for comparison', like Stefan mentioned. For example: data Entry = forall a. (DatabaseEntry a) = Entry a instance DatabaseEntry Entry where entryLabel (Entry e) = entryLabel e formatEntry (Entry e) =

[Haskell-cafe] Re: Type classes

2006-03-20 Thread Max Vasin
Stefan == Stefan Holdermans [EMAIL PROTECTED] writes: Stefan Max, class DatabaseEntry e where entryLabel :: e - String formatEntry :: e - String compareEntries :: e - e - Ordering Then I define data Entry = forall a. (DatabaseEntry a) = Entry a instance DatabaseEntry Entry where

Re: [Haskell-cafe] Type classes

2006-03-20 Thread Matthias Fischmann
Vasin wrote: To: haskell-cafe@haskell.org From: Max Vasin [EMAIL PROTECTED] Date: Mon, 20 Mar 2006 17:46:43 +0300 Subject: [Haskell-cafe] Type classes Hi! I'm currently experimenting with a bibliography generation tool for LaTeX. It will (if it will be finished) use BibTeX databases

Re: [Haskell-cafe] Re: how would this be done? type classes? existentialtypes?

2006-03-19 Thread Matthias Fischmann
On Fri, Mar 17, 2006 at 04:53:42PM +, Ben Rudiak-Gould wrote: Matthias Fischmann wrote: and now it gets interesting: i need instances for Rs on Show, Read, Eq, Ord. Show is very simple, but Read? I think you're right: it's impossible to implement Read for Rs in an extensible way,

[Haskell-cafe] Re: how would this be done? type classes? existential types?

2006-03-17 Thread Ben Rudiak-Gould
Matthias Fischmann wrote: now i want to create a list of a type similar to [r1, r2, r3] :: (Resource a) = [a] but with r1 being pizza, r2 being crude oil, and so on. The type you actually want here is [exists a. (Resource a) a], but no Haskell implementation supports that. data Rs =

[Haskell-cafe] Re: how would this be done? type classes? existentialtypes?

2006-03-17 Thread Ben Rudiak-Gould
Matthias Fischmann wrote: is there any difference between these two? if they are equivalent, why the two different ways to say it? data X where X :: (Resource a) = a - X data Y = forall a . (Resource a) = Y a There's no difference. There are two ways to say it for historical reasons.

[Haskell-cafe] Re: how would this be done? type classes? existential types?

2006-03-17 Thread Ben Rudiak-Gould
Matthias Fischmann wrote: On Thu, Mar 16, 2006 at 12:40:00PM +, Chris Kuklewicz wrote: (Why isn't it resourceName :: String ?) when i am trying this, ghc complains that the type of resourceName doesn't have any occurrance of 'a', and i feel that it must be harder for the type engine to

<    1   2   3   4   5   6   7   >