unresolved overloading (in Hugs 1.4) 
Author Message
 unresolved overloading (in Hugs 1.4)

How can I make this comparison succeed?

Quote:
> ([],1000,"",[],[[1]]) ==  ([],1000,"",[],[[1]])

ERROR: Unresolved overloading
*** type       : (Eq a, Eq b) => Bool
*** expression : ([],1000,"",[],[[1]]) == ([],1000,"",[],[[1]])

Another (similar/same) difficulty is:

Quote:
> let (a,b,c,d,e) = ([],1000,"",[],[[1]]) in show a

ERROR: Unresolved overloading
*** type       : Show a => [Char]
*** expression : let {...} in show a

The actual data type i'm having a problem with is along the lines of:
 type Env = ([Form], SeqnSupply, String, [String], [[Int]])

 let
  nullEnv = ([], initSeqn, pwd, nullOptions, initTimeLine)
  initEnv = envSetOpts nullEnv options
 in initEnv == initEnv

 --Form is
 data Form = .....
 instance Show Form where ...
 instance Eq   Form where ...

Any would be help appreciated,

John Atwood



Tue, 24 Jul 2001 03:00:00 GMT  
 unresolved overloading (in Hugs 1.4)

Quote:

> > ([],1000,"",[],[[1]]) ==  ([],1000,"",[],[[1]])
> ERROR: Unresolved overloading
> *** type       : (Eq a, Eq b) => Bool
> *** expression : ([],1000,"",[],[[1]]) == ([],1000,"",[],[[1]])

The problem is caused by empty lists, the type system can't make sure
that they are of the same type. Use the following:

Quote:
> ([]::[Int], 1000,"", []::[Int], [[1]]) == ([], 1000, "", [], [[1]])

True
(Or whatever their types are, of course that type must be an Eq type).

Quote:
> Another (similar/same) difficulty is:
> > let (a,b,c,d,e) = ([],1000,"",[],[[1]]) in show a
> ERROR: Unresolved overloading
> *** type       : Show a => [Char]
> *** expression : let {...} in show a

Same as above..
Quote:
> let (a,b,c,d,e) = ([]::[Int],1000,"",[],[[1]]) in show a

"[]"

Quote:
> The actual data type i'm having a problem with is along the lines of:
>  type Env = ([Form], SeqnSupply, String, [String], [[Int]])

>  let
>   nullEnv = ([], initSeqn, pwd, nullOptions, initTimeLine)
>   initEnv = envSetOpts nullEnv options
>  in initEnv == initEnv
>  --Form is
>  data Form = .....
>  instance Show Form where ...
>  instance Eq   Form where ...

make Env a data declaration and declare it as an instance of the Eq class.
i.e.

  data Env = E ([Form], SeqnSupply, String, [String], [[Int]])

  instance Show Env where
   showsPrec _ (E e) = ..... <- code to convert an Env to a String..

-Levent.



Wed, 25 Jul 2001 03:00:00 GMT  
 unresolved overloading (in Hugs 1.4)

Quote:

> How can I make this comparison succeed?

> > ([],1000,"",[],[[1]]) ==  ([],1000,"",[],[[1]])
> ERROR: Unresolved overloading
> *** type       : (Eq a, Eq b) => Bool
> *** expression : ([],1000,"",[],[[1]]) == ([],1000,"",[],[[1]])

An even more trivial example of this problem is

Prelude> [] == []
ERROR: Unresolved overloading
*** type       : Eq a => Bool
*** expression : [] == []

The problem is that hugs can't infer the type of the empty lists from
the context in the above statements.  In my trivial case this can be
solved by stating what type of lists they are, as in

Prelude> ([]::[Int]) == ([]::[Int])
True

For example, suppose you say "show []".  If [] is a [Char], then hugs
should print
""
but if [] is a [Int] then hugs should print
[]
So you need to disambiguate the types of the empty lists.

Quote:

> Another (similar/same) difficulty is:
> > let (a,b,c,d,e) = ([],1000,"",[],[[1]]) in show a
> ERROR: Unresolved overloading
> *** type       : Show a => [Char]
> *** expression : let {...} in show a

--
Adam P. Jenkins



Thu, 26 Jul 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Hugs 1.4 available somewhere?

2. Debugger for Hugs 1.4

3. Hugs 1.4, Haskell: the Craft of Functional Programming, and GHC

4. Hugs 1.4 Haskell ... sqrt function

5. Reading lines from file in Hugs 1.4

6. Announcing the final version of Hugs 1.4

7. Q on Parser Combinators (in hugs 1.4)

8. hugs 1.4

9. Unresolved Overloading

10. Haskell typing problems (Unresolved Overloading)

11. Unresolved top-level overloading

12. How does one over come "Class storage space exhausted": I'm using Hugs 1.4 for the PC

 

 
Powered by phpBB® Forum Software