Opened 8 years ago

Closed 8 years ago

Last modified 6 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: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

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 8 years ago by simonpj

  • Resolution set to invalid
  • Status changed from new to closed

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 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:3 Changed 6 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.