[Haskell-cafe] Ambiguous types for collection keys

2006-04-12 Thread Scott Weeks
Hello everyone, I've been banging my head against my desk a bit so I figured it's time to ask for help :-) I'm writing an application that persists data to disk. The hard stuff is pretty much done (binary serialisation, etc...) The big stumbling block is that I want users to be able to

Re: [Haskell-cafe] Ambiguous types for collection keys

2006-04-12 Thread ihope
On 4/12/06, Scott Weeks [EMAIL PROTECTED] wrote: Hello everyone, I've been banging my head against my desk a bit so I figured it's time to ask for help :-) When a user queries I have to read the input from IO and then somehow cast the key/index type without angering the type checker. If I

Re: [Haskell-cafe] Ambiguous types for collection keys

2006-04-12 Thread Scott Weeks
Well, if you get an ambiguous type variable error, you probably (I think) need to add some type annotations. For example: class Foo a where foo :: a bar :: a - String Evaluating bar foo will result in an error, but bar (foo :: Integer) will work just fine. The

Re: [Haskell-cafe] Ambiguous types for collection keys

2006-04-12 Thread Robert Dockins
On Apr 12, 2006, at 3:18 PM, Scott Weeks wrote: Well, if you get an ambiguous type variable error, you probably (I think) need to add some type annotations. For example: class Foo a where foo :: a bar :: a - String Evaluating bar foo will result in an error, but bar (foo :: Integer)

Re: [Haskell-cafe] Ambiguous types for collection keys

2006-04-12 Thread Brandon Moore
Robert Dockins wrote: On Apr 12, 2006, at 3:18 PM, Scott Weeks wrote: Well, if you get an ambiguous type variable error, you probably (I think) need to add some type annotations. For example: class Foo a where foo :: a bar :: a - String Evaluating bar foo will result in an error,

Re: [Haskell-cafe] Ambiguous types for collection keys

2006-04-12 Thread Scott Weeks
Or carry an instance in along with a type parameter, using existentials or GADT. Brandon Moore Do you know of an example that would apply to my situation? I think I neglected to state part of my problem. I am storing the root nodes of btree indexes in a heterogeneous list using Typeable.

Re: [Haskell-cafe] Ambiguous types for collection keys

2006-04-12 Thread Robert Dockins
On Apr 12, 2006, at 4:09 PM, Scott Weeks wrote: Or carry an instance in along with a type parameter, using existentials or GADT. Brandon Moore Do you know of an example that would apply to my situation? I think I neglected to state part of my problem. I am storing the root nodes of

Re: [Haskell-cafe] Ambiguous types for collection keys

2006-04-12 Thread Scott Weeks
You are trying to assign two distinct types to dynFoo; that's a no-no. You need to move the usage of the polymorphic function out of the let so that the use at each distinct type doesn't get unified. {-# OPTIONS -fglasgow-exts #-} import Data.Dynamic data Foo a = FVal a