The ghc compiler complains about 2 type errors in the following code:
data SearchResult a = Found a | Fail
class (Eq key, Ord key) = Dictionary dict key dat where
delete :: key - dict - dict
search :: key - dict - (key,SearchResult dat,dict)
searchList :: [key] -
Ambiguous type variable(s)
`key', `dict'
in the constraint `Dictionary dict key a10v'
arising from use of `searchList' at Dtest2.hs:11
In an equation for function `searchList':
searchList (x : xs) d
= let
During developing a module, I tried to compile the incomplete module
SplayTree.hs to check something and got a panic!
After changing the incorrect first line of SplayTree.hs from
module Dictionary where
to
module SplayTree where
I got the right error messages I "wanted".
The 3 concerned
Arnd Gehrmann writes:
Liebe Netznutzer,
zum Aktivieren des neuen Schaltschrankes suche ich einen Termin, an dem das
Netz für ca.2-3 Stunden abgeschaltet bleiben kann. Ich bitte daher für die
Planung darum, mir für die nächsten, sagen wir mal 8 Tage die Termine zu
nennen, an denen das
ghc expects that I use all type variables in a multi-paramter type class.
It seems to me that this makes no sense.
e.g.: a Dictionary class with 'key' as the type of keys in 'dict' and 'dat' as
the type of information associated with a key.
class (Eq key, Ord key) = Dictionary dict key dat
You're right. The restriction is excessive. Thanks for pointing
this out. Probably we should only require that at least one
of the class variables is constrained.
Why even require this? (All x) = x - x uses the class `All'
which restricts its argument not one whit. -- P
The ghc compiler complains about 2 type errors in the following code:
data SearchResult a = Found a | Fail
class (Eq key, Ord key) = Dictionary dict key dat where
delete :: key - dict - dict
search :: key - dict - (key,SearchResult dat,dict)
searchList :: [key] -
Simon L Peyton Jones wrote:
GHC 3.02 supports multi-parameter type classes, but I have been
guilty of not documenting precisely what that means.
I've now summarised the extensions, informally but I hope
precisely, at
http://www.dcs.gla.ac.uk/multi-param.html
That does not seem
| class (Eq key, Ord key) = Dictionary dict key dat where
|delete :: key - dict - dict
| ...
| the first error:
|
| Class type variable `dat' does not appear in method signature
| delete :: key - dict - dict
|
| Why does ghc expect that I use all of the type
Actually I think you would be better off with a class like
this:
class (Eq key, Ord key) = Dictionary dict key where
delete :: key - dict dat - dict dat
search :: key - dict dat - (key, SearchResult dat, dict dat)
searchList :: [key] - dict dat - ([(key,SearchResult
10 matches
Mail list logo