[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*To*: haskell@cs.glasgow.ac.uk*Subject*: Contexts in @data@ and @type@*From*: Simon L Peyton Jones <simonpj@cs.glasgow.ac.uk>*Date*: Fri, 01 Mar 91 17:15:06 +0000*Sender*: haskell-request@cs.glasgow.ac.uk

Nobody has been able to give a satisfactory account of what contexts in data and type declarations ACTUALLY MEAN. (see for example Sections 4.1.3, 4.3.2, etc). I propose the following simplifications. PROPOSAL ~~~~~~~~ 1. Contexts in @type@ declarations should vanish from the language. Nobody has been able to explain what they mean. 2. The declaration data (Eq a, Eq b) => Foo a b = C1 b a | C2 b Int | C3 introduces the (perfectly ordinary) type constructor Foo, and also introduces typings for C1, C2, C3 as follows: C1 :: forall a,b . (Eq a, Eq b) => b -> a -> Foo a b C2 :: forall a,b . Eq b => b -> Int -> Foo a b C3 :: forall a,b . Foo a b AND THAT IS THE *ONLY* WAY IN WHICH Foo IS SPECIAL. In general, each constructor gets a context which is a subset of that given in the @data@ decl, containing all the constraints on the free type variables of the constructor signature, and no others. (I was persuaded of this minor complication by John's comments, and by the fact that many more cases of ambiguity are likely to arise otherwise.) End of proposal ~~~~~~~~~~~~~~~

- Prev by Date:
**Re: Dictionaries are sometimes not necessary** - Next by Date:
**Pattern bindings** - Previous by thread:
**Dictionaries are sometimes not necessary** - Next by thread:
**Pattern bindings** - Index(es):