Opened 12 years ago

Closed 12 years ago

Last modified 9 years ago

#663 closed bug (invalid)

Confusion about types

Reported by: guest Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 6.4.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


In GHC 6.0.1 the following data type definition (for a binary search tree) seems to be invalid. I know I've used this kind of thing before, so whats up. This is the entire file, by the way:

data BST a = Ord a => Leaf | Node a (BST a) (BST a)

Gives an error message :

All of the type variables in the constraint `Ord a' are already in scope

(at least one must be universally quantified here)

When checking the existential context of constructor `Leaf' In the data type declaration for `BST'

I'm confused - where would I put a universal quantification? Does Leaf now need a type declaration and if so what would it be?

Change History (3)

comment:1 Changed 12 years ago by simonpj

Resolution: invalid
Status: newclosed

Not a bug, but rather a confusion about data type declarations.

My advice: just leave the "Ord a =>" out. If you must have it, use this

  data Ord a => BST a = ...

The Haskell Report discusses this; Haskell-cafe mailing list will help too.

comment:2 Changed 9 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:3 Changed 9 years ago by simonmar

Operating System: UnknownUnknown/Multiple
Note: See TracTickets for help on using tickets.