Xref: utzoo comp.object:3311 comp.lang.misc:7588 comp.lang.eiffel:1533 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!yale!cs.yale.edu!newsbase!duchier From: duchier@cs.yale.edu (Denys Duchier) Newsgroups: comp.object,comp.lang.misc,comp.lang.eiffel Subject: Re: A Hard Problem for Static Type Systems Message-ID: Date: 24 Apr 91 00:50:41 GMT References: <1991Apr20.010347.28984@leland.Stanford.EDU> Sender: news@cs.yale.edu Reply-To: duchier-denys@cs.yale.edu Followup-To: comp.object Organization: Computer Science, Yale University, New Haven, CT 06520-2158 Lines: 35 Nntp-Posting-Host: albania.ai.cs.yale.edu In-reply-to: craig@leland.Stanford.EDU's message of 20 Apr 91 01:03:47 GMT Haskell has the notion of classes, and below is the code taken verbatim from the implementation of the Prelude. `instance (Ord a) => Ord [a] where ...' basically means, if `a' is a type of class Ord, then `list of a' is also a type of class Ord, and the following operations are defined on it...'. Implementing this functionality typically requires passing a dictionnary (as an additional argument) that specifies the operations defined on type `a' as a member of class Ord (something like this; I'm a little fuzzy on the exact details). module PreludeListInst where import PreludeRealCore instance (Eq a) => Eq [a] where [] == [] = True (a:b) == (c:d) = a == c && b == d _ == _ = False instance (Ord a) => Ord [a] where [] <= _ = True _ <= [] = False (a:b) <= (c:d) = a <= c || a == c && b <= d _ < [] = False [] < _ = True (a:b) < (c:d) = a < c || a == c && b < d See "Report on the programming Language Haskell, A non-strict, Purely Functional Language" (YALEU/DCS/RR-777). Does this answer your question, or did I misunderstand the point you were trying to make? --Denys