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
; () 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
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
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
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
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
| 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
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:
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
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
- 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
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
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
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
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
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
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
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
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):
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 ::
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
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
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
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
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
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
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
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
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,
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
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
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
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
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
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
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
[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
(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
. 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
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
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
, 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
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
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
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
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
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
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
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
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.
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
[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
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
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
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
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
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,
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
___
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
...
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
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
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
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
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
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
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 [...]
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
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
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
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
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
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
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
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
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
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
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,
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 ::
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) =
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
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
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,
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 =
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.
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
401 - 500 of 676 matches
Mail list logo