I am quite confused with the collection package provided by the edison library. Attached is a sample program, what I wanted to do is to maintain a sorted of Pair of id and time (sorted by time). The error I got is: ghc -package data -package lang test.hs test.hs:17: No instance for `Collection.OrdColl c Pair' arising from use of `Collection.minElem' at test.hs:17 in a pattern binding: Collection.minElem sorted Actually I don't really understand what a class like "OrdColl c a" really means and how to use them. Please help! Regards, .paul.
I'm no edison expert but it seems the problem simply is that you're using overloaded functions and the compiler can't tell which instance you're trying to use. Try adding a type signature to the definition of sorted (I'm not familiar enough with edision to know what the type is) but something like: let sorted = ... :: SOMETYPEHERE hopefully someone will provide a more complete answer soon, but since no one has replied yet... - Hal -- Hal Daume III "Computer science is no more about computers | hdaume@isi.edu than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume On Tue, 30 Jul 2002 paul@theV.net wrote:
I am quite confused with the collection package provided by the edison library. Attached is a sample program, what I wanted to do is to maintain a sorted of Pair of id and time (sorted by time). The error I got is:
ghc -package data -package lang test.hs
test.hs:17: No instance for `Collection.OrdColl c Pair' arising from use of `Collection.minElem' at test.hs:17 in a pattern binding: Collection.minElem sorted
Actually I don't really understand what a class like "OrdColl c a" really means and how to use them. Please help!
Regards, .paul.
The Collection module just defines the OrdColl class, without giving any instances for it. To use the Collection module directly, you would have to define one or more instances yourself, something like this: data Bag a = ... instance OrdColl Bag a where insert a c = ... minElem c = ... ... But I assume that you don't want to implement your own collection datatype or write your own insert, minElem, etc. Luckily, Edison comes with a few pre-defined instances of OrdColl, each in a separate module. You just have to import the one you want. Replace the line
import qualified Collection as C with import qualified SkewHeap as C (or LazyPairingHeap, or SplayHeap, or UnbalancedSet) and it should work fine.
Hope this helps. - Brian Huffman
Thanks, and it works! Another question is where can I find some documentation on these heap modules? What is the difference between SkewHeap, LazyPairingHeap, SplayHeap, UnbalancedSet, etc? I couldn't find any in GHC's documentation. Regards, .paul. On Tue, Jul 30, 2002 at 11:22:26AM -0700, Brian Huffman wrote:
The Collection module just defines the OrdColl class, without giving any instances for it. To use the Collection module directly, you would have to define one or more instances yourself, something like this:
data Bag a = ... instance OrdColl Bag a where insert a c = ... minElem c = ... ...
But I assume that you don't want to implement your own collection datatype or write your own insert, minElem, etc. Luckily, Edison comes with a few pre-defined instances of OrdColl, each in a separate module. You just have to import the one you want.
Replace the line
import qualified Collection as C with import qualified SkewHeap as C (or LazyPairingHeap, or SplayHeap, or UnbalancedSet) and it should work fine.
Hope this helps. - Brian Huffman
The author of edison, Chris Okasaki, wrote a book called "Purely Functional Data Structures" (Cambridge University Press). It goes a long way toward explaining the rationale of many of the structures. On Wed, 31 Jul 2002 paul@theV.net wrote:
Thanks, and it works! Another question is where can I find some documentation on these heap modules? What is the difference between SkewHeap, LazyPairingHeap, SplayHeap, UnbalancedSet, etc?
I couldn't find any in GHC's documentation.
Regards, .paul.
On Tue, Jul 30, 2002 at 11:22:26AM -0700, Brian Huffman wrote:
The Collection module just defines the OrdColl class, without giving any instances for it. To use the Collection module directly, you would have to define one or more instances yourself, something like this:
data Bag a = ... instance OrdColl Bag a where insert a c = ... minElem c = ... ...
But I assume that you don't want to implement your own collection datatype or write your own insert, minElem, etc. Luckily, Edison comes with a few pre-defined instances of OrdColl, each in a separate module. You just have to import the one you want.
Replace the line
import qualified Collection as C with import qualified SkewHeap as C (or LazyPairingHeap, or SplayHeap, or UnbalancedSet) and it should work fine.
Hope this helps. - Brian Huffman
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
participants (4)
-
Brian Huffman -
Dan Weston -
Hal Daume III -
paul@theV.net